Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: easiest way to read multiple word command arguments

by choroba (Cardinal)
on Aug 15, 2013 at 16:06 UTC ( #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? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2022-12-05 13:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?