in reply to Re: split() Problem
in thread split() Problem

I think your problem is that you do too much at once without testing the result from the intermediate steps.

Most of my scripts start with

# always use those: use strict; use warnings; use Data::Dumper;

When you suspect that split isn't working the way you think it is, try adding the line print Dumper \@foo; immediately after the split, and look if the results are what you execpted it to be.

The $foo[$_] is always empty so

for iterates over the values in the array, not the indexes. So instead of $foo[$_] just write $_.

Replies are listed 'Best First'.
Re^3: split() Problem
by Omukawa (Acolyte) on Jul 22, 2008 at 10:52 UTC

    Changing $foo[$_] with $_ solved the problem. Thanks a lot. Also thank you for the advice about Data::Dumper