Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > problem with "our"

Reply
Thread Tools

problem with "our"

 
 
JaSeong Ju
Guest
Posts: n/a
 
      02-05-2004
Hi..

I'm new to perl.

How come this piece of code does not work in SunOs5.8, with perl v.
5.005_03 ?
--------------------
#!/usr/bin/perl

our $choice = 67.90;
print STDERR " value is: ", $choice, "\n";
exit(0);
-------------
The error is as follows:

Can't modify subroutine entry in scalar assignment at test6.pl line 3,
near "67.90;"
Execution of test6.pl aborted due to compilation errors.





The above script works well in Linux 2.4.20-8 kernel with perl v. 5.8.0.
Also, if "our" is replaced with "my", then script works in both operating
systems.

Is perl version 5.005_03 too old?

Many thanks.

JaSeong Ju

 
Reply With Quote
 
 
 
 
Aaron Sherman
Guest
Posts: n/a
 
      02-05-2004
JaSeong Ju <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...

> I'm new to perl.


And your perl is old to me

> How come this piece of code does not work in SunOs5.8, with perl v.
> 5.005_03 ?


The our keyword was introduced in 5.6.0, and is not available in your
version of Perl.

Thus, you have essentially written:

foo $bar = xxx

which Perl sees as:

$bar->foo() = xxx

which is why you're getting an error about modifying a subroutine.

Bottom line: use a newer Perl. 5.005_03 (released in 1999) is outdated
by 2 major and many more minor revisions. We're up to 5.8.3. I believe
at this point.

Staying within 2 years of current is probably wise with any language,
as storebought documentation and web or print articles about the
language will tend to be woefully out-of-date otherwise (try using STL
implementations from 1999 with modern C++ documentation, for example


That said, your Perl installation should have plenty of documentation
on how to establish global (package-scoped, of course) variables
without causing "strict" problems. See the documentation for the
"strict" and "vars" modules using the "perldoc" program for more
information.
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem problem problem :( Need Help Mike ASP General 2 05-11-2004 08:36 AM



Advertisments