CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [ccin1492] returning a hash from a subroutine...: Edit Log



KevinR
Veteran


Apr 9, 2009, 9:18 AM


Views: 595
Re: [ccin1492] returning a hash from a subroutine...

If the signals are unique you can use them as the hash keys, and probably the capacitance of each signal/key for all the files could be stored in an array that is the value of each signal/key.

Something like this:


Code
my @inputs = (a list of files); 
my %signals;
foreach my $file (@inputs) {
open (my $IN, "<", $file) or warn "Can't open file $file: $!";
while(<$IN>){
chomp;
# parse data here into $key (signal) and $val (capacitance)
push @{$signals{$key}},$val;
}
close($IN);
}


You could write a seperate subroutine to just parse the data and return the data back to the calling subroutine but that seems like a bit of overkill and added confusion for you at this point in time.
-------------------------------------------------


(This post was edited by KevinR on Apr 9, 2009, 9:29 AM)


Edit Log:
Post edited by KevinR (Veteran) on Apr 9, 2009, 9:28 AM
Post edited by KevinR (Veteran) on Apr 9, 2009, 9:29 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives