Chas. Owens wrote:
On Fri, May 2, 2008 at 5:55 PM, Richard Lee <[EMAIL PROTECTED]> wrote:
snip
while (<FH>) {
local $/ = "\n\n";
snip
}
snip
You want $/ to have an effect on <FH>, but it is localized to inside
of the loop. You need to say
{
local $/ = "\n\n";
while (<FH>) {
}
}
thanks..
works for me,
#!/usr/bin/perl
use strict;
use warnings;
open "FH", "<", "/tmp/fgg", or die "cannot $!\n";
my @yahoo;
my $count;
{
local $/ = "\n\n";
while (<FH>) {
++$count;
#my $fgh =~ /fgh\s+(\S+)/;
my ($f,$i,$l);
if (/fgh\s+(\d+)/smx) {
$f = $1;
}
if (/ijk\s+(\S+)/smx) {
$i = $1;
}
if (/lmn\s+(\S+)/smx) {
$l = $1;
}
push @yahoo, join('_', $f, $i, $l);
}
}
for (@yahoo) {
print "$_\n";
}
[EMAIL PROTECTED] tmp]# cat fgg
abc
def
fgh 111
ijk 333
lmn 2
abc
def
fgh 222
ijk 121
lmn 23
[EMAIL PROTECTED] tmp]# ./f_this.pl
111_333_2
222_121_23
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/