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: Beginner: Re: [BillKSmith] Grepping a file in all the files in an array and storing them in a hash: Edit Log



iphone
User

Oct 28, 2010, 6:34 PM


Views: 7988
Re: [BillKSmith] Grepping a file in all the files in an array and storing them in a hash


Quote

All the hash values are the same. They all refer to the same array. You want each one to refer to an different anonymous array. Note how this is done in the examples in the reference.


1.why do they refer to same array?I have a loop in place for every plf(see below code)


Code
foreach my $plf (@plf_files) { 
chomp($plf);
open my $match, '<',"$start_dir\\$plf" or die "could not open '$plf' $!";
my @file_lines = <$match>;
$Hash_filenames{$plf}=\@file_lines;
}


2.I have question on the below line

Code
@{ $Hash_filematches{ $filename } } = grep( /\/\Q$file_name\E#/i, @{ $Hash_filenames{ $plf } });

I am grepping on @{ $Hash_filenames{ $plf } } which I believe gives size of array,how will this work grepping on size of array?


(This post was edited by iphone on Oct 28, 2010, 6:40 PM)


Edit Log:
Post edited by iphone (User) on Oct 28, 2010, 6:34 PM
Post edited by iphone (User) on Oct 28, 2010, 6:35 PM
Post edited by iphone (User) on Oct 28, 2010, 6:35 PM
Post edited by iphone (User) on Oct 28, 2010, 6:40 PM


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

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