I've several of those in the file that have only keys but no values. This
could be problematic. Is there a way, I can flag these while filling the
hash up?

Thanks,
perdeep

-----Original Message-----
From: John Bernard [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 30, 2002 3:37 PM
To: 'Mehta, Perdeep'
Subject: RE: [Perl-unix-users] Perl help



I think the input file which u read passes some line which does not have
$words[0] value

pls have a look at ur input file
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Mehta, Perdeep
Sent: Monday, September 30, 2002 1:30 PM
To: [EMAIL PROTECTED]
Subject: [Perl-unix-users] Perl help


Hi All,

I would appreciate any help on the following code.

Here I fill the defln hash with the appropriate keys and values:

use strict;
use warnings;

  my %defln = ();

  while (my $line = <FILE>) {
       chop($line);
       if ($line =~ /^$/) {
          next;
       }
       else {
          my @words = split(/\t+/, $line);
          push(@{ $defln{$words[0]} }, $line);
       }
   }


Then I wish to retrieve the value associated with a key and work on it,

     my($defln) = @{ $defln{$words[0]} };
     my($string) = ($defln =~ /\s*\|([^|]+)\|/g);  # string between two
pipes
     print OUT "> $string\n";

Though the result is printed out but it throws following error that I could
not resolve,

Use of uninitialized value in concatenation (.) or string at test.pl line
103, <FILE> line 1895.
The line 103 points to the print statement.

Thanks in advance,
perdeep
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to