[24403] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6591 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 21 03:05:48 2004

Date: Fri, 21 May 2004 00:05:08 -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           Fri, 21 May 2004     Volume: 10 Number: 6591

Today's topics:
    Re: Converting file-input argument as string <ewijaya@singnet.com.sg>
    Re: Converting file-input argument as string (Kevin Collins)
    Re: create tables in pdf using perl (Mohamed Parvez)
    Re: create tables in pdf using perl (Mohamed Parvez)
    Re: grepping lines above and below a pattern found (David Combs)
    Re: grepping lines above and below a pattern found (David Combs)
    Re: ISO two Perl idioms... <uri@stemsystems.com>
    Re: Password scheme/Persistent session... (krakle)
    Re: Password scheme/Persistent session... (krakle)
    Re: Password scheme/Persistent session... (krakle)
    Re: Perl array manipulation questions <uri@stemsystems.com>
    Re: Perl vs PHP (Sam Holden)
    Re: Perl vs PHP (krakle)
    Re: Perl vs PHP (krakle)
        Perl work? <postmaster@castleamber.com>
    Re: regexp to match time string <uri@stemsystems.com>
    Re: regexp to match time string <jwillmore@remove.adelphia.net>
    Re: scoping problem <postmaster@castleamber.com>
    Re: scoping problem <usenet@morrow.me.uk>
    Re: scoping problem <postmaster@castleamber.com>
    Re: SOLVED: How do I scope a variable if the variable n (Kevin Collins)
    Re: SOLVED: How do I scope a variable if the variable n <uri@stemsystems.com>
    Re: sort numeric lists (David Combs)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 21 May 2004 09:58:45 -0000
From: "Edward Wijaya" <ewijaya@singnet.com.sg>
Subject: Re: Converting file-input argument as string
Message-Id: <opr8cgn7edpncm2o@news.singnet.com.sg>


> So what's stopping you?  The variable IS a string.  Just go ahead and use
> it.  What have you tried that doesn't work the way you think it should?
>

I always thought $file from $ARGV[0]
is the whole file itself.

Now I know it can work.

Thanks so much.

Regards
Edward WIJAYA
SINGAPORE



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

Date: Fri, 21 May 2004 03:50:08 GMT
From: spamtotrash@toomuchfiction.com (Kevin Collins)
Subject: Re: Converting file-input argument as string
Message-Id: <slrncaqv3b.26a.spamtotrash@doom.unix-guy.com>

In article <opr8cgn7edpncm2o@news.singnet.com.sg>, Edward Wijaya wrote:
> 
>> So what's stopping you?  The variable IS a string.  Just go ahead and use
>> it.  What have you tried that doesn't work the way you think it should?
>>
> 
> I always thought $file from $ARGV[0]
> is the whole file itself.
> 
> Now I know it can work.
> 
> Thanks so much.

Edward,

	I've posted a similar response to one of your posts in comp.unix.shell, but
I'll try again:

Please, PLEASE start out by attempting to *learn* the languages you are using
before posting all these questions to newsgroups that waste people's time. Read
the man pages, the perldocs, the FAQs, the various tutorial sites, Google.com,
etc.

It has become clear to me that you are in WAY over your head. People will help
you no matter what, since you are polite and seem to try to listen to what they
are saying, but you are pushing the limits of what is acceptable. 

Every question I have seen you post (~15+), would be answered in the basic
documentation for the respective language (Perl, ksh), which means you didn't
look or you don't care if you are wasting my time.

For your benefit, I really hope you try to do some learning before you do more
posting.

Good luck,

Kevin


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

Date: 20 May 2004 22:37:16 -0700
From: parvez@gmail.com (Mohamed Parvez)
Subject: Re: create tables in pdf using perl
Message-Id: <f86738db.0405202137.79620ec3@posting.google.com>

well i did that, the first thing. But i could not find any module that
would let me create tables inside a pdf


