in reply to Finding a line in a scalar, and copying it to a new scalar?

Something like this would probably do:

use strict; use warnings; my $temp = "DATA\nFile\nHello\nAnother line\n"; my $found; if( $temp =~ m/File\n(^.*$)/m ) { $found = $1; print $found, "\n"; }

...I like the anchors in this regex, but there are a lot of other ways to craft the RE. Or you could to it this way instead:

my @lines = split /\n/, $temp; foreach my $idx ( 0 .. $#lines ) { next unless $lines[ $idx ] =~ m/File/; $found = $lines[ $idx + 1 ]; print $found; last; }

Dave