Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 02-27-2005, 09:48 AM   #1
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 ./ line 14.
Global symbol "$outputfile" requires explicit package name at ./ line 16.
Global symbol "$command1" requires explicit package name at ./ line 18.
Global symbol "$command2" requires explicit package name at ./ line 20.
Global symbol "$outputfile" requires explicit package name at ./ 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[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]"};

Old 02-27-2005, 11:19 AM   #2
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

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


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 01:47 AM
command arguments in perl djgerbavore Programming 1 12-30-2004 08:06 AM
Kernel arguments? ace_bandit_1 Linux - Hardware 2 06-29-2004 02:06 AM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM
Perl: Getting a script to accept arguments JStew Programming 10 03-10-2003 06:56 AM > Forums > Non-*NIX Forums > Programming

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

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