in reply to How do I select first string of a two dimensional array to compare to other values?
I don't understand your question. It's usually better to include sample input data (within <code> tags) and expected output.
If you want to work with the first line only, don't use while. If you want to compare two string values, you should use eq, ne, or index, or maybe a regex: $value =~ /\Q$important/.
Update: example script added:
#!/usr/bin/perl use warnings; use strict; my $first_line = <DATA>; my $important = (split ' ', $first_line)[0]; while (<DATA>) { # Process the remaining lines. my $value = (split)[0]; print if $value eq $important; } __DATA__ john chevrolet usa hans bmw germany ivan lada russia john talbot uk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do I select first string of a two dimensional array to compare to other values?
by joi1369 (Initiate) on Aug 31, 2015 at 01:05 UTC | |
by AnomalousMonk (Archbishop) on Aug 31, 2015 at 01:11 UTC | |
by joi1369 (Initiate) on Aug 31, 2015 at 01:19 UTC | |
by AnomalousMonk (Archbishop) on Aug 31, 2015 at 01:49 UTC | |
by AnomalousMonk (Archbishop) on Aug 31, 2015 at 01:30 UTC |