On 12/13/2013 07:43 AM, Shaji Kalidasan wrote:
Greetings,

Here is one way to do it. Please note that I have retained your variable naming 
conventions and style instead of inventing my own.

[code]
use strict;
use warnings;

my %complex_hash;

my @ex = qw / 5326 2041 1391 1439  x1259 /;

open my $fh, "<", "fullhost.txt" or die $!;
while (<$fh>) {

while( my $line = <$fh> ) {
     chomp;
     my $line = $_;

no need to copy $_ as the while did it.

     my ($key, $value) = split /\s+/, $line;
     chomp $key;
     chomp $value;

why did you chomp those? the line was chomped so any newlines are gone. those two lines don't do anything.

     $complex_hash{$key} = $value;
}

for my $element (@ex) {
foreach my $key (keys %complex_hash) {
if($key =~ /$element/) {
print " $element : \t\t\t ",  $complex_hash{$key}, "\n";
}
}
}

even if you copy the OP's names you need to indent.

uri

--
Uri Guttman - The Perl Hunter
The Best Perl Jobs, The Best Perl Hackers
http://PerlHunter.com

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to