in reply to Re: @ARGV Manipulation
in thread @ARGV Manipulation

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.

Replies are listed 'Best First'.
RE: RE: Re: @ARGV Manipulation
by merlyn (Sage) on Sep 16, 2000 at 05:33 UTC
    I'm lost about where you're lost. Here's the things that I think you'll need to know to do this task, but I'm not sure which of these you know and which you don't.
    • how to look at @ARGV
    • how to walk through an array with a foreach loop
    • how to assign things to a hash
    • what a hash can contain
    • the difference between \ and / as it applies to Perl
    • how to recognize the difference between file_1 and a,b,c on the command line
    • how to turn a,b,c into a 3-element list
    • how to populate an arrayref
    • how to read a file into an arrayref
    • how to recognize the things from the file to figure out where they'll go
    • other things that I didn't think of when I was coming up with this list
    I enjoy helping people. But I keep wondering "help you with WHAT?" on each post. Ask a more specific question, perhaps any of the above. If it's all of the above, then I suggest you need a good book or two, or spend some time with Perl tutorials.

    -- Randal L. Schwartz, Perl hacker

      AHA! Thank you! I DON'T know:
      how to recognize the difference between file_1 and a b c, other than p +ositionally. Which is of no help, because a b c can change, depending on which fields I want to read!
      That's precisely it! I caan figure the rest out! I have 4 books, which have been helpful, thus far. Thank you, thank you, thankyou, for helping to extract some clarity from me! Steven L. Sesar, Perl Infant
        Well, I've got to kick that question back to you. How would you know, as a human being, which arguments on the command line are filenames, and which ones are columns within filenames?

        You can't teach a computer to do what you yourself cannot compute, or decide how to compute. So first, teach me, and I can help you figure out the code.

        For example, what rule can you use to distinguish a, the filename, from a, the column name?

        I think that the way you've stated your problem, it's intractable, which is why I keep kicking it back. You'll need to annotate the column names distinctly from the filenames somehow.

        -- Randal L. Schwartz, Perl hacker