[16227] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3639 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 12 14:16:00 2000

Date: Wed, 12 Jul 2000 11:15:31 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963425731-v9-i3639@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 12 Jul 2000     Volume: 9 Number: 3639

Today's topics:
    Re: Perl... the split function <lauren_smith13@hotmail.com>
    Re: Perl... the split function (M.J.T. Guy)
    Re: Printing web pages aaronp243@my-deja.com
    Re: Reading lines of a file within a loop? <iltzu@sci.invalid>
    Re: Regex Never satisfied <john@nomailplease>
        session tracking dbottoms98@my-deja.com
    Re: Sorting a tab separated table ? <jeff@vpservices.com>
    Re: sorting issue <dpalmeNOSPAM@unitedtraffic.com>
    Re: sorting issue (Tad McClellan)
    Re: sorting issue <juex@deja.com>
        stat->mtime trouble <slavelle@concentus-tech.com>
        Strange Characters Like &#61623 ? <axl@loop.com>
    Re: Strange Characters Like &#61623 ? <care227@attglobal.net>
    Re: Strange Characters Like &#61623 ? <bill.kemp@wire2.com>
    Re: stupid perl question newsposter@cthulhu.demon.nl
    Re: stupid perl question (NP)
    Re: stupid perl question <d.drury@spamoffucl.ac.uk>
    Re: stupid perl question <bart.lateur@skynet.be>
    Re: sub selects (Tad McClellan)
        this is a test mindspring is screwing up their news ser <dpalmeNOSPAM@unitedtraffic.com>
    Re: this is a test mindspring is screwing up their news <sariq@texas.net>
    Re: this is a test mindspring is screwing up their news <care227@attglobal.net>
    Re: using @_ with subs (Just a quickie from a Perl Wann (Tad McClellan)
    Re: Which one is better? $_[0] or shift? <bart.lateur@skynet.be>
    Re: Which one is better? $_[0] or shift? <lr@hpl.hp.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 12 Jul 2000 09:04:06 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Perl... the split function
Message-Id: <8ki4v1$5dp$1@brokaw.wa.com>


Antony <mcnultya@nortelnetworks.com> wrote in message
news:MPG.13d68eaae5b1fa798968b@eurnews0...
>
> My problem is... how do you set the delimiters to be a 'space' and a
> 'comma' ?
>
> I have tried
> split(/([, ])/, "1 10,20", 3);
> But for some reason that doesn't work.

Do you want to split on a ", " or on either " " or ","?

space+comma
split (/ ,/, $string);

space or comma
split (/[ ,]/, $string);

Use the parens if you want to capture the delimiters, leave them out to toss
them.

Lauren





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

Date: 12 Jul 2000 16:57:02 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Perl... the split function
Message-Id: <8ki80u$58k$1@pegasus.csx.cam.ac.uk>

Antony  <mcnultya@nortelnetworks.com> wrote:
>
>My problem is... how do you set the delimiters to be a 'space' and a 
>'comma' ?
>
>I have tried
>	split(/([, ])/, "1 10,20", 3);
>But for some reason that doesn't work.

What do you mean by "doesn't work"?   What did you expect it to produce,
and what did it actually produce?

It does what I expect it to do (modulo some curiosity about the third
argument):

  DB<1> x split(/([, ])/, "1 10,20", 3);
0  1
1  ' '
2  10
3  ','
4  20
  DB<2>


Mike Guy


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

Date: Wed, 12 Jul 2000 16:03:49 GMT
From: aaronp243@my-deja.com
Subject: Re: Printing web pages
Message-Id: <8ki4sr$mj3$1@nnrp1.deja.com>

In article <87sntgw1f1.fsf@limey.hpcc.uh.edu>,
  Tony Curtis <tony_curtis32@yahoo.com> wrote:
> >> On Tue, 11 Jul 2000 19:29:46 GMT,
> >> aaronp243@my-deja.com said:
>
> > Hi!  I am trying to print a web page using perl as if
> > the web page were being printed from netscape.  I want
> > to do this with perl because I have to print out many of
> > the web pages!  Any ideas would be appreciated!  Thanks
> > in advance.
>
>     perldoc lwpcook
>
> to find out how to grab stuff off the web in perl.
>
>     perldoc HTML::TreeBuilder
>     perldoc HTML::FormatPS
>
> will parse the HTML and let you output it as PostScript.
>
> (Alternatively netscape can be controlled remotely from
> the command line, so you might be able to tell netscape to
> print through a script.  But this is clpm, so that would
> be blasphemous. :-)
>
> hth
> t
> --
> "With $10,000, we'd be millionaires!"
>                                            Homer Simpson
>

Hi.  I tryed this approach once.  Unfortunately I have images in the web
pages that need to be printed out.  Also, if there are tables in the
page, they will not be printed out.  It will say "Table not shown".  I
think that the module is just trying to get out of doing work! :)