"J. Gleixner" <glex_nospam@qwest.invalid> wrote in message news:<035rc.66$QZ6.20350@news.uswest.net>...
> Mohamed Parvez wrote:
> > Hello All,
> > 
> > Is there any perl module that will let me create tables inside pdf document?
> > 
> > I need to create reports in table format in a pdf file 
> > 
> > If some examples can be provided it will be great 
> 
> Whenever you have a. "Is there any perl module that will...", question,
> always start by searching CPAN:
> 
> http://search.cpan.org/
> 
> Examples are typically included with the module's documentation.


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

Date: 20 May 2004 22:38:10 -0700
From: parvez@gmail.com (Mohamed Parvez)
Subject: Re: create tables in pdf using perl
Message-Id: <f86738db.0405202138.26f8157a@posting.google.com>

well i did that the first thing. But i could not find any module that
would let me create tables inside a pdf

"J. Gleixner" <glex_nospam@qwest.invalid> wrote in message news:<035rc.66$QZ6.20350@news.uswest.net>...
> Mohamed Parvez wrote:
> > Hello All,
> > 
> > Is there any perl module that will let me create tables inside pdf document?
> > 
> > I need to create reports in table format in a pdf file 
> > 
> > If some examples can be provided it will be great 
> 
> Whenever you have a. "Is there any perl module that will...", question,
> always start by searching CPAN:
> 
> http://search.cpan.org/
> 
> Examples are typically included with the module's documentation.


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

Date: Fri, 21 May 2004 04:01:03 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: grepping lines above and below a pattern found
Message-Id: <c8jutv$2me$1@reader2.panix.com>

In article <Xns94D297D2B5106dkwwashere@216.168.3.30>,
David K. Wall <dwall@fastmail.fm> wrote:
>Abhinav <matrix_calling@yahoo.dot.com> wrote:
>
>> mike wrote:
>> 
>>> say i have this in a text file
>>> 
>>> "Use this form to 
>>> post your messages.
>>> Remember that 
>>> it can be viewed by 
>>> millions of people worldwide. 
>>> For questions about posting, 
>>> check our FAQ"
>>> 
>>> what is the most commonly used way to print ,say , 2 lines above
>>> and 2 lines below a certain pattern found such that my output is
>>> 
>>> "post your messages.
>>> Remember that 
>>> it can be viewed by 
>>> millions of people worldwide. 
>>> For questions about posting, "
>>> 
>>> for the matched pattern "viewed" .
>>> 
>>> thanks...
>> Is this allowed ?
>> 
>> system "grep -A2 -B2 $pattern $file";
>
>Might not work well on an OS without grep. :-) 

Might not work well on an OS without GNU grep. :-) 

David



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

Date: Fri, 21 May 2004 04:12:34 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: grepping lines above and below a pattern found
Message-Id: <c8jvji$2tb$1@reader2.panix.com>

In article <4086EB21.CF01E2C3@acm.org>, John W. Krahn <krahnj@acm.org> wrote:
>mike wrote:
>> 
>> say i have this in a text file
>> 
>> "Use this form to
>> post your messages.
>> Remember that
>> it can be viewed by
>> millions of people worldwide.
>> For questions about posting,
>> check our FAQ"
>> 
>> what is the most commonly used way to print ,say , 2 lines above and 2
>> lines below a certain pattern found such that my output is
>> 
>> "post your messages.
>> Remember that
>> it can be viewed by
>> millions of people worldwide.
>> For questions about posting, "
>> 
>> for the matched pattern "viewed" .
>
>my $above = 2;
>my $below = 2;
>
>my @buffer;
>
>while ( <> ) {
>    @buffer = ( @buffer, $_ )[ -( $above + 1 ) .. -1 ];
>    /viewed/ && print @buffer, map scalar <>, 1 .. $below;
>    }
>

John:  Perhaps you could add a few comments explaining
       your (as usual) nifty code?

Once you've done that, maybe it can be inserted 
in to some tutorial part of the pod-files --
looks like it'd be useful, and educational, for
lots of people.

