develooper Front page | perl.perl5.porters | Postings from April 2008

Re: [perl #53504] Bug in if(open(my $fh,...)) { } scoping

Thread Previous | Thread Next
From:
Rafael Garcia-Suarez
Date:
April 30, 2008 00:01
Subject:
Re: [perl #53504] Bug in if(open(my $fh,...)) { } scoping
Message ID:
b77c1dce0804300001r2f6259bau4eea3d28b41ccdef@mail.gmail.com
2008/4/29 H.Merijn Brand <h.m.brand@xs4all.nl>:
>  related nuisance:
>
>  /home/merijn 102 > cat xx.pl
>  #!/pro/bin/perl
>
>  use strict;
>  use warnings;
>
>  if    (my @scr = glob ("*.sh")) {
>     print "I have shell scripts here\n";
>     }
>  elsif (my @scr = glob ("*.pl")) {
>     print "I have perl scripts here\n";
>     }
>  /home/merijn 103 > perl xx.pl
>  "my" variable @scr masks earlier declaration in same scope at xx.pl line 9.
>  I have perl scripts here
>  /home/merijn 104 >

That's exactly the opposite problem you're having there. Just remove
the 2nd my...

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About