-Aaron


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 12 Jul 2000 15:38:41 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Reading lines of a file within a loop?
Message-Id: <963416116.12623@itz.pp.sci.fi>

In article <slrn8mosle.9rf.bernard.el-hagin@gdndev25.lido-tech>, Bernard El-Hagin wrote:
>>	my $speed = $1;
>>>      if ($speed >= 500 )
>            ^^^^^^
>This is where "use strict" will cause the script to die unless you make
>$speed global.

Eh? I see no closing brace between those two lines, so how could
$speed go out of scope between them?

Admittedly, the code has been quoted and edited so much I can't be
100% sure I (or someone else) didn't snip out something relevant.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.





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

Date: Wed, 12 Jul 2000 16:32:00 +0100
From: "John" <john@nomailplease>
Subject: Re: Regex Never satisfied
Message-Id: <396c8fef$1@news.telinco.net>


Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote in message
news:slrn8mougg.9rf.bernard.el-hagin@gdndev25.lido-tech...
> On Wed, 12 Jul 2000 14:38:24 +0100, John <john@nomailplease> wrote:
> >
> >Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote in message
> >news:slrn8moi52.9rf.bernard.el-hagin@gdndev25.lido-tech...
> >> On Wed, 12 Jul 2000 10:40:39 +0100, John <john@nomailplease> wrote:
> >> >At last I feel the arcane mystery of regex starting to reveal itself
to
> >me !
> >> >
> >> >However chuffed I am that my code below works I would appreciate it if
> >> >someone would show me how it could be done a bit better.
> >> >I'm sure it could be done in two lines by not destroying the RHS but
am
> >> >stumped.
> >> >
> >> >Thanks, JohnShep
> >> >
> >> >  $alpha = $numeric = $string_in;
> >> >  $alpha =~ s/[\W]|[\d]//g; # remove any non letters
> >> >  $numeric =~ s/[\D]//g; # remove any non digits
> >>
> >> If you want these in two different variables (as you seem to ) then the
> >> only improvements and/or simplifications I can think of are:
> >>
> >> $alpha =~ s/[\W\d]//g;
> >>
> >> and
> >>
> >> $numeric =~ s/\D//g;
> >>
> >Yes that's what I need, I was imagining a regex that was something like
> >$alpha = extract_alpha_from $string_in;
> >$numeric = extract_numeric_from $string_in;
> >thanks John
>
> You mean something like this:
>
> ($some_variable) = $string_to_search =~ m/some(.*)regex/;
>
> which would put $1 into $some_variable if there's a match in
> $string_to_search.
>
> But I don't know if that's possible in your case since you haven't
> provided an input string. If, for example, your input is...
>
> $string_in = "aaa999bbb";
>
> ...and you want just the numbers you can use:
>
> ($nums) = $string_in =~ m/(d\+)/;
>
> But if...
>
> $string_in = "a8d8w7823y34uwierwe87234";
>
> ...and you still want just the numbers, you have to use s/// or some
> other way (a map, possibly). Of course there could be a way to use the
> ($a) = $b =~ /(.*)/ form, but I don't know how.  You can be sure,
> though, that if it's possible someone here will post it. :-)
>
> Bernard

Thanks Bernard, I've learned something from your posts.
Best wishes, John




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

Date: Wed, 12 Jul 2000 17:35:30 GMT
From: dbottoms98@my-deja.com
Subject: session tracking
Message-Id: <8kia90$r9i$1@nnrp1.deja.com>

