Hello there monks I'm trying to convert a script that used to use vars/Getopts::Std (I still don't know why this works on 1 PC and not another, especially when I did exactly the same install of Perl 5.8.7 Build 813 on both PC's!!!) to use command line parameters. I don't seem, using my usual method, to be able to pick up any parameters. Is there a different method employed in Win32 Perl from that used on a Unix server? An example of the code follows :-
#
# Process the parameters
#------------------------#
$P_count = scalar @ARGV ;
if ($P_count == 1) {
$file_in = $ARGV[0] ;
}
elsif ($P_count == 2) {
($IP_in, $MAC_in) = @ARGV ;
}
elsif ($P_count == 3) {
($IP_in, $MAC_in, $Port_in) = @ARGV ;
}
else
{
print "\n\tIncorrect number of parameters supplied - ($P_count)" ;
print "\n\tThere MUST be between 1 & 3 parameters!\n" ;
exit 123 ;
}
On the command line I type the script name and the parameters and my counter always says that there are 0 supplied! eg script.pl(fred), script.pl fred & script "fred" all produce 0 parameters? Is there a difference or have I got a typo or just plain misunderstood something?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.