Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: easiest way to read multiple word command arguments

by choroba (Cardinal)
on Aug 15, 2013 at 16:06 UTC ( [id://1049621]=note: print w/replies, xml ) Need Help??


in reply to easiest way to read multiple word command arguments

Process the options one by one. If the option does not start with a dash, add it to the previous one:
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my %options; my $current_option; my $space; for (@ARGV) { if (/^-/) { $current_option = $_; $space = q(); # No space before the + first word. } else { $options{$current_option} .= $space . $_; $space = ' '; } } print Dumper \%options;
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-23 20:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found