To All,

Does anyone know where I can get some good info and examples on session
tracking in Perl??  I want it so that users have to login to view all
the pages in a website!!  Not just login on the first page but be able
to type in a url of a page in the site without loggin in!

Thanks


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 12 Jul 2000 10:26:55 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Sorting a tab separated table ?
Message-Id: <396CAA5F.904E0F22@vpservices.com>

dpi27@my-deja.com wrote:
> 
> I want to sort a table using an element of this table as the sorting
> key.
> 
> I thought of coding it like this :
> 
> foreach $element (sort { (split(/\t/,$a))[1] cmp (split(/\t/,$b))[1]) }
> @table)
> 
> so for a table like this one :
> @table=("val1.1\tval2.1\tval3.1\tval4.1","val2.1\tval2.2\tval3.2\val4.2"....)

If you wish to handle this as a database, DBI along with either DBD::CSV
or DBD::RAM will handle tab "delimited" files just fine and let you use
a SQL ORDER BY clause to sort it on any combination of fields.  With
DBD::RAM you could just treat @table directly as a SQL accessible table.

-- 
Jeff


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

Date: Wed, 12 Jul 2000 11:14:09 -0500
From: "D.W." <dpalmeNOSPAM@unitedtraffic.com>
Subject: Re: sorting issue
Message-Id: <8ki7th$3of$1@nntp9.atl.mindspring.net>

Colin,
I was reviewing what I'm trying to do and two things came up during this
review last night that will impact this.

unfortunately, I am going to have multiple records, so even sorting the hash
using the city/state combinations isn't going to work, and we also have a
date field which can have multiple entries on any given day so that isn't
going to work either.  I still have to sort this but I'm really befuddled
now as to how to do it using perl....

Any suggestions where to look?

Douglas

Colin Kuskie wrote in message ...
>On 11 Jul 2000, D.W. wrote:
>
>> I need to sort the miles as they are computed so that when the list is
>> displayed it will show the lowest or shortest miles to the highest.
>>
>> I tried using a hash keyed on the miles but the problem is some of the
>> cities are going to have the SAME MILES so that isn't going to work.
>>
>> does anyone have a suggestion on the simplest and easiest way to sort
this
>> so I can display the information correctly?
>
>You had the right idea with a hash, but instead of making the number
>of miles be the keys of the hash use the city-state combinations.  Then
>sort the keys of the hash by its values and you're done!
>
>For example:
>
>my %hash = (
>  "Portland-OR" => 125,
>  "Eugene-OR" => 15,
>  "Springfield-OR" => 15,
>  "Corvallis-OR" => 75
>)
>
>##Sort from lowest to highest
>##This can be made much more efficient via the Schwartzian Transform
>##by doing all the value lookups once.
>@sorted_keys = sort { $hash{$a} <=> $hash{$b} } keys %hash;
>
>print map { "$_:$hash{$_}\n" } @sorted_keys;
>
>Will print:
>Springfield-OR:15
>Eugene-OR:15
>Corvallis-OR:75
>Portland-OR:125
>
>Good luck!
>Colin
>




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

Date: Wed, 12 Jul 2000 12:23:55 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: sorting issue
Message-Id: <slrn8mp6sr.794.tadmc@magna.metronet.com>


[ Please put your comments *following* the quoted text that you
  are commenting on.

  Please do not quote an _entire_ article, quote just enough to
  establish the context for your comments.

  Please do not quote signatures.

  Please visit        news.announce.newusers

  Thank you.
]


On Wed, 12 Jul 2000 11:14:09 -0500, D.W. <dpalmeNOSPAM@unitedtraffic.com> wrote:

>I was reviewing what I'm trying to do and two things came up during this
>review last night that will impact this.
>
>unfortunately, I am going to have multiple records, so even sorting the hash
>using the city/state combinations isn't going to work, and we also have a
>date field which can have multiple entries on any given day so that isn't
>going to work either.  I still have to sort this but I'm really befuddled
>now as to how to do it using perl....
>
>Any suggestions where to look?


