Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Use of uninitialized value in print

by kyle (Abbot)
on Mar 26, 2009 at 20:20 UTC ( [id://753503]=note: print w/replies, xml ) Need Help??


in reply to Use of uninitialized value in print

Here's one that works:

#!/usr/bin/perl use strict; use warnings; use strict 'vars'; use Getopt::Std; #Setting options # u:username # h:hostname # p:password # k:SSH Key getopts("u:h:p:k:"); our ($opt_u, $opt_h); #### TEST SECTION ### print "opts::$opt_u\n";

In your version, you refer to $opts::opt_u, which is a package variable in the "opts" package. strict won't complain about that because you've given the full name of the package variable, but that doesn't change the fact that there's nothing in it. Your call to getopt will set $main::opt_u instead (because that's what package it's called in).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-25 14:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found