[32553] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3819 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 16 21:09:21 2012

Date: Fri, 16 Nov 2012 18:09:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 16 Nov 2012     Volume: 11 Number: 3819

Today's topics:
        Module for common perl/shell/python constants <h.b.furuseth@usit.uio.no>
        Perl goto (was: static variable problem) <rweikusat@mssgmbh.com>
    Re: Perl goto (was: static variable problem) <derykus@gmail.com>
    Re: static variable problem <derykus@gmail.com>
    Re: static variable problem dave@deezee.org
    Re: static variable problem <kst-u@mib.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 16 Nov 2012 12:05:48 +0100
From: Hallvard Breien Furuseth <h.b.furuseth@usit.uio.no>
Subject: Module for common perl/shell/python constants
Message-Id: <hbf.20121116cb3g@bombur.uio.no>

Is there module which lets me write a single config file with
integer/string constants which will be used by both Perl, Bash and
Python?  Preferably Perl would turn them into compile-time constants.

E.g. I'd write "use Shellvars qw(foo.sh); where foo.sh
would contain
    FOO = 3
    BAR = "baz"
Hopefully
    BAD = "oops
would fail rather than produce some arbitrary strange result.

-- 
Hallvard


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

Date: Wed, 14 Nov 2012 13:23:46 +0000
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Perl goto (was: static variable problem)
Message-Id: <87obj0pbbx.fsf_-_@sapphire.mobileactivedefense.com>

"C.DeRykus" <derykus@gmail.com> writes:

[...]

>   goto BLOCK;
>
>   FOO: foo("Hello World");
>   exit;
>
>   BLOCK: {
>     my $bar = 1;
>
>     sub foo
>     {
>       my $a = shift;
>       print "$bar $a\n";   
>       return;
>     }
>     goto FOO;
> };

In contrast to 'other languages', the destination of a Perl goto is
determined at runtime, by 'outward' searching (IIRC, term used by the
Camel book) for a matching label in all currently active lexical
scopes. This implies that, compared to other means for performing flow
control, it is a very expensive operation.

--------------
use Benchmark;

timethese(-5,
	  {
	   goto => sub {
	       goto out;

	       print "ha!";

	       out:
	       return 3;
	   },

	   return => sub {
	       return 3;
	   }});


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

Date: Wed, 14 Nov 2012 15:29:20 -0800 (PST)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: Perl goto (was: static variable problem)
Message-Id: <f85691b4-ead5-4978-b23f-8ecc146127a5@googlegroups.com>

On Wednesday, November 14, 2012 5:23:49 AM UTC-8, Rainer Weikusat wrote:
> "C.DeRykus" <derykus@gmail.com> writes:
> 
> 
> 
> [...]
> 
> 
> 
> >   goto BLOCK;
> 
> >
> 
> >   FOO: foo("Hello World");
> 
> >   exit;
> 
> >
> 
> >   BLOCK: {
> 
> >     my $bar = 1;
> 
> >
> 
> >     sub foo
> 
> >     {
> 
> >       my $a = shift;
> 
> >       print "$bar $a\n";   
> 
> >       return;
> 
> >     }
> 
> >     goto FOO;
> 
> > };
> 
> 
> 
> In contrast to 'other languages', the destination of a Perl goto is
> 
> determined at runtime, by 'outward' searching (IIRC, term used by the
> 
> Camel book) for a matching label in all currently active lexical
> 
> scopes. This implies that, compared to other means for performing flow
> 
> control, it is a very expensive operation.
> 
> 
> 
> --------------
> 
> use Benchmark;
> 
> 
> 
> timethese(-5,
> 
> 	  {
> 
> 	   goto => sub {
> 
> 	       goto out;
> 
> 
> 
> 	       print "ha!";
> 
> 
> 
> 	       out:
> 
> 	       return 3;
> 
> 	   },
> 
> 
> 
> 	   return => sub {
> 
> 	       return 3;
> 
> 	   }});

Thanks, that's interesting. I would have
thought that it'd be much cheaper. Of course, 
spaghetti code is super bad anyway for all
the reasons we know about.  You gotta have
Clint Eastwood's steely gaze and grit to 
follow the crooked trails and dodge bullets 
that might ricochet anywhere.  

That's why I said "duck".

-- 
Charles DeRykus


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

Date: Tue, 13 Nov 2012 11:30:51 -0800 (PST)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: static variable problem
Message-Id: <3ca96274-d8ae-4d20-9ec4-d643ec5caae9@googlegroups.com>

On Tuesday, November 13, 2012 5:38:07 AM UTC-8, Dave Saville wrote:
> 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?
> 
> 

And just for a spaghetti western :)


  goto BLOCK;

  FOO: foo("Hello World");
  exit;

  BLOCK: {
    my $bar = 1;

    sub foo
    {
      my $a = shift;
      print "$bar $a\n";   
      return;
    }
    goto FOO;
};
__END__

[ duck ]   C.DeRykus


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

Date: Thu, 15 Nov 2012 03:22:09 -0800 (PST)
From: dave@deezee.org
Subject: Re: static variable problem
Message-Id: <7abbf615-0772-4b1b-87fc-8f073d497f2b@googlegroups.com>

Thanks all. I was a bit confused because my test was pasted straight out of perldocs. :-)

Sorry for the late response but I am having problems with my newsreader and never saw my own post nor any of the replies. Had to log into Google to send this - Yuk I hate web groups. 


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

Date: Thu, 15 Nov 2012 12:46:01 -0800
From: Keith Thompson <kst-u@mib.org>
Subject: Re: static variable problem
Message-Id: <ln1ufuiohi.fsf@nuthaus.mib.org>

dave@deezee.org writes:
> Thanks all. I was a bit confused because my test was pasted straight
> out of perldocs. :-)
>
> Sorry for the late response but I am having problems with my
> newsreader and never saw my own post nor any of the replies. Had to
> log into Google to send this - Yuk I hate web groups.

Where exactly in the Perl docs did you find that code?

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
    Will write code for food.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"


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

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:

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

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 V11 Issue 3819
***************************************


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