Re: Problem with compiling a script

2004-07-21 Thread James Edward Gray II
On Jul 21, 2004, at 8:47 AM, Paul Smith wrote:
Bingo, James! Sorry for my ignorance, but I am just beginning with 
Perl.
Not a problem.  Brand new to Perl and already using strict, you're off 
to the perfect start.  Welcome.

James
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Problem with compiling a script

2004-07-21 Thread Prasanna Kothari
Hi,
Qualify the variable's in your perl script, since the script uses 
strict(use strict). For Eg: declare $greeting as "my $greeting"
or comment "use strict" and that should work.

Paul Smith wrote:
Dear All
I am trying to run the script below, but I always get the following 
error:

[EMAIL PROTECTED] scripts]$ secondperl
Global symbol "$greeting" requires explicit package name at 
/home/paulus/scripts/secondperl line 6.
Global symbol "$greeting" requires explicit package name at 
/home/paulus/scripts/secondperl line 7.
Execution of /home/paulus/scripts/secondperl aborted due to 
compilation errors.

The script is:
#!/usr/bin/perl
use warnings;
use strict;
$greeting = "World";
print "It matches\n" if "Hello World" =~ /$greeting/;
Any ideas?
Thanks in advance,
Paul


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Problem with compiling a script

2004-07-21 Thread Paul Smith
Bingo, James! Sorry for my ignorance, but I am just beginning with Perl.
Paul
James Edward Gray II wrote:
On Jul 21, 2004, at 8:35 AM, Paul Smith wrote:
I am trying to run the script below, but I always get the following 
error:

[EMAIL PROTECTED] scripts]$ secondperl
Global symbol "$greeting" requires explicit package name at 
/home/paulus/scripts/secondperl line 6.
Global symbol "$greeting" requires explicit package name at 
/home/paulus/scripts/secondperl line 7.
Execution of /home/paulus/scripts/secondperl aborted due to 
compilation errors.

Easy enough.
The script is:
#!/usr/bin/perl
use warnings;
use strict;

Above, you are asking Perl to make you play by the Good Programmer 
rules.  One of those rules is, you  must declare a variable before using 
it.

$greeting = "World";

Here you use an undeclared variable.  Usually, you'll declare a variable 
with "my", so change to above line to:

my $greeting = 'World';
Hope that helps.
James
print "It matches\n" if "Hello World" =~ /$greeting/;



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Problem with compiling a script

2004-07-21 Thread James Edward Gray II
On Jul 21, 2004, at 8:35 AM, Paul Smith wrote:
Dear All
I am trying to run the script below, but I always get the following 
error:

[EMAIL PROTECTED] scripts]$ secondperl
Global symbol "$greeting" requires explicit package name at 
/home/paulus/scripts/secondperl line 6.
Global symbol "$greeting" requires explicit package name at 
/home/paulus/scripts/secondperl line 7.
Execution of /home/paulus/scripts/secondperl aborted due to 
compilation errors.
Easy enough.
The script is:
#!/usr/bin/perl
use warnings;
use strict;
Above, you are asking Perl to make you play by the Good Programmer 
rules.  One of those rules is, you  must declare a variable before 
using it.

$greeting = "World";
Here you use an undeclared variable.  Usually, you'll declare a 
variable with "my", so change to above line to:

my $greeting = 'World';
Hope that helps.
James
print "It matches\n" if "Hello World" =~ /$greeting/;

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Problem with compiling a script

2004-07-21 Thread Paul Smith
Dear All
I am trying to run the script below, but I always get the following error:
[EMAIL PROTECTED] scripts]$ secondperl
Global symbol "$greeting" requires explicit package name at 
/home/paulus/scripts/secondperl line 6.
Global symbol "$greeting" requires explicit package name at 
/home/paulus/scripts/secondperl line 7.
Execution of /home/paulus/scripts/secondperl aborted due to compilation 
errors.

The script is:
#!/usr/bin/perl
use warnings;
use strict;
$greeting = "World";
print "It matches\n" if "Hello World" =~ /$greeting/;
Any ideas?
Thanks in advance,
Paul
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]