Thanks,

David




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

Date: Fri, 21 May 2004 03:59:46 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: ISO two Perl idioms...
Message-Id: <x7pt8yl9al.fsf@mail.sysarch.com>

>>>>> "b" == bill  <please_post@nomail.edu> writes:


  b> 1. The problem is to read and discard lines from a file until a
  b>    condition is met (usually some regexp match), and then process
  b>    subsequent lines.  E.g.

  b>    my $found;
  b>    while (<IN>) {
  b>      if (meets_condition($_)) {
  b>        $found = 1;
  b>        last;
  b>      }
  b>    }

  b>    die "Bad data\n" unless $found;

  b>    while (<IN>) {
  b>      # etc.
  b>    }

i read the other posts and none seem to use subs which make for a great
flow control mechanisim. and i don't like to use boolean flags for loop
stuff if i can help it that it reeks of fortran and spaghetti code.

	sub skip_until_condition {
		my( $fh, $cond_code) = @_ ;

		while( <$fh> ) {
			return if $cond_code->($_) ;
		}

		die "lousy file i just read" ;
	}

now in the main code you just do:

	skip_until_condition( \*IN, \&meets_condition ) ;

	while( <IN> ) {

		...
	}

clean and easy to understand. the lesson is that return is a flow
control op too and that subs are your friend.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 20 May 2004 21:19:05 -0700
From: krakle@visto.com (krakle)
Subject: Re: Password scheme/Persistent session...
Message-Id: <237aaff8.0405202019.6ffc3e47@posting.google.com>

"John W. Kennedy" <jwkenne@attglobal.net> wrote in message news:<_55rc.106204$MH.21799388@news4.srv.hcvlny.cv.net>...
> krakle wrote:
> > The question IS ontopic to this group.
> 
> No, it is not.  You are asking a question about how the web works, not 
> how Perl works.

I never asked how the web works or any sort of question to that
nature. It was a question pertaining to sessions in mod_perl. Yes it
will be used for a web site obviously but it DOESN'T make sense to ask
a PERL question in a regular newsgroup dealing with the web that
doesn't relate to PERL... Why is this so hard for you guys to
understand...


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

Date: 20 May 2004 21:21:23 -0700
From: krakle@visto.com (krakle)
Subject: Re: Password scheme/Persistent session...
Message-Id: <237aaff8.0405202021.2d9c43d0@posting.google.com>

Tad McClellan <tadmc@augustmail.com> wrote in message news:<slrncamk5q.692.tadmc@magna.augustmail.com>...
> Your question is not about Perl. Your question is about how to
> maintain state in CGI applications.

Because mod_perl IS CGI? Actually buddy, mod_perl ISN'T CGI...


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

Date: 20 May 2004 21:26:35 -0700
From: krakle@visto.com (krakle)
Subject: Re: Password scheme/Persistent session...
Message-Id: <237aaff8.0405202026.7c7a2896@posting.google.com>

yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) wrote in message news:<40abbf23@news.victoria.tc.ca>...
> Well for one thing you condradicted yourself elsewhere.

I see no contradiction in my posts.

> You said that
> looking up names that start with Z would take longer than names that start
> with A (or words to that effect).

This is true. Linear.

> However, that would only be true if the
> data was sorted, which would imply that apache does something smarter with
> the data in .htpasswd than simply doing a "linear style look up".

Read the documentation. Better yet, add 100,000 users to a plaintext
 .htpasswd file. Have fun with it :)

> I wouldn't see any reason to assume that apache does
> linear lookups in the first place.

Why ASSUME? Apache does linear lookups on .htpasswd. If you wanted it
NOT to there is a seperate mod that enables you to use a Berkely DB.

> it is just as possible that the files
> are (for example) cached in memory in some kind of structure that provides
> extremely fast lookup.

Possible? You are just guessing... And that's not how .htpasswd
works...


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

Date: Fri, 21 May 2004 04:03:18 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Perl array manipulation questions
Message-Id: <x7iseql94p.fsf@mail.sysarch.com>

