in reply to Regex Matching
The trick lies in the fact that you want to match any
character, but that the dot looses its special meaning in the
square brackets. See perlop and perlre. You could
just replace the bracket stuff with a single dot.
I would prefer to use substr to get the data (untested, you get the idea mehopes):
Hope this helps,my @lengths = qw/1 20 20 5/; #inside some looplike thing my @array = (); push @array, substr( $line, 0, $_, '' ) for @lengths; print join "\t", @array; }
Jeroen
"We are not alone"(FZ)
Update: Just stick to unpack as Hofmator says.
It gives you all in one line:
I couldn't get it to strip trailing spaces/nulls with A or Z or @, though.my @array= unpack 'a1a20a20a5', $line;
In Section
Seekers of Perl Wisdom