473,322 Members | 1,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Perl: I do not pass parameters to usage() and @_ is defined yet ???

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2. use Getopt::Long;
  3.  
  4.  
  5.  
  6.  
  7. $l=@ARGV;
  8.  
  9. print "The number of args is " . @ARGV;print "\n"; 
  10.  
  11. my  $bool= GetOptions('help|?' => \$help, 'url=s' => \$url, 'size=i' => \$size);
  12.  
  13.  
  14. ;
  15. if ( !$bool    or $l < 1 || defined $help ){
  16. &usage();
  17.  
  18. print "=======\n";
  19. print "THE END";
  20.   if (@_ ){
  21.   print "Unknown option: @_\n"}
  22.   print "usage: program [--url URL] [--size SIZE] [--help|-?]\n";
  23.  
  24. }  
  25.  
OUTPUT:
=======
C:\>perld.pl --url www --size 15 -david -fass
The number of args is 6
Unknown option: david
Unknown option: fass


usage: program [--url URL] [--size SIZE] [--help|-?]
=======

please explain why the "additional arguments of perld.pl" are passed through sub usage() to @_????
but I call to sub usage() without parameters????????!!!!!!!!!
Oct 16 '07 #1
1 1508
KevinADC
4,059 Expert 2GB
@_ is global. It will display whatever it's last values were. Since you did not pass any arguments to usage(), @_ is still the values of the paramaters you passed to the script.
Oct 16 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
4
by: banz | last post by:
Hello I have a problem to resolve: I wrote a Perlscript which caches data from a server (local on my machine) I would like to have a other connection to a remote server but I don't know how to...
5
by: Robert Oschler | last post by:
I am converting a Perl script over to "C" for a potential open source project. I need some open source "C" code that will give me the same functionality of a Perl Style associative array: ...
0
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
4
by: pmcgover | last post by:
I enjoyed Paul Barry's September article in Linux Journal entitled, "Web Reporting with MySQL, CSS and Perl". It provides a simple, elegant way to use HTML to display database content without any...
8
by: gooop | last post by:
I am new to perl. I am having trouble with this code line I wrote. On the third line I keep getting this message when I go to run this. This is just the first part of the code. Please any advice...
1
by: gooop | last post by:
I am new to perl. I am having trouble with this code line I wrote. On thef fourth line I keep getting this message when I go to run this. . Please any advice would help.I am using TextPad, and window...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.