CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [griever92] Using Arguments with Subroutines: Edit Log



FishMonger
Veteran / Moderator

Oct 31, 2012, 8:08 AM


Views: 2169
Re: [griever92] Using Arguments with Subroutines

Show us your code that parses the switches. That's where your problem is located.

Actually, you should show us your entire script.

Normally I'd have more error handling, but here's a minimal script showing one way how to use the module to process the switches.


Code
#!/usr/bin/perl 

use 5.10.0;
use strict;
use warnings;
use Getopt::Long;

GetOptions(
'l=s' => \&my_sub( @ARGV ),
);


sub my_sub {
shift;
die "Need Target Parameter\n" unless @_;
print shift;;
}


Outputs:

Quote
c:\testing>main.pl -l this.is.my.target
this.is.my.target



(This post was edited by FishMonger on Oct 31, 2012, 8:08 AM)


Edit Log:
Post edited by FishMonger (Veteran) on Oct 31, 2012, 8:08 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives