As you can see, "name,ipAdd,DestDev" are names of structured fields within the gzipped file. Let's say I ran this:"atlanta" "192.168.1.1" "vienna" "miami" "192.168.1.2" "dallas" "nyc4" "192.168.1.3" "boston"
which produces the following output:exfields.pl file2.gz name,ifSpeed
my new program would "merge" the output of both of those files producing:"atlanta" "622000000" "miami" "155000000" "nyc4" "155000000"
So, here's what I've got so far:"atlanta" "192.168.1.1" "vienna" "622000000" "miami" "192.168.1.2" "dallas" "155000000" "nyc4" "192.168.1.3" "boston" "155000000"
I suppose that I have three questions: 1. It was sugessted that I return a reference to a hash, thus conserving some memory. Would that just be, return /%hash? 2. In any case, what kind of print statement can I insert to test the contents of each hash, as returned? 3. I can't seem to find any information regarding reading data contained in a hash into DBI? Oh yeah, the reason that I am using a hash is that I would like the keys of the hash to become the column headers in the database table that I create. Any direction/help, as always, is much appreciated!#!/usr/local/bin/perl -w ## merge.pl use strict; if ($ARGV[3] ne "") { my $file1 = $ARGV[0]; my $list1 = join (",", $ARGV[1]); my $file2 = $ARGV[2]; my $list2 = join (",", $ARGV[3]); my %hash_1 = process($file1, $list1); my %hash_2 = process($file2, $list2); }else { print "merge.pl - Usage: file field(s) file field(s)\n"; } sub process { my ($file, $list) = @_; my $script = "perl /home/limo/Perl/exfields.pl -e"; my %hash; my $arg; for $arg (split /,/ => $list) { open(FILE, "$script $arg $file |") or die "System error: $!\n"; while (<FILE>) { next if /^(#|none|unkno)/i; chomp; push @{ $hash{$arg} }, split; } close FILE; } return %hash; }
In reply to Data in Hash - DBI by Limo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |