Are you asking how to set @ARGV that way? Or are you saying it already
contains something like:
@ARGV = qw(file1 a b file2 c d);
And if so, how do we know when the filenames end and the key letters begin?
And what kind of data structure do you want this in?
And what defines a column?
-- Randal L. Schwartz, Perl hacker | [reply] [d/l] |
Ok, one more time. Here is a very direct question that would really help me get started.
How do I parse the elements of:
merge.pl file_1 a,b,c file_2 d,e,f
so that:
file_1 a,b,c
gets placed in a hash where:
keys = "a", "b", "c"
and:
key values = /$aref_a, /$aref_b, /$aref_c
and:
file_2 d, e, f
</CODE>
gets placed in another hash where:
keys = "d", "e", "f"
and:
key values = /$aref_d, /$aref_e, /$aref_f
I believe that I can figure out the rest. This has just been a sticking point for me. Obviously. And regarding your "hire a programmer" comment. Look. I am NOT a programmer. I am a network engineer, tasked with writing some tools for my group. I have stated in just about every one of my posts that I am new to Perl. So, it shouldn't surprise anyone if I am having trouble expressing ideas in a programming context. Would you tell a 2 year old, who is just learning to speak, to "hire a tutor" before asking you a question? At any rate, I don't mean to sound ungrateful for everyone's help, nor do I want anyone to do my work for me. Just a little direction would be great. | [reply] [d/l] [select] |
| [reply] |
You know, I wish that I were a better programmer, so that I could be more succinct, but since Perl is very new to me, I do the best that I can, and try and learn from you folks.
To answer your questions:
@ARGV is set on the command line using the following syntax:
merge.pl file_1 a,b,c file_2 d,e,f
where "a,"b",c" and "d,"e",f" are column headers.
Columns are defined in the files as such:
#DFD ' '
#H Period Interface SrcRouter Subset MbitsCap Polls MbpsIn
MbpsOut MbpsSum InMinUtil In5pUtil InAvgUtil In95pUtil InMaxUtil
InUtilSD InMaxTS OutMinUtil Out5pUtil OutAvgUtil Out95pUtil
OutMaxUtil OutUtilSD OutMaxTS EffMinUtil Eff5pUtil EffAvgUtil
Eff95pUtil EffMaxUtil EffUtilSD EffMaxTS Class InPctDiscards
InPctErrors InPctDiscErr InPctDiscErr95Q OutPctDiscards
OutPctErrors OutPctDiscErr OutPctDiscErr95Q SecSysUpTime
InWrapEvts InWrapCnts OutWrapEvts OutWrapCnts PctPollsGT80pUtil
PctPollsGT1pDiscErr Flags KppsIn KppsOut IfDescr IfIndex
#F %-17s %-35s %-15s %-6s %9.5f %7d %14.3f %14.3f %14.3f %7.3f
%7.3f %7.3f %7.3f %7.3f %9.5f %14s %7.3f %7.3f %7.3f %7.3f %7.3f
%9.5f %14s %7.3f %7.3f %7.3f %7.3f %7.3f %9.5f %14s %3s %7.3f
%7.3f %7.3f %7.3f %7.3f %7.3f %7.3f %7.3f %10d %7d %7d %7d %7d
%7.3f %7.3f %-10s %14.3f %14.3f %-30s %-10s
Specifically, what I want to do is:
From file_1:
create a hash whose keys are any of the headers specified on the
command line. Each key value is a reference to an array containing
the data from each column.
From file_2:
create another hash whose keys are any of the headers specified
on the command line. Each key value is a reference to an array
containing the data from each column.
NOTE: There will ALWAYS be matching data between both files, but NOT necessarily under the same header label!
For example:
the column "SrcRtr" from file_1 contains the exact same data as the
column "DstDev" in file_2
After assembling these data structures, I want to merge them,
in structured format, and print the
resulting merged file to <STDOUT>.
I'm not sure if this is any clearer, but please let me know if it's not.
| [reply] [d/l] [select] |