in reply to Re^3: Constructing a hash - why isn't my regex matching anything
in thread Constructing a hash - why isn't my regex matching anything
I did look at my code(below),I am hardly doing anything other than constructing the hash
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %hash; open my $fh, '<', $ARGV[0] or die "could not open $ARGV[0]'' $!"; while (my $line = <$fh>) { #print "line:$line\n"; my ($key) = $line =~ /;([^;]+)\s-\s/; #print "KEY:$key\n"; my ($value) = $line =~ /\.\\(.*)-\d+\;/; #print "VALUE:$value\n"; if (!($hash{$key})) { $hash{$key}=$value; } } open my $hash, '>', "hash_flf.txt"; print Dumper(\%hash); close $hash;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Constructing a hash - why isn't my regex matching anything
by Anonyrnous Monk (Hermit) on Dec 19, 2010 at 11:36 UTC |