in reply to using split
Note: it often helps you and us if you reduce your sample code to just demonstrate the bug. Most likely in the process you will solve the problem, but even if you don't you will understand it better. In either case you will remember the lesson better at the end of the day.
Your sample could have reduced to:
use strict; use warnings; my $line = "This|that"; my @cols = split(/|/, $line); print "@cols";
Prints:
T h i s | t h a t
where I expected:
This that
I know what I mean. Why don't you? has a few other related tips that may help in the future.
Why no use strict by the way? Especially puzzling as there is a use warnings.
Added:
Note too that the 3 parameter open is much preferred over the two parameter open (see open) for lucidity and security.
if ($cols[11] = $target1)
looks wrong! Do you really intend to assign $target1 to $cols[11]? Note that the if is (effectively) testing the contents of $target1, not equality of $target1 and $cols[11].
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: using split
by naikonta (Curate) on Jun 05, 2007 at 02:21 UTC | |
by GrandFather (Saint) on Jun 05, 2007 at 03:26 UTC | |
|
Re^2: using split
by educated_foo (Vicar) on Jun 04, 2007 at 21:42 UTC | |
by GrandFather (Saint) on Jun 04, 2007 at 23:56 UTC | |
by educated_foo (Vicar) on Jun 05, 2007 at 15:09 UTC | |
by GrandFather (Saint) on Jun 05, 2007 at 19:41 UTC |