"be consistent" | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hello monks, thank you for your time. I am wondering about the proper syntax for inputing files at the command line and sending them to separate hashes. perl -walne '$h{$F[0]}.="$F[1]";END{print "$_:\t" . $h{$_} for sort keys%h}' file1.txt.
Now lets say I want to read in a second file as a second hash in the same execution... what is the syntax to tell perl that file1 and file2 should go to separate hashes? perl -walne '$h{$F[0]}.="$F[1]" Now here is where I want to read in file2.txt into %h2 ;END{$_=......... ' file1.txt file2.txtAny ideas on how to do this? Thanks a ton!! UPDATE how about something simpler... file one is a list, and I want to print out every line in file 2 that matches the current element in the list. In a script you would do this by making a nested foreach loop or you could do it by making a hash and then checking the hash.. How would one do this at command line (specifically dealing with 2 files ) ? Something like this where the file 2 lines only are piped in to the matching part: perl -F: -walne'$h{$F[0]}.="$F[1] "; END{#Line from file2 here#=~/$h{$_}/&&print"$h{$_}"for keys%h}' file1.txt file2.txt In reply to How to supply two input files at command line by ZWcarp
|
|