LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 02-27-2005, 10:48 AM   #1
zaken
LQ Newbie
 
Registered: Jul 2004
Location: kent
Distribution: Fedora
Posts: 5

Rep: Reputation: 0
perl arguments


OK I'm a newbie at perl. whats wrong with the perl below??? I keep getting errors

Global symbol "$hostfile" requires explicit package name at ./multi-rtr-cmd.pl line 14.
Global symbol "$outputfile" requires explicit package name at ./multi-rtr-cmd.pl line 16.
Global symbol "$command1" requires explicit package name at ./multi-rtr-cmd.pl line 18.
Global symbol "$command2" requires explicit package name at ./multi-rtr-cmd.pl line 20.
Global symbol "$outputfile" requires explicit package name at ./multi-rtr-cmd.pl line 31.



These are being generated by the piece of script below.
I've tried all sorts of different quotes and reading various bits.
Please help me on my learning path.

# Read in the arguments into script variables

if(!"@ARGV"){&Usage};

if($ARGV[0] eq "-i") {$hostfile = "$ARGV[1]"};

if($ARGV[2] eq "-o") {$outputfile = "$ARGV[3]"};

if($ARGV[4] eq "-c1") {$command1 = "$ARGV[5]"};

if($ARGV[6] eq "-c2") {$command2 = "$ARGV[7]"};

TIA,
Neil.
 
Old 02-27-2005, 12:19 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 65
It looks like you have "use strict;" You will need to declare the variables with:
my $varname;
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with passing arguments in Perl bahadur Programming 1 05-30-2005 02:47 AM
command arguments in perl djgerbavore Programming 1 12-30-2004 09:06 AM
Kernel arguments? ace_bandit_1 Linux - Hardware 2 06-29-2004 03:06 AM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 09:09 PM
Perl: Getting a script to accept arguments JStew Programming 10 03-10-2003 07:56 AM


All times are GMT -5. The time now is 11:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration