in reply to Re: using a variable as a filehandle
in thread using a variable as a filehandle

First, I would to see some comparsion to split and why your way is better (which it is).

Second, why not do:

while (my ($line) = $record->{data} =~/(.*)\n/g) { ... }

It saves on the chomp and is more concise, imho ...

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Replies are listed 'Best First'.
Re^3: using a variable as a filehandle
by ikegami (Patriarch) on Nov 01, 2004 at 20:00 UTC

    That doesn't work, because you're changing the context of =~ from scalar to list. while ($record->{data} =~/(.*)\n/g) { my $line = $1; would be the equivalent without the chomp.

    However, neither solution will always work with Windows text files. See my reply to this post's grandparent.

Re^3: using a variable as a filehandle
by Sandy (Curate) on Nov 01, 2004 at 21:20 UTC
    It saves on the chomp and is more concise, imho ...
    Yep, you're right. I was tired, and in too much of a hurry

    sigh...