[27678] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9124 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 5 14:05:34 2006

Date: Wed, 5 Apr 2006 11:05:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 5 Apr 2006     Volume: 10 Number: 9124

Today's topics:
        fork and taint <no@thanks.com>
        my variables don't work inside of a loop <mdudley@king-cart.com>
    Re: my variables don't work inside of a loop <rvtol+news@isolution.nl>
    Re: my variables don't work inside of a loop <news@chaos-net.de>
    Re: my variables don't work inside of a loop lawrence@hummer.not-here.net
    Re: Perl-related events in 2006 ?  <rvtol+news@isolution.nl>
    Re: Perl-related events in 2006 ? <brian.d.foy@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 5 Apr 2006 18:20:29 +0200
From: Asterbing <no@thanks.com>
Subject: fork and taint
Message-Id: <MPG.1e9e0cbb6aa397189897d4@news.tiscali.fr>

Hello. This script below crashes perl.exe when in taint mode. I've not 
any message in error log.

#!/usr/bin/perl -T
print "Content-type: text/html\n\n";
my $pid = fork();
die "fork: $!\n" unless defined $pid;
if (!$pid){
	print "son ok<br>";
	exit 0;}
print "daddy ok<br>";
exit 0;

It seems like the problem happen on line "my $pid = fork();" because if 
I stop the script just below using an "exit 0;", it crashes the same 
way.


------------------------------

Date: Wed, 05 Apr 2006 11:18:07 -0400
From: Marshall Dudley <mdudley@king-cart.com>
Subject: my variables don't work inside of a loop
Message-Id: <4433DFAF.4B15B170@king-cart.com>

I have a very strange problem. I am running perl version 5.005_03 built
for i386-freebsd.  The problem is that "my" variables which should be
local to the block, are not being seen inside of a loop within that
block.  I have had to change them to global variables to get them seen.

The following code demonstrates it:

---------------------------------------------
my $category = "<test>";
my $name = "product's";
$options = "blue & green";    #This one is global
                my @variables = ("category","name","options");
                    foreach my $var(@variables) {
                        $$var =~ s/\</&lt;/g;
                        $$var =~ s/\>/&gt;/g;
                        $$var =~ s/\&/&amp;/g;
                        $$var =~ s/\'/&apos;/g;
                        $$var =~ s/\"/&quot;/g;
print "$var = $$var\n";
                    }
print "$category - $name - $options\n";

----------------- and when executed gives me this:

execonn# perl test.pl
category =
name =
options = blue &amp; green
<test> - product's - blue &amp; green
#execonn

As can be seen, the "my" variables completely disappear when they are
accessed inside the loop both to the regular expression and the print
statement, yet reappear when outside of the loop, and the global
variable of options is available both in the loop and outside of it.

Any ideas?  Everything I find says that "my" variables should be
available everywhere within the block that they are declared in.

Marshall



------------------------------

Date: Wed, 5 Apr 2006 17:48:10 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: my variables don't work inside of a loop
Message-Id: <e10vth.1es.1@news.isolution.nl>

Marshall Dudley schreef:


Missing:

  use warnings;
  use strict;

> ---------------------------------------------
> my $category = "<test>";
> my $name = "product's";
> $options = "blue & green";    #This one is global
>                 my @variables = ("category","name","options");
>                     foreach my $var(@variables) {
>                         $$var =~ s/\</&lt;/g;
>                         $$var =~ s/\>/&gt;/g;
>                         $$var =~ s/\&/&amp;/g;
>                         $$var =~ s/\'/&apos;/g;
>                         $$var =~ s/\"/&quot;/g;
> print "$var = $$var\n";
>                     }
> print "$category - $name - $options\n";


I don't quite understand what you try to achieve there.
BTW, you are replacing '&' by &amp;, after you inserted some '&'s
yourself!


Maybe this helps:

#!/usr/bin/perl
use warnings;
use strict;

