rmwheeler has asked for the wisdom of the Perl Monks concerning the following question:
Sample Data: Car Red 100 Car Black 100 Car Yellow 100 Bus Green 400 Truck Blue 300
Thanks!open (FILE, 'test.txt') or die "$!\n"; my @line = <FILE>; foreach my $line (@line) { chomp $line; my($car, $color, $amount) = split(/ /, $line); print "$car $color $amount\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Next Line Assigning to A Scalar
by davido (Cardinal) on Oct 29, 2014 at 21:04 UTC | |
by rmwheeler (Initiate) on Oct 30, 2014 at 15:41 UTC | |
by davido (Cardinal) on Oct 30, 2014 at 15:59 UTC | |
|
Re: Next Line Assigning to A Scalar
by toolic (Bishop) on Oct 29, 2014 at 20:07 UTC | |
by rmwheeler (Initiate) on Oct 29, 2014 at 20:25 UTC | |
by toolic (Bishop) on Oct 29, 2014 at 20:42 UTC | |
by rmwheeler (Initiate) on Oct 30, 2014 at 13:00 UTC | |
|
Re: Next Line Assigning to A Scalar
by GotToBTru (Prior) on Oct 29, 2014 at 20:38 UTC | |
by rmwheeler (Initiate) on Oct 30, 2014 at 13:08 UTC |