>>>>> "BM" == Ben Morrow <usenet@morrow.me.uk> writes:

  >> Is there a way to create a 3rd array of the same size such that @c = @a 
  >> + @b, and after the operation @c = (3, 6, 9, 12).  Again, without using 
  >> a for or a foreach loop??

  BM> @c = map { $a[$_] + $b[$_] } 0..$#a;

if you can afford to destroy one of those arrays, it can be done without
indexing (which is slowish and i just prefer to skip if not needed).

	@c = map { shift @a + $_ } @b ;

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 21 May 2004 01:26:29 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl vs PHP
Message-Id: <slrncaqmm5.1le.sholden@flexal.cs.usyd.edu.au>

On Thu, 20 May 2004 22:44:12 GMT,
	Charlton Wilbur <cwilbur@mithril.chromatico.net> wrote:
>>>>>> "W" == Wappler  <wappler@gmx.net> writes:
> 
>    W> Perhaps it is not possible to get a decent answer in a perl
>    W> newsgroup.  Maybe you should try a google search with
>    W> "advantages of PHP versus Perl".  There are people - not only
>    W> PHP freaks - who see advantages here.
> 
> Most of the advantages have to do with being quick and dirty, or small
> and cheap.  But as soon as you get to the point of needing to do large
> projects in it, the advantages of PHP vanish.
> 
> For instance, mod_perl can't really be run safely in a shared
> environment the way mod_php can, because mod_perl gives the user
> access to server internals, and an error can hose all the server
> children -- even those serving other virtual hosts.  So for speed in a
> shared hosting environment, you're pretty much stuck with PHP, because
> mod_perl is too unsafe to run.

On the el-cheapo shared web hosts I've used there has been a transition
(usually without bothering to inform me until after the fact - but you
expect that when you pay next to nothing) to a php which runs as the user
and not the server uid. I can only assume it forks a process ala cgi
for each request - and hence loses the speed benefit.

But that's miles off topic...


-- 
Sam Holden


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

Date: 20 May 2004 21:30:23 -0700
From: krakle@visto.com (krakle)
Subject: Re: Perl vs PHP
Message-Id: <237aaff8.0405202030.46237c8a@posting.google.com>

Tad McClellan <tadmc@augustmail.com> wrote in message news:<slrncaoaj1.86e.tadmc@magna.augustmail.com>...
> Wappler <wappler@gmx.net> wrote:
> 
> > there is
> > nothing you can't do with PERL.
> 
> 
> There is nothing you can't do with Perl either.

or perl or pErL or PErl... We all know what language he is referring
to by when he says PERL. Ok tad, or Tad rather...


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

Date: 20 May 2004 21:38:00 -0700
From: krakle@visto.com (krakle)
Subject: Re: Perl vs PHP
Message-Id: <237aaff8.0405202038.63f1f5ec@posting.google.com>

"Wappler" <wappler@gmx.net> wrote in message news:<40acecba$0$31052$91cee783@newsreader02.highway.telekom.at>...
> Perhaps it is not possible to get a decent answer  in a perl newsgroup.
> Maybe you should try a google search with "advantages of PHP versus Perl".
> There are people - not only PHP freaks - who see advantages here.

I can give an unbiased answer. If I had to start all over and select a
language to learn from scratch FOR the web I'd use PHP because 1. It's
easier 2. More convienent and 3. faster than CGI. If I had to program
something not dealing with the web I would use Perl..Obviously since
Perl DIDN'T start off (or ever became) an internet language... Since
i've worked with Perl for years and became aquinted with mod_perl I
prefer to use Perl for web work and offline work. You know what they
say: It's not the language it's how well the programmer knows it.

In a nut shell... If you are only interested in doing web work PHP may
very well be the best way to go because it was made and geared
specifically for that. Times have changed. Change is good. PHP is the
prefered language on the web. But use whatever YOU are most
comfortable and most effective with.


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