{ local (${"}, ${\}) = ("\t|\t", "\n" );

  my @ary = qw(<test> product's blue_&_green);

  for my $elm ( @ary ) {
      s/&/&amp;/g
    , s/</&lt;/g
    , s/>/&gt;/g
    , s/'/&apos;/g
    , s/"/&quot;/g for $elm;

    print "\$elm = $elm";
  }

  print "\n@ary";
}

-- 
Affijn, Ruud

"Gewoon is een tijger."



------------------------------

Date: Wed, 5 Apr 2006 18:02:45 +0200
From: Martin =?iso-8859-1?Q?Ki=DFner?= <news@chaos-net.de>
Subject: Re: my variables don't work inside of a loop
Message-Id: <slrne37qh5.m0p.news@maki.homeunix.net>

Marshall Dudley wrote :
> I have a very strange problem. I am running perl version 5.005_03 built
> for i386-freebsd.  The problem is that "my" variables which should be
> local to the block, are not being seen inside of a loop within that
> block.  I have had to change them to global variables to get them seen.
>
> The following code demonstrates it:
>
> ---------------------------------------------
use strict;
use warnings;
> my $category = "<test>";
> my $name = "product's";
> $options = "blue & green";    #This one is global
>                 my @variables = ("category","name","options");
>                     foreach my $var(@variables) {
>                         $$var =~ s/\</&lt;/g;
>                         $$var =~ s/\>/&gt;/g;
>                         $$var =~ s/\&/&amp;/g;
>                         $$var =~ s/\'/&apos;/g;
>                         $$var =~ s/\"/&quot;/g;
> print "$var = $$var\n";
>                     }
> print "$category - $name - $options\n";
>
> ----------------- and when executed gives me this:
>
> execonn# perl test.pl
> category =
> name =
> options = blue &amp; green
><test> - product's - blue &amp; green
> #execonn
>
> As can be seen, the "my" variables completely disappear when they are
> accessed inside the loop both to the regular expression and the print
> statement, yet reappear when outside of the loop, and the global
> variable of options is available both in the loop and outside of it.
>
> Any ideas?  Everything I find says that "my" variables should be
> available everywhere within the block that they are declared in.

You set $var to strings, not to the content of the variables you
defined.

Maybe this helps:
----
#!/usr/bin/perl

use warnings;
use strict;

my $category = "<test>";
my $name = "product's";
my $options = "blue & green";

my @variables = ($category, $name, $options);
foreach my $var(@variables) {
    my $oldvar = $var; 
    $var =~ s/\</&lt;/g;
    $var =~ s/\>/&gt;/g;
    $var =~ s/\&/&amp;/g;
    $var =~ s/\'/&apos;/g;
    $var =~ s/\"/&quot;/g;
    print "$oldvar - $var\n"
}
----

HTH

Best regards
Martin 

-- 
perl -e '$S=[[73,116,114,115,31,96],[108,109,114,102,99,112],
[29,77,98,111,105,29],[100,93,95,103,97,110]];
for(0..3){for$s(0..5){print(chr($S->[$_]->[$s]+$_+1))}}'


------------------------------

Date: 05 Apr 2006 09:04:35 -0700
From: lawrence@hummer.not-here.net
Subject: Re: my variables don't work inside of a loop
Message-Id: <87mzf0f1po.fsf@hummer.i-did-not-set--mail-host-address--so-shoot-me>

Marshall Dudley <mdudley@king-cart.com> writes:

[snip out horribly formatted code using soft references]

> 
> Any ideas?  Everything I find says that "my" variables should be
> available everywhere within the block that they are declared in.

But nowhere in your code did you reference your my variables, you used
soft references (and because you exercised good netiquette and have
read this group for thirty days before you posted the first time, you
knew that the general concensus is that soft references are rarely the
right answer) to global variables you never declared.  

perldoc perlref

       Only package variables (globals, even if localized) are visible to sym-
       bolic references.  Lexical variables (declared with my()) aren't in a
       symbol table, and thus are invisible to this mechanism.  For example:

           local $value = 10;
           $ref = "value";
           {
               my $value = 20;
               print $$ref;
           }

       This will still print 10, not 20.  Remember that local() affects pack-
       age variables, which are all "global" to the package.



-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
	Lawrence Statton - lawrenabae@abaluon.abaom s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
sort them into the correct order.


------------------------------

Date: Wed, 5 Apr 2006 17:04:39 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Perl-related events in 2006 ? 
Message-Id: <e10tl4.1e8.1@news.isolution.nl>

lars@nospam.nosoftwarepatents.edu schreef:
> What perl-related events are coming up this year ?
> When and where ?

Some in Europe:
http://www.yapceurope.org/ 

-- 
Affijn, Ruud

"Gewoon is een tijger."


------------------------------

Date: Wed, 05 Apr 2006 07:55:52 -0500
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: Perl-related events in 2006 ?
Message-Id: <050420060755522515%brian.d.foy@gmail.com>

In article <orJYf.913$hi2.742@news.itd.umich.edu>,
<lars@nospam.nosoftwarepatents.edu> wrote:

> What perl-related events are coming up this year ?
> When and where ?

Here's some of the stuff from the calendar of the latest issue of The
Perl Review, along with some stuff that came out after we went to
press. Besides these big events, there might be local Perl Mongers
things happening near you too.

June 15-16, 2006
Nordic Perl Workshop
Oslo Norway
http://www.perlworkshop.no/2006/

June 26-28, 2006
YAPC::NA
Chicago, Illinois
http://yapc.org/America/

July 24-28, 2006
O'Reilly Open Source Convention
Portland, Oregon
http://conferences.oreillynet.com/oscon

30 Aug - 1 Sep 2006
YAPC::Europe::2006
Birmingham, UK
http://yapceurope.org/

September  18-21, 2006
O'Reilly European Open Source Convention 2006
Brussels, Belgium
http://conferences.oreillynet.com/eurooscon
*** Free account sponsored by SecureIX.com ***
*** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com ***


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 9124
***************************************


home help back first fref pref prev next nref lref last post