Hi Richard,

Your right, that won't actually work.  I wasn't paying very close attention was
I?  It'd have to be something like this to actually work:

my ($fgh) = $_ =~ /fgh\s+(\S+)/;

-J

--
On Fri, May 02, 2008 at 06:26:52PM -0400, Richard Lee wrote:
> Joshua Hoblitt wrote:
> >Richard,
> >
> >The unitalized warnings are probably coming from one or more of $fgh, $ijk,
> >$lmk being undefined because the regex failed to match anything.  You can 
> >test
> >this by trying to print the values of these variables.
> >
> >They are probably undefinately because the record seperator is being set
> >lexically inside of the loop (and thus won't apply to the outer while).  
> >Please
> >consider this code:
> >
> >    local $/ = "\n\n";
> >    while (<FH>) {
> >        ++$count;
> >     
> >        my $fgh =~ /fgh\s+(\S+)/;
> >        my $ijk =~ /ijk\s+(\S+)/;
> >        my $lmk =~ /lmk\s+(\S+)/;
> >        
> >        no warnings qw(uninitialized);
> >        warn "1: $fgh, 2: $ijk, 3: $lmk\n";
> >      
> >        push @yahoo, join('_', $fgh, $ijk, $lmk);
> >        use warnings;
> >    }
> >
> >Cheers,
> >
> >-J
> >
> >--
> >On Fri, May 02, 2008 at 05:55:58PM -0400, Richard Lee wrote:
> >  
> >>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);
> >>}
> >>
> >>[EMAIL PROTECTED] tmp]# cat fgg
> >>abc
> >>def
> >>fgh 111
> >>ijk 333
> >>lmn 2
> >>
> >>abc
> >>def
> >>fgh 222
> >>ijk 121
> >>lmk 23
> >>[EMAIL PROTECTED] tmp]#
> >>
> >>-- 
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>http://learn.perl.org/
> >>
> >>    
> 
> 
> thank you for this help..
> 
> question.. will this solution actually work ? I changed mine to series 
> of if statment because i wasn't sure if regex will work on $_ since I am 
> putting =~ to the varilable i want to assign to.. ? not sure

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to