[tpm] how to delete array entries en-passant

Shaun Fryer sfryer at sourcery.ca
Wed Jun 30 09:46:07 PDT 2010


# a file and an input stream are both filehandles
# assign $fh from either <> or open()

while (<$fh>) {
    my $line = process($_);
    print $line if $line !~ /^\s*\z/;
}

--
Shaun Fryer

On Wed, Jun 30, 2010 at 12:35 PM, Fulko Hew <fulko.hew at gmail.com> wrote:
>> Does the process require the presence of the entire file in memory before
>> the loop, and the shuffled-down file afterwards? Do you output the
>> remaining lines?
>
> No, but I need to output the 'remaining' lines.
>
> Also I forgot to mention, the reason the original data was in an array, was
> because
> it came from one of two sources... slurping a file, or a 'received' string.
> So I thought I'd first normalize either dataset into the array I would then
> traverse.


More information about the toronto-pm mailing list