in reply to Re: Parsing @ARGV w/ Map Function
in thread Parsing @ARGV w/ Map Function
Wow!
While all these answers are helpful, this is the one that opened several doors for me that I wasn't even thinking about. From what I read I didn't think whole statements would fit inside map, much less just calling a subroutine.
I played around and got things working quickly from your examples. (Before that, I was going over conditional regex abilities, and not getting too far.) Once I saw that, it was easy and an if...elsif...else block did fine for testing (but it ignored malformed arguments, this is just an experiment so far). Then I looked back and found what I came up with was pretty close to what you had come up with.
But there is one big question I have when looking at your 2nd example. I wasn't sure if map was a loop or if it handled data in other ways. So what is the difference in whether I use map or a foreach loop with almost the same statements in it? Is there a speed difference or anything else?
I will be looking at Getopt::Long. It's amazing the things you can miss that everyone else considers standard when you're self-taught. It's the kind of thing where I might see someone using it and say to them, "You never told me you could do that," and the response is, "You never asked." Sometimes there's so much it's hard to know what to ask about what is out there.
Thank you, everyone, for the helpful posts. While this is quick and simple, so it might get used on some small programs, I can see Getopt::Long has much more to use for parsing arguments. My main intent was that I knew there had to be a way to do this and I wanted to see what it was and what it included that I didn't know about.
|
|---|