Sounds like you need a multilevel data structure.

   perldoc perlreftut

   perldoc perlref

   perldoc perllol

   perldoc perldsc




[ snip Jeopardy quoted text ]


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 12 Jul 2000 10:41:01 -0700
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: sorting issue
Message-Id: <396cadaa$1@news.microsoft.com>

"Tad McClellan" <tadmc@metronet.com> wrote in message
news:slrn8mn6ui.4q5.tadmc@magna.metronet.com...
> On 11 Jul 2000 22:10:29 GMT, D.W. <dpalmeNOSPAM@unitedtraffic.com> wrote:
> >
> >I'm computing the distances between these cities and a city/state
> >combination given at the command line.
>
> >I need to sort the miles as they are computed so that when the list is
>                           ^^^^^^^^^^^^^^^^^^^^
>
>
> You cannot do this (if I'm reading it correctly).
> You cannot sort a list if the list is not yet complete.

Well, not quite. You can assert that the list is sorted at all times. That
simply means, that a new element is inserted into the right spot rather then
appended at the end of the list.
However, a different data structure (e.g. at least a binary tree not to
mention others) would be better suited for this approach.

jue




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

Date: Wed, 12 Jul 2000 13:26:23 -0400
From: Sean Lavelle <slavelle@concentus-tech.com>
Subject: stat->mtime trouble
Message-Id: <396CAA3E.22BEE5FB@concentus-tech.com>

    I am trying to run down directories and check the mod times of the
files in them but I get these (fatal) errors alot:

        Can't call method "mtime" on an undefined value at
lookingglass.pl line 28.

        I am checking for a null value slipping in the array but that
doesn't seem to be it.  Here is the relevent code:

$now_time = time();

# Read the files in the dir to an array
$i=0;
find(sub{$dir_list[$i] =  $File::Find::name; $i++;}, $opt_i);

$j=0;
for($i=0; $i<=@dir_list; $i++){
  $stats = stat($dir_list[$i]);
  if($dir_list[$i] eq ""){}
  else{
    # check if modified in the last 24 hours -- this is where it bombs
out
    if(($now_time - $stats->mtime)<$day_sec){
      print $mod_list[$j]; print "  "; print $stats->mode; print "\n";
      $j++;
    }
  }
}

    Lots of thanks in advance.
        Sean


--
Sean Lavelle
  Concentus Technology Corporation
  5115 Parkcenter Ave, Suite 150
  Dublin, Ohio 43017
Phone (614) 799-4317
slavelle@concentus-tech.com




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

Date: Wed, 12 Jul 2000 08:55:26 -0700
From: Axl <axl@loop.com>
Subject: Strange Characters Like &#61623 ?
Message-Id: <396C94EE.2F96C014@loop.com>

Hi,

Running a "cut and paste your resume here" form submittal, there are
some odd characters that keep turning up. Right now they are all
replaced with a dash (-), since I'm assuming they're some kind of
bulleted list character. But it would be nice to know exactly what
characters these are supposed to represent. Would there be maybe a
translation chart somewhere?

& # 61623 ;
& # 61608 ;
& # 61656 ;

(Note - there are no spaces in the actual data being received, I just
put some spaces there so the &# wouldn't be possibly interpreted as the
original character before encoding.)

TIA,

Axl



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

Date: Wed, 12 Jul 2000 12:13:19 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Strange Characters Like &#61623 ?
Message-Id: <396C991F.BF425562@attglobal.net>

[microsoft.public.inetserver.iis.activeserverpages ???]

Axl wrote:
> 
> Hi,
> 
> Running a "cut and paste your resume here" form submittal, there are
> some odd characters that keep turning up. Right now they are all
> replaced with a dash (-), since I'm assuming they're some kind of
> bulleted list character. But it would be nice to know exactly what
> characters these are supposed to represent. Would there be maybe a
> translation chart somewhere?

Check out the kind folks at comp.infosystems.www.authoring.html
since those are used to display special chars within HTML markup.

Also, many HTML books contain just the chart you are looking for.


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

Date: Wed, 12 Jul 2000 17:41:51 +0100
From: "W Kemp" <bill.kemp@wire2.com>
Subject: Re: Strange Characters Like &#61623 ?
Message-Id: <963420253.4812.0.nnrp-07.c3ad6973@news.demon.co.uk>

>> Running a "cut and paste your resume here" form submittal, there are
>> some odd characters that keep turning up. Right now they are all
>> replaced with a dash (-), since I'm assuming they're some kind of
>> bulleted list character. But it would be nice to know exactly what
>> characters these are supposed to represent. Would there be maybe a
>> translation chart somewhere?
>
>Check out the kind folks at comp.infosystems.www.authoring.html
>since those are used to display special chars within HTML markup.


Don't bother them- the list of numbers/characters is the unicode list found
deep within http://www.unicode.org/

>
>Also, many HTML books contain just the chart you are looking for.

I doubt it really. I have an oldish full unicode list as a text file and its
450 kb, which is about 160 pages worth of text.
It doesn't have those characters mentioned!




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

Date: 12 Jul 2000 15:15:52 GMT
From: newsposter@cthulhu.demon.nl
Subject: Re: stupid perl question
Message-Id: <8ki238$ddp$1@internal-news.uu.net>

EPROM <eprom007@hotmail.com> wrote:


> No, not that I won't learn Perl, but it makes little sense to me to read for
> hours
> trying to figure something out, if there is a more simple way.

  So because you are to lazy to read you feel you are allowed to waste
other people's time. Thanks for the warning.

Erik



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

Date: Wed, 12 Jul 2000 15:25:43 GMT
From: nvp@spamnothanks.speakeasy.org (NP)
Subject: Re: stupid perl question
Message-Id: <X50b5.303679$MB.5105691@news6.giganews.com>

12 Jul 2000, newsposter@cthulhu.demon.nl <newsposter@cthulhu.demon.nl> wrote:
: 
:   So because you are to lazy to read you feel you are allowed to waste
: other people's time. Thanks for the warning.

Not trying to pick a fight, but... maybe 'p3rlc0dr' was right about
some of the people in this group...  There's no reason to be a jerk,
even when the person who's written the posting makes you want to rip
off your own arm and beat yourself with it.

-- 
Nate II



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

Date: Wed, 12 Jul 2000 16:37:18 +0100
From: "Duncan Drury" <d.drury@spamoffucl.ac.uk>
Subject: Re: stupid perl question
Message-Id: <8ki3ct$gsc$1@uns-a.ucl.ac.uk>

That is nasty.  You are the one reading a newsgroup and entering into
discussions of why someone asked a question.  No one else is wasting your
time but yourself...

Dunk
<newsposter@cthulhu.demon.nl> wrote in message
news:8ki238$ddp$1@internal-news.uu.net...
> EPROM <eprom007@hotmail.com> wrote:
>
>
> > No, not that I won't learn Perl, but it makes little sense to me to read
for
> > hours
> > trying to figure something out, if there is a more simple way.
>
>   So because you are to lazy to read you feel you are allowed to waste
> other people's time. Thanks for the warning.
>
> Erik
>




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

Date: Wed, 12 Jul 2000 18:31:18 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: stupid perl question
Message-Id: <087pmsolouijj453h6kcpm747hc2lpdd0r@4ax.com>

EPROM wrote:

>But your right, docs and faq are the first place that one should look...I just
>strongly doubted it would be in there.

The Perl Cookbook was written for people in a situation like yours:
given a problem, how do I tackle it in Perl? I'm not convinced such
simple taks are indeed in there...

-- 
	Bart.


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

Date: Wed, 12 Jul 2000 10:21:33 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: sub selects
Message-Id: <slrn8movnd.6cq.tadmc@magna.metronet.com>

On Wed, 12 Jul 2000 13:12:20 GMT, brainmuffin@excite.com <brainmuffin@excite.com> wrote:

>Does anyone know if mySQL supports sub-selects, and if so, what the
>syntax is?


errr, what is your Perl question?


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 12 Jul 2000 09:58:50 -0500
From: "D.W." <dpalmeNOSPAM@unitedtraffic.com>
Subject: this is a test mindspring is screwing up their news servers AGAIN
Message-Id: <8ki3ae$f1s$1@slb6.atl.mindspring.net>

It appears that Mindspring has flushed their entire cache of news articles
and I'm just testing to make sure that I can at the very least POST
SOMETHING.

Douglas





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

Date: Wed, 12 Jul 2000 10:42:32 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: this is a test mindspring is screwing up their news servers AGAIN
Message-Id: <396C91E8.CDCEE47@texas.net>

"D.W." wrote:
> 
> It appears that Mindspring has flushed their entire cache of news articles
> and I'm just testing to make sure that I can at the very least POST
> SOMETHING.

I don't see the word 'test' in comp.lang.perl.misc.

- Tom


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

Date: Wed, 12 Jul 2000 12:08:52 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: this is a test mindspring is screwing up their news servers AGAIN
Message-Id: <396C9814.3A427F6C@attglobal.net>

"D.W." wrote:
> 
> It appears that Mindspring has flushed their entire cache of news articles
> and I'm just testing to make sure that I can at the very least POST
> SOMETHING.

Please use alt.test or a similar group.


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

Date: Wed, 12 Jul 2000 10:24:23 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: using @_ with subs (Just a quickie from a Perl Wannabe :)
Message-Id: <slrn8movsn.6cq.tadmc@magna.metronet.com>

On Wed, 12 Jul 2000 14:49:10 +0200, Pirla <the.pirla@NOSPAM.flashnet.it> wrote:
>On 2 Jul 2000 14:02:28 +0100, Jonathan Stowe <gellyfish@gellyfish.com>
>wrote:
>
>>On Fri, 30 Jun 2000 15:13:32 +1000 Geoff Toogood wrote:

>>> open (FILE, '>>file.txt') || &error("CANT OPEN FILE");

>I think 


Please do not post guesses.

It hurts rather than helps.


>you have to call your subroutine error in this way:
> || error("CANT OPEN FILE");


No you don't.


>and your subroutine must return a value (True or False).


No it doesn't.


>Try 


Please try yourself before posting code.

If you don't have time to try it, then please do not post it.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 12 Jul 2000 18:24:33 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Which one is better? $_[0] or shift?
Message-Id: <6s6pms47aev7h16fphb1n3sq9lo2uqfipi@4ax.com>

Abigail wrote:

>][ The interest in the '??' operator -- (A ?? B) is the same as (defined A 
>][ ? A : B) -- seems to have waned.
>
>I don't think the interest has waned. But why bother reviving it when
>it unleases some of the most bitter flames I've seen, and the pumpking
>vetos it anyway?

Get another pumpking.

;-)

