in reply to Using a Hash Variable in an If Statement
#!/usr/bin/perl use warnings; #use strict; my @names = qw( DONT MICH LEON RAPH SPLN SHRD CASY APRL FOOT BEBP RKST DUBY SAMH GRAW KNYN KP01 KP02 KP03 KP04 KP05 ); my %data; open my $file, "<", "rat_event.txt" or die "Can't open file:$!"; while(<$file>) { next if /\.mcp/; chomp; my ($s, $n) = split; push @{ $data{$s} }, $n; } my $i = 1; for my $name (@names) { print "$name\n"; my $x = 1; for (@{$data{$name}}) { print "Time $x : $_\n"; $x++; } print "\n"; $i++; } close($file);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using a Hash Variable in an If Statement
by Bama_Perl (Acolyte) on May 11, 2015 at 20:51 UTC | |
by edimusrex (Monk) on May 11, 2015 at 21:00 UTC | |
by Bama_Perl (Acolyte) on May 11, 2015 at 22:15 UTC | |
by 2teez (Vicar) on May 12, 2015 at 00:04 UTC | |
by edimusrex (Monk) on May 12, 2015 at 00:45 UTC | |
by 2teez (Vicar) on May 12, 2015 at 02:26 UTC |