GeoffOs has asked for the wisdom of the Perl Monks concerning the following question:

My first dip into perl, and I am attempting to amend someone else code to suit my purpose, but I keep getting errors. Here is this code:
my ($cmd, $cmdkill); $cmd = qq{$path -qx $host $port $suser $password}; $cmdkill = qq{$path -qx $host $port} }; open(PROC,"$cmd|") or die "failed to fork :$!\n";
But I get this error
Global symbol "$cmd" requires explicit package name at ./check_req.pl +line 213. Global symbol "$cmdkill" requires explicit package name at ./check_req +.pl line 214.
Anyone know what I am doing wrong?

Replies are listed 'Best First'.
Re: requires explicit package name
by talexb (Chancellor) on Oct 22, 2003 at 16:11 UTC

    It also looks like your line

    $cmdkill = qq{$path -qx $host $port} };
    has two closing braces .. without the entire script it's impossible to determine if this is correct or not. I'm guessing not.

    --t. alex
    Life is short: get busy!
      Banging my head against a wall, I never saw that, thanks all of you. Geoff
Re: requires explicit package name
by dragonchild (Archbishop) on Oct 22, 2003 at 16:06 UTC
    To elaborate on Abigail-II's correct answer, the problem is in the line(s) above the snippet you're showing us. Most likely, there's a colon instead of a semi-colon somewhere. Or, someone chose to leave off the semi-colon on the last line in a block (which is legal, but usually dumb, for this very reason) and you removed the block, but left the code.

    To generalize, if you can't find the error where the compiler complains, try looking a few lines above and seeing if it's there.

    ------
    We are the carpenters and bricklayers of the Information Age.

    The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

    ... strings and arrays will suffice. As they are easily available as native data types in any sane language, ... - blokhead, speaking on evolutionary algorithms

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Re: requires explicit package name
by Abigail-II (Bishop) on Oct 22, 2003 at 16:04 UTC
    Try putting a semi-colon in front of the 'my'.

    Abigail

Re: requires explicit package name
by tbone1 (Monsignor) on Oct 22, 2003 at 19:22 UTC
    I am attempting to amend someone else code to suit my purpose

    You know, one of these days I'm going to write that blues song called "Other People's Software"

    That being said, I ran into something similar a while back, and it was a missing ';', as Abigail-II said. If that isn't it, let us know.

    --
    tbone1
    Ain't enough 'O's in 'stoopid' to describe that guy.
    - Dave "the King" Wilson

Re: requires explicit package name
by Anonymous Monk on Oct 23, 2003 at 02:33 UTC
    How about removing the extraneous } character at the end of line 214. Line 214 is:
    $cmdkill = qq{  ... blah ... } };