in reply to Re: Re: Extracting from a File
in thread Break List into Pieces (was: other ways ?)
It will probably be a lot faster to use substr or unpack than to glue individual characters together, especially when you are pulling them out of a complex data structure and not just a string.my @frags = ( { line => 5, column => 12, length => 10, name => 'foo' }, { line => 6, column => 12, length => 10, name => 'foo' }, ); # ... my %var; # @chunks is an array of arrays, where each contains a # block of the file. foreach my $chunk (@chunks) { foreach my $frag (@frags) { push(@{$var{$frag->{name}}}, substr($chunk->[$frag->{line}], $frag->{column}, $frag->{length})); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re^3: Extracting from a File
by physi (Friar) on May 15, 2002 at 18:54 UTC |