Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: switch being ignored put into ARGV

by Corion (Patriarch)
on Oct 16, 2022 at 12:31 UTC ( [id://11147466]=note: print w/replies, xml ) Need Help??


in reply to [RESOLVED] switch being ignored put into ARGV

The order in which you assign stuff is wrong. Getopt::Std removes items from @ARGV. Try

#!perl use 5.020; use Getopt::Std; @ARGV = ("-u", "my miscreants", "Some reason"); my %opts; getopts ('u', \%opts); my ($miscreants, $reason) = @ARGV; say "---"; say "Miscreants: $miscreants"; say "Reason: $reason"; say "-u set: " . $opts{'u'}; %opts = (); @ARGV = ("-u", "my miscreants", "Some reason"); ($miscreants, $reason) = @ARGV; getopts ('u', \%opts); say "---"; say "Miscreants: $miscreants"; say "Reason: $reason"; say "-u set: " . $opts{'u'};

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2024-04-26 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found