Title: regrouping lines of STDIN

Hello London.pm

first let me apologise, I know this mail will be accompanied by an HTML version & I don't know how to prevent it. Outlook swears I'm using plain text but somehow it doesn't end up that way. So, sorry...

This is intended to re-sort STDIN according to a regexp:

        my $rxp  = $ARGV[0];   
        my %seen;

        print $rxp;

        while (<STDIN>) {
            if (my ( $code ) = /$rxp/g) {
                push @{ $seen{$code} } , $_;
            }
        }
       
        for (%seen) {
        # could maybe sort these by the key
            for (@$_) {
                 print;
             }
        }

It won't work with strict because I get "Can't use string ("AA") as an ARRAY ref while "strict refs" in use." How do I use a proper array ref? Any other comments very welcome...

cheers,
Tom SW

Reply via email to