Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > Re: another hel...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 16 Topic 11019 of 11531
Post > Topic >>

Re: another help on input record separator clarity please

by jhoblitt@[EMAIL PROTECTED] (Joshua Hoblitt) May 2, 2008 at 11:08 AM

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 @[EMAIL PROTECTED]
 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 @[EMAIL PROTECTED]
> my $count;
> 
> while (<FH>) {
>    local $/ = "\n\n";
>    ++$count;
> 
>    my $fgh =~ /fgh\s+(\S+)/;
>    my $ijk =~ /ijk\s+(\S+)/;
>    my $lmk =~ /lmk\s+(\S+)/;
>  
>    push @[EMAIL PROTECTED]
 join('_', $fgh, $ijk, $lmk);
> }
> 
> [root@[EMAIL PROTECTED]
 tmp]# cat fgg
> abc
> def
> fgh 111
> ijk 333
> lmn 2
> 
> abc
> def
> fgh 222
> ijk 121
> lmk 23
> [root@[EMAIL PROTECTED]
 tmp]#
> 
> -- 
> To unsubscribe, e-mail: beginners-unsubscribe@[EMAIL PROTECTED]
> For additional commands, e-mail: beginners-help@[EMAIL PROTECTED]
> http://learn.perl.org/
>
 




 16 Posts in Topic:
another help on input record separator clarity please
rich.japh@[EMAIL PROTECTE  2008-05-02 17:55:58 
Re: another help on input record separator clarity please
chas.owens@[EMAIL PROTECT  2008-05-02 17:58:47 
Re: another help on input record separator clarity please
rich.japh@[EMAIL PROTECTE  2008-05-02 18:21:32 
Re: another help on input record separator clarity please
rvtol+news@[EMAIL PROTECT  2008-05-03 00:32:22 
Re: another help on input record separator clarity please
rvtol+news@[EMAIL PROTECT  2008-05-03 12:40:34 
Re: another help on input record separator clarity please
jhoblitt@[EMAIL PROTECTED  2008-05-02 11:08:27 
Re: another help on input record separator clarity please
chas.owens@[EMAIL PROTECT  2008-05-02 20:04:43 
Re: another help on input record separator clarity please
rich.japh@[EMAIL PROTECTE  2008-05-02 21:48:41 
Re: another help on input record separator clarity please
chas.owens@[EMAIL PROTECT  2008-05-03 04:26:34 
Re: another help on input record separator clarity please
jhoblitt@[EMAIL PROTECTED  2008-05-02 11:26:06 
Re: another help on input record separator clarity please
chas.owens@[EMAIL PROTECT  2008-05-03 16:41:18 
Re: another help on input record separator clarity please
rvtol+news@[EMAIL PROTECT  2008-05-04 20:25:44 
Re: another help on input record separator clarity please
chas.owens@[EMAIL PROTECT  2008-05-04 15:42:43 
Re: another help on input record separator clarity please
rvtol+news@[EMAIL PROTECT  2008-05-04 23:01:08 
Re: another help on input record separator clarity please
chas.owens@[EMAIL PROTECT  2008-05-04 19:00:38 
sed split on pipe
pauliecat@[EMAIL PROTECTE  2008-05-06 05:27:04 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 1:01:38 CDT 2008.