[EMAIL PROTECTED] wrote:
> Hi,
> 
> I am not able to split a string and build an array. I am reading the
> lines from a file. I could not understand what I am doing wrong here.
> 
> My code is below:
> 
> #!/usr/bin/perl -w
> #
> ------------------------------------------------------------------------
> ------
> my $spool_file="gwcd";
> my $gwcd_file="/appl/loopqual/ait/log/$spool_file.lst";
> my ($wc_cd,$ind,$dm1,$dm2,$row_ct,$row);
> my (@wc,@source_ind,@dummy1,@dummy2,@wc_row_ct,@data);
> 
>   print "open $gwcd_file\n";
>   open(GWCDIN, "< $gwcd_file");  #|| die "can't open $gwcd_file: $!";
>   if ($? == 0)
>   {
>     print "open successful\n";
>     while (<GWCDIN>)
>     {
>       $row = $_;
>      ( $wc_cd, $ind, $dm1, $row_ct, $dm2 ) = split(/\s*/,$row);

        Believe it is breaking on each character since you state it can or can 
not be there.  Similar to //.  Change to \s+ and you will get the the first 
number, but don't see where you would get that second number. Believe from your 
code it should be 471453 and not 725906.

Wags ;) ps I made assumption that the 2 on the separate line was all part of 
one line. Changed into __DATA__ and ran the test for printing.


>      push(@wc,$wc_cd);
>      push(@source_ind,$ind);
>      push(@wc_row_ct,$row_ct);
>     }  # end while
> 
>     print "$wc[10]\n";
>     print "$wc_row_ct[10]\n";
>   }
> close GWCDIN;
> 
> The input file is below:
> 
> 313222                                   A 12/02/2003      44453
> 2
> 630620                                   A 02/28/2005     826240
> 2
> 847464                                   A 02/28/2005      29155
> 2
> 847576                                   A 02/28/2005      14147
> 2
> 847286                                   A 02/28/2005       5274
> 2
> 630323                                   A 03/01/2005     785867
> 2
> 708387                                   A 03/01/2005     725906
> 2
> 815932                                   A 03/01/2005     644998
> 2
> 616249                                   A 03/01/2005     620161
> 2
> 513422                                   A 03/01/2005     488744
> 2
> 708335                                   A 03/01/2005     471453
> 2
> 419422                                   A 03/01/2005     469839
> 2
> 419865                                   A 03/01/2005     389593
> 2
> 
> When I print, I was expecting the program to print 708335 and 725906
> on two separate lines. But the program is printing 7 and 3 on two
> separate lines.
> 
> Any help is really appreciated.
> 
> Thanx..
> -Bheem
> 
> _______________________________________________
> Perl-Unix-Users mailing list
> Perl-Unix-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



*******************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
*******************************************************


_______________________________________________
Perl-Unix-Users mailing list
Perl-Unix-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to