Date: Thu, 20 May 2004 20:51:24 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Perl work?
Message-Id: <40ad609d$0$201$58c7af7e@news.kabelfoon.nl>

I am looking for freelance Perl work. I already found jobs.perl.org. But 
I am wondering if there are more sites that list freelance perl projects.

I did some Google searches, but only found bidding sites where people 
want a $5 / hour Perl programmer, and people offer to do it $ 2 / hour :-(

Any pointers to good sites are welcome.


-- 
John                               MexIT: http://johnbokma.com/mexit/
                            personal page:       http://johnbokma.com/
    Experienced Perl programmer available:     http://castleamber.com/


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

Date: Fri, 21 May 2004 03:23:10 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: regexp to match time string
Message-Id: <x7u0yalazl.fsf@mail.sysarch.com>

>>>>> "JW" == James Willmore <jwillmore@remove.adelphia.net> writes:

  JW> On Thu, 20 May 2004 14:54:20 +0000, Brandon Metcalf wrote:
  >> I'm trying to come up with a regexp to match a string containing the
  >> date and time in the format:
  >> 
  >> yyyy-mm-dd hh:mm:ss
  >> 
  >> with either the date or time part being optional but not both and the
  >> ":ss" part always being optional.  I have the following which falls short
  >> in a number of ways:
  >> 
  >> /^(\d{4}(-\d{1,2}){1,2}\s+)?(\d{1,2}(:\d{2}){1,2})?$/

  JW> Not sure (and could be very wrong)

  JW> my @datetime = split /[-:]/, $the_string_to_parse;

then how can you determine which are the missing parts? so i bet on very
wrong. :)

uri 

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 21 May 2004 00:03:53 -0400
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: regexp to match time string
Message-Id: <pan.2004.05.21.04.03.51.335259@remove.adelphia.net>

On Fri, 21 May 2004 03:23:10 +0000, Uri Guttman wrote:

>>>>>> "JW" == James Willmore <jwillmore@remove.adelphia.net> writes:
> 
>   JW> On Thu, 20 May 2004 14:54:20 +0000, Brandon Metcalf wrote:
>   >> I'm trying to come up with a regexp to match a string containing
>   >> the date and time in the format:
>   >> 
>   >> yyyy-mm-dd hh:mm:ss
>   >> 
>   >> with either the date or time part being optional but not both and
>   >> the ":ss" part always being optional.  I have the following which
>   >> falls short in a number of ways:
>   >> 
>   >> /^(\d{4}(-\d{1,2}){1,2}\s+)?(\d{1,2}(:\d{2}){1,2})?$/
> 
>   JW> Not sure (and could be very wrong)
> 
>   JW> my @datetime = split /[-:]/, $the_string_to_parse;
> 
> then how can you determine which are the missing parts? so i bet on very
> wrong. :)

How about ...
my @datetime = split /[-: ]/, $the_string_to_parse; #I didn't consider the
space in the previous example.

