in reply to slurped scalar map
You could use lvalue refs:
#! perl -slw use strict; my $data = <<EOD; record 1 record 2 is a bit longer record 3 is just this length EOD my $p = 0; my @refs; while( my $o = 1+index $data, "\n", $p ) { push @refs, \substr $data, $p, $o - $p; $p = $o } print $$_ for @refs;
which works okay (from 5.8.4 (maybe 5.8.3 I forget) onwards), but don't try assigning to them unless your replacements are exactly the same length as the originals.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: slurped scalar map
by 0xbeef (Hermit) on Jun 20, 2006 at 21:26 UTC | |
by BrowserUk (Patriarch) on Jun 21, 2006 at 07:36 UTC |