in reply to array of strings that matched a pattern

If you call it right, yes.

if (my @matches = $text =~ /some (regex) here (with) lots (of) capture +s/) { print join "\t", @matches; }

Replies are listed 'Best First'.
Re^2: array of strings that matched a pattern
by Anonymous Monk on Apr 29, 2011 at 14:27 UTC
    hi, that crashes for me (eclipse IDE goes black and does not respond). i'm in a while loop as shown in pseudocode
    while (<infile>) { if (my @matches = $_ =~ /exp/) { print join "\t", @matches; } }
    i had to do this
    while (<infile>) { if (my @matches = $_ =~ /exp/) { my $line = join "\t", @matches; print $line; } }
    I can't see what was wrong with the first version?
      Buffering?

      Throw a print "\n"; after the print join and see if it works (you probably didn't want the results from each line butted up against each other anyhow)

      You may want to set $|=1 at the start too, if you haven't already.

      I'm looking at Pro Perl by Peter Wainwright, and it indicates that:

      1) setting $| or

      2) using the autoflush method, if using IO::File or IO::Handle or

      3) printing to a terminal (not sure how perl sees your IDE)

      turns off block buffering, but line buffering is still active. I'd think terminating the line should guarantee a flush.

      -Greg

        That's by fault for not posting properly - i did actually have a \n at the end of the line. It was eclipse that was the problem - was fine from command line. I didn't think of it being a problem with eclipse. I assumed it was me :) Thank-you