in reply to Re: Parse a file into a hash
in thread [Resolved] Parse a file into a hash
#!/usr/bin/perl -w use warnings; use strict; my @tmp; ### Start Configuration my $src_file = "Servers.csv"; ### End Configuration my %stack = (); my $current_key = undef; my $current_value = undef; open( SRC, "<", $src_file ); while (<SRC>) { chomp; s/#.*//; s/\"//g; s/\;/\-/; push @tmp, $_ if $_ =~ m/^\;/ and next; my ($key,$value) = split /\-/, $_; push @tmp, $value; if (defined $key) { $current_key = $key; push @tmp, $value; $stack{$current_key} = @tmp; } close(SRC);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Parse a file into a hash
by aaron_baugher (Curate) on Apr 05, 2012 at 22:19 UTC | |
by kazak (Beadle) on Apr 06, 2012 at 14:50 UTC | |
by mendeepak (Scribe) on Apr 07, 2012 at 05:55 UTC | |
by kazak (Beadle) on Apr 09, 2012 at 14:43 UTC |