-- 
	Bart.


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

Date: Wed, 12 Jul 2000 10:57:24 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Which one is better? $_[0] or shift?
Message-Id: <MPG.13d6515fd80fcfdc98abbd@nntp.hpl.hp.com>

In article <963392840.1844@itz.pp.sci.fi> on 12 Jul 2000 09:20:36 GMT, 
Ilmari Karonen <iltzu@sci.invalid> says...
> In article <MPG.13d5375eb2b87da598abb7@nntp.hpl.hp.com>, Larry Rosler wrote:
> >In article <smn2c9lrnd6175@corp.supernews.com> on Tue, 11 Jul 2000 
> >20:54:33 GMT, Craig Berry <cberry@cinenet.net> says...
> >> Prakash Kailasa (prakash@gate.net) wrote:
> >> : Ilmari Karonen <iltzu@sci.invalid> wrote:
> >> : 
> >> : :   my $optional = @_ ? shift : 'default';
> >> : 
> >> : 	my $optional = shift || 'default';
> >> 
> >> What if the caller wants $optional to be 0 or '' or undef?
> >
> >I'm sure the point is to replace undef by 'default'.  Otherwise why 
> >bother with providing the default at all?
> 
> Because you want foo() to do the same as foo('default'), which might
> not be the same as foo(undef)?  Particularly useful where the optional
> value is used as a boolean.

Your observation refers to the code you posted, which tests the length 
of @_.  My comment refers to the alternate that simply shifts the 
argument in, where one cannot distinguish between undef as the actual 
first value of @_ or undef as the nonexistent first value of @_.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3639
**************************************


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