cool has asked for the wisdom of the Perl Monks concerning the following question:
Small portions of both the files are as follows,#! /usr/bin/perl -w open AA, '<',"A.txt" or die "open: $!"; foreach $line(<AA>) { chomp($line); @temp=split(/\./,$line); $new=$temp[0].'.'.$temp[1]; open BB, '<',"B.out" or die "Failed to open B.out: $!"; foreach $line1(<BB>) { @temp1=split(/\s+/,$line1); if($new eq $temp1[0]) { print $temp1[1]."\t"; print $temp1[2]."\n"; } } close (BB); } close(AA);
A.txt 1a6m_-.ent.dssp b1b5e_A.ent.dssp b1bx4_A.ent.dssp b1bx7_-.ent.dssp b1bxy_A.ent.dssp
Now, white space b/w column 2 and 3 of B.out is not constant. So while using split in line 11 of my code, I usedB.out b1a6m_-.ent 79K 83E 127.119 b1a6m_-.ent 80G 84A 136.545 b1b5e_A.ent 123R 127M 132.48 b1bx4_A.ent 61H 65S 145.4
and got error Use of uninitialized value in string eq at a.pl line 18, <BB> line 427. but if I use@temp1=split(/\s+/,$line1);
it works pretty fine. What is the reason for this err? Isn't / +/ and /\s+/ refer for same thing? Is there a better way of doing this?@temp1=split(/ +/,$line1);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: "Err:Use of uninitialized value in string eq" while using split
by thundergnat (Deacon) on May 04, 2006 at 14:06 UTC | |
|
Re: "Err:Use of uninitialized value in string eq" while using split
by socketdave (Curate) on May 04, 2006 at 14:08 UTC | |
by cool (Scribe) on May 04, 2006 at 15:13 UTC | |
|
Re: "Err:Use of uninitialized value in string eq" while using split
by jwkrahn (Abbot) on May 04, 2006 at 23:25 UTC |