in reply to @ARGV Manipulation

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

Replies are listed 'Best First'.
RE: Re: @ARGV Manipulation
by Limo (Scribe) on Sep 16, 2000 at 05:28 UTC
    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.
      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