in reply to Re: Pulling out pairs
in thread Pulling out pairs
dog:cat:pig <== skip, only has three fields Amy:Ann <== skip, only has two fields ape:ant:bug:car <== match this line (it has four fields) but we only need to keep 'ape' and 'ant'
Tweaking the code above, we might think that this will do the trick for us:
However, that doesn't seem to work for us, nothing gets printed. In fact, try as we might, we can't construct any line at all that passes the IDIOM==4 test.while (<DATA>) { chomp; (my ($first, $second) = split /:/) == 4 or next; print "$first $second\n"; } __DATA__ dog:cat:pig Amy:Ann ape:ant:bug:car
So, does anyone want to guess why IDIOM==4 is so different from IDIOM==2?
Update: As an added hint, testing for IDIOM==3 will match the 'dog:cat:pig' line....
-Blake
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Pulling out pairs
by Anonymous Monk on Dec 13, 2001 at 09:33 UTC | |
by blakem (Monsignor) on Dec 13, 2001 at 11:23 UTC |