Of course, this works if the line has only the pattern yyyy-mm-dd hh:mm:ss
-or- yyyy-mm-dd hh:mm and variations therein.  And doesn't fully meet the
requirements the OP set forth :-(  And, you can't be sure about the
missing parts :-(

But ... it's nice to post something like this in the hopes that someone
*may* be able to use it later on - so I don't feel all that bad about
missing the mark :-)

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
 Philosophy will clip an angel's wings.   -- John Keats 
 
 


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

Date: Thu, 20 May 2004 20:11:53 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: scoping problem
Message-Id: <40ad575b$0$200$58c7af7e@news.kabelfoon.nl>



ZMAN wrote:

> Hello all-
> 
> I have a routine to generate an image map that I've written for our HTML
> wrapper that we use here at work.
> I for the life of me have not been able to clear out the array @t_imaprows.

Where do you clear it? And why do you use a global?

> Keeps appending with each pass.
> Any help would be greatle appreciated thanks in advance!
> 
> 
> ########################################################
> my (@t_imaprows)=();
> 
> %env_imap = (
>               'begin_fn' => ['*SKIP*', 'BeginImap'],
>               'end_fn' => ['*SKIP*', 'EndImap'],
>               'name' => '',
> );
> 
> sub mcr_imaprow
> {
>    push(@t_imaprows, {@_});
>    return(undef);

that's the default behaviour of return so use return;

> }
> sub BeginImap
> {
>   my($cmp) = &df::CurrentComponent();

No need for the & I guess.

>   my($tag, $pass, %env) = @_;

>   return(undef) if ($factory::pass_level < 1);

     return if $factory::pass_level < 1;


>   my($r) = '';
>   my $name  = $env{'name'};
>   $r .= "<map name=\"$name\">\n";
>   my($i);
>   for($i = 0; $i <= $#t_imaprows; $i++ )

     for (my $i = 0; etc .)

>   {
>     my(%t_imaprow) = %{$t_imaprows[$i]};
>     my $coords  = $t_imaprow{'coords'};
>     my $shape  = $t_imaprow{'shape'};
>     my $target  = $t_imaprow{'target'};
>     my($link) = $t_imaprow{'link'};
>     my($l) = &make_link($link);

drop the &

>     my($target_str);
> 
>    if ($t_imaprow{'target'} eq '')
>    {
>         $target_str = '';
>    } else {
>         $target_str = "target=\"_$setimaprow{'target'}\"";
>    }

      my $target_str = $t_imaprow{'target'}  eq ''
			?
		      		''
			:
				qq(target="_$setimaprow{'target'}");


>      $r .= "<AREA coords=\"$coords\" href=$l shape=\"$shape\"
> $target_str>\n";

use qq here, no need to escape the ".

>    }

if you want to clear it, @t_imaprows = (); for example.

> 
>   $r .= "</map>\n";
> 
>   return($r);
> }
> 
> sub EndImap
> {
>               return(undef);

return;

> }

-- 
John                               MexIT: http://johnbokma.com/mexit/
                            personal page:       http://johnbokma.com/
    Experienced Perl programmer available:     http://castleamber.com/


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

Date: Fri, 21 May 2004 02:48:39 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: scoping problem
Message-Id: <c8jqm7$che$1@wisteria.csv.warwick.ac.uk>


Quoth John Bokma <postmaster@castleamber.com>:
> >    return(undef);
> 
> that's the default behaviour of return so use return;

No it's not. return with no argument returns undef in scalar ctx and the
empty list in list ctx. This means it is always false. return undef is
true in list ctx (which is not usually what you meant).

Ben

-- 
$.=1;*g=sub{print@_};sub r($$\$){my($w,$x,$y)=@_;for(keys%$x){/main/&&next;*p=$
$x{$_};/(\w)::$/&&(r($w.$1,$x.$_,$y),next);$y eq\$p&&&g("$w$_")}};sub t{for(@_)
{$f&&($_||&g(" "));$f=1;r"","::",$_;$_&&&g(chr(0012))}};t    # ben@morrow.me.uk
$J::u::s::t, $a::n::o::t::h::e::r, $P::e::r::l, $h::a::c::k::e::r, $.


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

Date: Thu, 20 May 2004 22:01:15 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: scoping problem
Message-Id: <40ad70ff$0$210$58c7af7e@news.kabelfoon.nl>

Ben Morrow wrote:

> Quoth John Bokma <postmaster@castleamber.com>:
> 
>>>   return(undef);
>>
>>that's the default behaviour of return so use return;
> 
> No it's not. return with no argument returns undef in scalar ctx and the
> empty list in list ctx. This means it is always false. return undef is
> true in list ctx (which is not usually what you meant).

Oops. I stand corrected, thanks.

-- 
John                               MexIT: http://johnbokma.com/mexit/
                            personal page:       http://johnbokma.com/
    Experienced Perl programmer available:     http://castleamber.com/


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

Date: Fri, 21 May 2004 03:57:55 GMT
From: spamtotrash@toomuchfiction.com (Kevin Collins)
Subject: Re: SOLVED: How do I scope a variable if the variable name contains a variable?
Message-Id: <slrncaqvhu.26a.spamtotrash@doom.unix-guy.com>

In article <c8jitc$95n$1@wisteria.csv.warwick.ac.uk>, Ben Morrow wrote:
> 
> Quoth IneverReadAnythingSentToMe@hotmail.com (David Filmer):
>> The fact that my last posting seems very clear to me but not to you is
>> troubling. Either I have it right but am expressing it poorly, or I
>> have it wrong. I believe I'm clearly expressing my understanding of
>> the subject, so I wonder if my understanding is all wrong.
> 
> Others have explained most of where you're wrong. Basically:
> 
> 1. Symrefs (using-a-variable-as-a-variable-name) only work with globals.

Please clarify that, because I don't believe it :)

sub foo
{
	my @bar = qw(a b c); 	# create array bar
	my $baz = 'bar';		# 
	my @bee = @{$baz}		# @bee == @bar
}

Every thing there is lexical and scoped to the subroutine, i.e., not global...
Or maybe I'm really confused?

> 2. Symrefs don't work under use strict.
> 3. This is for a good reason: they are dangerous, and not usually
>    necessary.

-snip-

Thanks,

Kevin


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

Date: Fri, 21 May 2004 04:13:26 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: SOLVED: How do I scope a variable if the variable name contains a variable?
Message-Id: <x7fz9ul8nu.fsf@mail.sysarch.com>

>>>>> "KC" == Kevin Collins <spamtotrash@toomuchfiction.com> writes:

  >> 1. Symrefs (using-a-variable-as-a-variable-name) only work with globals.

  KC> Please clarify that, because I don't believe it :)

  KC> sub foo
  KC> {
  KC> 	my @bar = qw(a b c); 	# create array bar
  KC> 	my $baz = 'bar';		# 
  KC> 	my @bee = @{$baz}		# @bee == @bar
  KC> }

have you actually tested that code? why do you believe that last
assignment worked?

#!/usr/local/bin/perl

#use strict ;

print foo(), "\n" ;

sub foo {
	my @bar = qw(a b c); 	# create array bar
	my $baz = 'bar';		# 
	my @bee = @{$baz}		# @bee == @bar
}

that printed a blank line as i would expect.

when i enabled strict, it bombed with this:

Can't use string ("bar") as an ARRAY ref while "strict refs" in use at
/home/uri/perl/test/symref_lex.pl line 10.

which is also as expected.

so please believe that symrefs don't work with lexical/my vars. my vars
are NOT in the symbol table so you can't access them via symrefs.
lexicals only work with real/hard refs (but hard refs can also work with
globals).

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 21 May 2004 03:46:17 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: sort numeric lists
Message-Id: <c8ju29$2di$1@reader2.panix.com>

In article <x74qreozy9.fsf@mail.sysarch.com>,
Uri Guttman  <uri@stemsystems.com> wrote:
 ...
>
>and the promised module in that paper (5 years ago) is actually under
>full development right now and mostly working. it is the core of a talk
>i am giving at yapc::buffalo this june. the module is called Sort::Maker
>and this is what the OP would do to properly sort his rows of numbers
>
>	use Sort::Maker ;
>
>	my $sorter = make_sorter(
>		plain	=> 1,
>		number	=> '$_->[0]',
>		number	=> '$_->[1]',
>		number	=> '$_->[2]',
>	) ;
>
>	my @sorted = $sorter->( @unsorted ) ;
>
>i may have an alpha version of this module ready in a few weeks if
>anyone is interested in playing with it. the goal is to have it on cpan
>before yapc which is in mid-june.

Yes, I'd very much to have a go at using it.  Thus, please
add me to your list of email-addrs to send your
"buggy, but worth a try" announcement to.

Thanks!

David   dkcombs@panix.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 6591
***************************************


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