#!/usr/bin/perl -w use strict; my @files_to_process= ( {data=>"The quick\n" . "brown fox\n" . "ran over\n" . "the purple\n" . "witch. So\n". "there!\n"} ); foreach my $record (@files_to_process) { while ($record->{data} =~/(.*\n)/g) { chomp (my $line = $1); my $second_line = ""; print "$line\n"; if ($line =~ /witch/) { if ($record->{data} =~ /(.*\n)/gm) { $second_line = $1; } print "-> $second_line\n" if $second_line; } } }
In reply to Re: using a variable as a filehandle
by Sandy
in thread using a variable as a filehandle
by bear0053
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |