Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 30th, 2008, 11:58 AM   #1
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 333
Rep Power: 3 kruptof is on a distinguished road
use strict and typeglobs

I am trying to experiment with using typglobs using the following code:
#!/indigoperl/bin/perl
#use warnings;
#use strict;
our ($spud,@spud);
$spud = "I am a scalar";
@spud = qw(I am an array);
sub spud
{
	print "I am a sub routine;";
}
*potato = *spud;

print $potato;
The code above works fine as expected, but when I enable the strict pragma, it doesn't compile and dies with the error:
Quote:
Variable "$potato" is not imported at refs.pl line 13.
Global symbol "$potato" requires explicit package name at refs.pl line 13.
Execution of refs.pl aborted due to compilation errors.
This is probably because i havent declared the lexical variable $potato, so my question is can typeglobs be used with the strict pragma enabled and if so how?
__________________
Quote:
When I was young it seemed that life was so wonderful,a miracle, oh it was beautiful, magical.
Now watch what you say or they'll be calling you a radical,a liberal, oh fanatical, criminal. Oh won't you sign up your name,we'd like to feel you're acceptable, respectable, oh presentable, a vegetable
kruptof is offline   Reply With Quote
Old Jul 10th, 2008, 3:41 AM   #2
KevinADC
Newbie
 
Join Date: Jul 2008
Posts: 7
Rep Power: 0 KevinADC is on a distinguished road
Re: use strict and typeglobs

Sure they can but you still have to declare your variables.

#!/indigoperl/bin/perl
use warnings;
use strict;
our ($spud,@spud,$potato);
$spud = "I am a scalar";
@spud = qw(I am an array);
sub spud
{
	print "I am a sub routine;";
}
*potato = *spud;

print $potato;
KevinADC is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:44 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC