Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion static variable problem
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dave Saville  
View profile  
 More options Nov 13 2012, 8:38 am
Newsgroups: comp.lang.perl.misc
From: "Dave Saville" <d...@invalid.invalid>
Date: Tue, 13 Nov 2012 13:38:07 +0000 (UTC)
Local: Tues, Nov 13 2012 8:38 am
Subject: static variable problem
Please why does this throw an error?

[T:\tmp]cat try.pl
use strict;
use warnings;

foo("Hello World");
exit;
{
  my $bar = 1;

  sub foo
  {
    my $a = shift;
    print "$bar $a\n";   # <== line 12
    return;
  }

}

[T:\tmp]try.pl
Use of uninitialized value in concatenation (.) or string at try.pl
line 12.
 Hello World

So $bar is private to foo - but you can't initialise it?

TIA
--
Regards
Dave Saville


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.