Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: A nice little question for the insane

by jdporter (Canon)
on Apr 06, 2005 at 03:51 UTC ( #445163=note: print w/ replies, xml ) Need Help??


in reply to Re: A nice little question for the insane
in thread A nice little question for the insane

That's probably the best answer, IMHO. Here's a more hackish approach:

chomp( @a = qx( for x in $_; do echo \$x; done ) );
There's already a tool that knows how to parse command lines! :-)

Update: fixed bugs in code, which was untested. Thanks, tlm!


Comment on Re^2: A nice little question for the insane
Re^3: A nice little question for the insane
by crenz (Priest) on Apr 06, 2005 at 09:57 UTC
      I don't agree. It looks like what the OP is doing is sort of similar as what you expect from the shell - taking the argument string, and chopping it up into pieces. That isn't what any of the getopt tools are doing - they are taking the pieces and processing that.

      In parsing/compiling terms, getopt and Getopt::* are parsers. The OP is lexing: turning a string into tokens. And that's what the shell is doing as well (which makes the qx trick work - although the shell will parse things different than the OP does).

        Yes, you're right. However, I don't know the scope of the original poster's problem, so I thought I'll just supply the link so that the OP can think about whether the modules might already do what (s)he needs to do -- or not.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://445163]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2014-12-20 11:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls