develooper Front page | perl.beginners | Postings from May 2008

another help on input record separator clarity please

Thread Next
From:
Richard Lee
Date:
May 2, 2008 14:56
Subject:
another help on input record separator clarity please
Please help me with this another misunderstanding of my perl.

My plan is to make input record separator to "\n\n" so that file records 
are separated by blank space.. and then
collect information and push them into array by joining.

But when I run this, it says uninitilized values...  I am doing 
something wrong.. aren't i


cat ././f_this.pl
#!/usr/bin/perl

use strict;
use warnings;

open "FH", "<", "/tmp/fgg", or die "cannot $!\n";

my @yahoo;
my $count;

while (<FH>) {
    local $/ = "\n\n";
    ++$count;

    my $fgh =~ /fgh\s+(\S+)/;
    my $ijk =~ /ijk\s+(\S+)/;
    my $lmk =~ /lmk\s+(\S+)/;
  
    push @yahoo, join('_', $fgh, $ijk, $lmk);
}

[root@server tmp]# cat fgg
abc
def
fgh 111
ijk 333
lmn 2

abc
def
fgh 222
ijk 121
lmk 23
[root@server tmp]#

Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About