[25580] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7824 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 24 14:05:53 2005

Date: Thu, 24 Feb 2005 11:05:24 -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           Thu, 24 Feb 2005     Volume: 10 Number: 7824

Today's topics:
    Re: Annoying Problem with a Basic Perl app and XP Pro (Anno Siegel)
    Re: Annoying Problem with a Basic Perl app and XP Pro <sholden@flexal.cs.usyd.edu.au>
    Re: Annoying Problem with a Basic Perl app and XP Pro (Anno Siegel)
    Re: BerkeleyDB locking question <dwilga-MUNGE@mtholyoke.edu>
        Bizarre precedence quirk (bug?) <jkrugman345@yahbitoo.com>
    Re: Bizarre precedence quirk (bug?) <jonny@windmillwalton.demon.co.uk>
    Re: Bizarre precedence quirk (bug?) xhoster@gmail.com
    Re: Bizarre precedence quirk (bug?) <1usa@llenroc.ude.invalid>
    Re: Bizarre precedence quirk (bug?) <abigail@abigail.nl>
    Re: Bizarre precedence quirk (bug?) <mritty@gmail.com>
    Re: Comparing huge XML Files nospam@geniegate.com
    Re: Comparing huge XML Files <bernard.el-haginDODGE_THIS@lido-tech.net>
        CPAN problem <xrsr@rogerware.com>
    Re: CPAN problem <phaylon@dunkelheit.at>
    Re: Credit cards storage nospam@geniegate.com
    Re: glob xhoster@gmail.com
        How to generate random emails? kongyew@w-manager.com
    Re: How to generate random emails? <phaylon@dunkelheit.at>
        How to tell if a subroutine arg is a constant <jonny@windmillwalton.demon.co.uk>
    Re: How to tell if a subroutine arg is a constant <noreply@gunnar.cc>
    Re: How to tell if a subroutine arg is a constant <jonny@windmillwalton.demon.co.uk>
    Re: How to tell if a subroutine arg is a constant <tassilo.von.parseval@rwth-aachen.de>
    Re: How to tell if a subroutine arg is a constant <phaylon@dunkelheit.at>
    Re: How to tell if a subroutine arg is a constant <nobull@mail.com>
    Re: maximum size of a hash table xhoster@gmail.com
    Re: OOP Tutorial <leslievNO@SPAMicoc.co.za>
    Re: OOP Tutorial <leslievNO@SPAMicoc.co.za>
    Re: OOP Tutorial <leslievNO@SPAMicoc.co.za>
    Re: OOP Tutorial <phaylon@dunkelheit.at>
    Re: OOP Tutorial <flavell@ph.gla.ac.uk>
    Re: OOP Tutorial <abigail@abigail.nl>
    Re: OT: Re: standard mode for arrow down (Peter Lewerin)
    Re: OT: Re: standard mode for arrow down <matternc@comcast.net>
        That sig <leslievNO@SPAMicoc.co.za>
    Re: That sig <abigail@abigail.nl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 24 Feb 2005 14:13:47 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Annoying Problem with a Basic Perl app and XP Pro
Message-Id: <cvkner$dtb$1@mamenchi.zrz.TU-Berlin.DE>

Dimitri Papoutsis  <bastard@uni-koblenz.de> wrote in comp.lang.perl.misc:

> Definition: Pseudo-trial: 
>         not even tried to do sth. but babbling as if...

A trial is an experiment (if it isn't an interrogation).  The word you
want is "attempt".

Anno


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

Date: 24 Feb 2005 14:31:40 GMT
From: Sam Holden <sholden@flexal.cs.usyd.edu.au>
Subject: Re: Annoying Problem with a Basic Perl app and XP Pro
Message-Id: <slrnd1rpac.8ub.sholden@flexal.cs.usyd.edu.au>

On 24 Feb 2005 14:13:47 GMT,
	Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> Dimitri Papoutsis  <bastard@uni-koblenz.de> wrote in comp.lang.perl.misc:
>
>> Definition: Pseudo-trial: 
>>         not even tried to do sth. but babbling as if...
>
> A trial is an experiment (if it isn't an interrogation).  The word you
> want is "attempt".

A lot of common usage and a few dictionaries disagree with that and
include "to make an effort to do" as one of the meanings of
try.

But I missed all the context...

-- 
Sam Holden


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

Date: 24 Feb 2005 16:53:48 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Annoying Problem with a Basic Perl app and XP Pro
Message-Id: <cvl0qs$ka3$1@mamenchi.zrz.TU-Berlin.DE>

Sam Holden  <sholden@cs.usyd.edu.au> wrote in comp.lang.perl.misc:
> On 24 Feb 2005 14:13:47 GMT,
> 	Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> > Dimitri Papoutsis  <bastard@uni-koblenz.de> wrote in comp.lang.perl.misc:
> >
> >> Definition: Pseudo-trial: 
> >>         not even tried to do sth. but babbling as if...
> >
> > A trial is an experiment (if it isn't an interrogation).  The word you
> > want is "attempt".
> 
> A lot of common usage and a few dictionaries disagree with that and
> include "to make an effort to do" as one of the meanings of
> try.

The distinction is exactly what I'm getting at, but that's "try".  "Trial"
appears to have a somewhat specialized meaning.

"To see the effect we tried increasing the voltage" -- "a trial increase" (ok)
"He tried to answer the question" -- "a trial answer" (no)

Then again, there are many dialects of English -- maybe it works in some.

I love this stuff, but it's way off topic.

Anno


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

Date: Thu, 24 Feb 2005 12:01:23 -0500
From: Dan Wilga <dwilga-MUNGE@mtholyoke.edu>
Subject: Re: BerkeleyDB locking question
Message-Id: <dwilga-MUNGE-C19577.12012324022005@nap.mtholyoke.edu>

In article <F4qdnVz0qfBRBIDfRVnyiA@giganews.com>,
 "Mark" <admin@asarian-host.net> wrote:

> -rw-------  1 nobody  nobody     8192 Feb 24 09:54 __db.001
> -rw-------  1 nobody  nobody  1318912 Feb 24 09:54 __db.002
> -rw-------  1 nobody  nobody   368640 Feb 24 09:54 __db.003
> -rw-------  1 nobody  nobody    49152 Feb 24 09:54 whitelist
> 
> The whitelist db only has 10 or so entries in it (for test only, of
> course). Why the huge overhead? "__db.002" almost seems to suggest it

I'm sure Paul or someone else knows the exact purpose of each of these 
files off the top of his head, but I do know they are all necessary, 
mostly for locking. These three don't usually increase in size. 
Different env creation options produce differently-numbered env files.

In general, you shouldn't delete these files unless you find that the DB 
needs to be re-created from scratch, is corrupt, or a process grabbed a 
lock and didn't properly release it. So you really only get a 
performance hit the first time, when the files are actually created.

-- 
Dan Wilga          dwilga-MUNGE@mtholyoke.edu
** Remove the -MUNGE in my address to reply **


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

Date: Thu, 24 Feb 2005 16:35:53 +0000 (UTC)
From: J Krugman <jkrugman345@yahbitoo.com>
Subject: Bizarre precedence quirk (bug?)
Message-Id: <cvkvp9$h1b$1@reader2.panix.com>




I don't know whether this is a bug or what, but it's about the most
bizarre Perl "quirk" (to keep it printable) I've ever come across,
and I've seen my share.  If I run the following Perl script:

  $x = $y = 1;
  $y ||= ($x &&= 0); 
  print "$x\n";

The output is
1

!!!  What on earth is up with THAT???  Just to make sure I was not
losing my mind, I ran this script as well:

  $x = $y = 1;
  ($x &&= 0); 
  print "$x\n";

and the output was empty (undef), as expected.  Why should the &&=
assignment have a different effect depending on whether one prepends
"$y ||= " to it or not?

jill


-- 
To  s&e^n]d  me  m~a}i]l  r%e*m?o\v[e  bit from my a|d)d:r{e:s]s.



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

Date: 24 Feb 2005 08:48:52 -0800
From: "jonnytheclown" <jonny@windmillwalton.demon.co.uk>
Subject: Re: Bizarre precedence quirk (bug?)
Message-Id: <1109263732.827127.320630@l41g2000cwc.googlegroups.com>

It's what I would expect.  In the second line...

$y ||= ($x &&= 0)

$y is already true - so the ($x &&= 0) does not get evaluated - so $x
does not change.

In the second example I would have expected it to print 0 rather than
empty (undef)



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

Date: 24 Feb 2005 17:02:35 GMT
From: xhoster@gmail.com
Subject: Re: Bizarre precedence quirk (bug?)
Message-Id: <20050224120235.366$3I@newsreader.com>

J Krugman <jkrugman345@yahbitoo.com> wrote:
> I don't know whether this is a bug or what, but it's about the most
> bizarre Perl "quirk" (to keep it printable) I've ever come across,
> and I've seen my share.  If I run the following Perl script:
>
>   $x = $y = 1;
>   $y ||= ($x &&= 0);
>   print "$x\n";
>
> The output is
> 1
>
> !!!  What on earth is up with THAT???

If you used:

$y or $y=($x &&= 0);

What would you have expected to happen?  Why would expect your version
to do something different than my version?


> Just to make sure I was not
> losing my mind, I ran this script as well:
>
>   $x = $y = 1;
>   ($x &&= 0);
>   print "$x\n";
>
> and the output was empty (undef), as expected.

Uh, I think you *are* losing your mind.  I get zero, not empty or undef.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Thu, 24 Feb 2005 17:30:06 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Bizarre precedence quirk (bug?)
Message-Id: <Xns96077F2D230A8asu1cornelledu@127.0.0.1>

J Krugman <jkrugman345@yahbitoo.com> wrote in news:cvkvp9$h1b$1
@reader2.panix.com:

> I don't know whether this is a bug or what,

About 20 years ago, when I was still didling around with my trusty ZX 
Spectrum (and trust me, that machine had bugs), I decided that it was 
always more effective to assume that unexpected output generated by the 
computer was my fault. This assumption has not been violated (at least 
for me) since then.

>   $x = $y = 1;
>   $y ||= ($x &&= 0); 

The short-circuit behavior of logical operators is well documented. In 
fact, you use it every time you open a file:

open(my $file, '<', 'filename') || die $!;

If || did not short-circuit, code like this would be impossible to 
write. 

So, in the expression above, $y is already true. The rest is not 
evaluated.

> print "$x\n";
> The output is
> 1
> 
> !!!  What on earth is up with THAT???  

Please, spare the yelling. Go back and take a look at perldoc perlop:

C-style Logical Or
 Binary "||" performs a short-circuit logical OR operation. That is, if
 the left operand is true, the right operand is not even evaluated.

Of course, instead of printing 1, I would have preferred that your 
computer slapped you for using such an expression in the first place. 
Are you trying to trip up future readers of your code? What is wrong 
with:

$x &&= 0;
$y ||= $x;


>   $x = $y = 1;
>   ($x &&= 0); 
>   print "$x\n";
> 
> and the output was empty (undef), as expected.

How can that be?

#! /usr/bin/perl

use strict;
use warnings;

my $x = my $y = 1;

$x &&= 0;

print "$x\n";

__END__

C:\Temp> p
0

> Why should the &&=  assignment have a different effect depending on 
> whether one prepends "$y ||= " to it or not?

Because that's how those operators are defined to work.

Sinan


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

Date: 24 Feb 2005 17:50:09 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Bizarre precedence quirk (bug?)
Message-Id: <slrnd1s4uh.p92.abigail@alexandra.abigail.nl>

J Krugman (jkrugman345@yahbitoo.com) wrote on MMMMCXCV September MCMXCIII
in <URL:news:cvkvp9$h1b$1@reader2.panix.com>:
<>  
<>  
<>  
<>  I don't know whether this is a bug or what, but it's about the most
<>  bizarre Perl "quirk" (to keep it printable) I've ever come across,
<>  and I've seen my share.  If I run the following Perl script:
<>  
<>    $x = $y = 1;
<>    $y ||= ($x &&= 0); 
<>    print "$x\n";
<>  
<>  The output is
<>  1
<>  
<> !!!  What on earth is up with THAT???  Just to make sure I was not
<>  losing my mind, I ran this script as well:
<>  
<>    $x = $y = 1;
<>    ($x &&= 0); 
<>    print "$x\n";
<>  
<>  and the output was empty (undef), as expected.  Why should the &&=
<>  assignment have a different effect depending on whether one prepends
<>  "$y ||= " to it or not?


Because if you have

    $y ||= EXPRESSION;

EXPRESSION is not evaluated if $y is true. Your program is equivalent to:

    $x = $y = 1;
    unless ($y) {
        if ($x) {$x = 0}
        $y = 0;
    }
    print "$x\n";


However, since $y is true, no assignment to $x is done.



Abigail
-- 
perl -wle 'eval {die [[qq [Just another Perl Hacker]]]};; print
           ${${${@}}[$#{@{${@}}}]}[$#{${@{${@}}}[$#{@{${@}}}]}]'


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

Date: Thu, 24 Feb 2005 18:11:56 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Bizarre precedence quirk (bug?)
Message-Id: <MNoTd.62949$8a6.40804@trndny09>

"J Krugman" <jkrugman345@yahbitoo.com> wrote in message
news:cvkvp9$h1b$1@reader2.panix.com...
> I don't know whether this is a bug or what, but it's about the most
> bizarre Perl "quirk" (to keep it printable) I've ever come across,
> and I've seen my share.  If I run the following Perl script:
>
>   $x = $y = 1;
>   $y ||= ($x &&= 0);
>   print "$x\n";
>
> The output is
> 1

All of the OP= operators are defined so that
$x OP= $y
is equivalent to
$x = $x OP $y

Therefore, your example expands to:
$y = $y || ($x = $x && 0);

From this, it should be easy to see that since the first operand of ||
is already true, the second operand is never evaluated.

Paul Lalli



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

Date: Thu, 24 Feb 2005 14:52:42 GMT
From: nospam@geniegate.com
Subject: Re: Comparing huge XML Files
Message-Id: <Lucy1109255646213720xacb334@air.tunestar.net>

In: <1109146491.730966.318020@o13g2000cwo.googlegroups.com>, "junnuthala" <junnuthula@yahoo.com> wrote:
>Hello,
>
>Can someone please suggest me a Perl module for comparing huge XML
>Files.
>
>I tried XML::SemanticDiff, but it is taking a lots and lots of time to
>load the XML File nodes, elements and attributes to the Hash.

I suppose the approach I'd take is to "flatten" the document into something
line oriented. Doesn't matter how you do it, so long as you do it consistantly,
stripping out irrelevant stuff. (Like maybe leading and trailing spaces)

Then compare the two flattened documents. (You could place some context
in the flattened document so you'll know where the differences are in the source)

Something like: (With \n, ; and \t escaped):

/ROOT/ELEMENT/ELEMENT/BAR<tab>53<tab>Attr1=A;Attr2=B<tab>Text here.. With \t and \n escaped.

It may be important to sort the attribute names so they appear in the same order. 

Seems to me there are some tools already for flattening XML, I haven't used them 
in awhile though. (No real use for them)

Thats how I'd approach it. Depends on speed -vs- accuracy tradeoffs, for instance
what do you need to do with the differences?

In the above example, if the line is a difference, you could then skip ahead 
in the document to the 53'rd instance of: /ROOT/ELEMENT/ELEMENT/BAR (Or perhaps
just the 53rd element, depending on how you've flattened it)

You're correct, diff by itself won't work. The order of the attributes is irrelevant.

You could use diff after you've flattened it though.

Jamie
-- 
http://www.geniegate.com                    Custom web programming
guhzo_42@lnubb.pbz (rot13)                User Management Solutions


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

Date: Thu, 24 Feb 2005 16:11:19 +0100
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Comparing huge XML Files
Message-Id: <Xns9607A4ADEC40Belhber1lidotechnet@62.89.127.66>

nospam@geniegate.com wrote:

> In: <1109146491.730966.318020@o13g2000cwo.googlegroups.com>,
> "junnuthala" <junnuthula@yahoo.com> wrote: 
>>Hello,
>>
>>Can someone please suggest me a Perl module for comparing huge XML
>>Files.
>>
>>I tried XML::SemanticDiff, but it is taking a lots and lots of
>>time to load the XML File nodes, elements and attributes to the
>>Hash. 
> 
> I suppose the approach I'd take is to "flatten" the document into
> something line oriented. [...]


This approach will never be good enough to *really* compare XML 
files.
Consider these two XML snippets:

<A>
  <B>This is element B.</B>
  <C>This is element C.</C>
</A>


<A>
  <C>This is element C.</C>
  <B>This is element B.</B>
</A>


For many purposes these two snippets are exactly the same. Root A has 
two children B and C. If you flatten them out, though, they won't be 
the same. There are hundreds of such things to consider when 
comparing XML.


To the OP: have a look at XML::Twig. It doesn't do comparisons, but 
it has a mechanism for parsing huge XML files which you might find 
useful.


-- 
Cheers,
Bernard


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

Date: Thu, 24 Feb 2005 18:08:25 GMT
From: roger <xrsr@rogerware.com>
Subject: CPAN problem
Message-Id: <Xns960767323BB33rsrrogerwarecom@207.225.159.8>

I've got a freshly installed version of perl 5.6.1 as configured by
the MS Services For Unix (SFU) package.

I'm trying to use the CPAN module to download/install a few things,
like Bundle::libnet and so on, but not having any luck.

I allowed CPAN to autoconfigure itself, by answering no to the first
question it asked when I ran

     perl -MCPAN -e shell


After that, I get a shell, and type the following:


cpan> install Bundle::libnet
LWP not available

  Please, install Net::FTP as soon as possible. CPAN.pm installs it for 
you
  if you just type
      install Bundle::libnet

Issuing "/bin/ftp -n"
usage: lcd local-directory
100% |**************************************************| 95544       
00:01
Bad luck... Still failed!
Can't access URL ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz.


And it repeats that for 2 other files (02packages.details.txt.gz and
03modlist.data.gz)

Then it says:

Could not fetch modules/03modlist.data.gz
Warning: Cannot install Bundle::libnet, don't know what it is.
Try the command

    i /Bundle::libnet/

to find objects with matching identifiers.




However,that URL is valid, and it does in fact download all
three of the files attempted to the current directory where I 
ran the command.

Having never used CPAN before, I don't know if I'm doing something
wrong, or if there is some problem with the vanilla SFU configuration.

Can anyone help?

Thanks




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

Date: Thu, 24 Feb 2005 19:13:36 +0100
From: Robert Sedlacek <phaylon@dunkelheit.at>
Subject: Re: CPAN problem
Message-Id: <pan.2005.02.24.18.13.35.591988@dunkelheit.at>

roger wrote:

> Can anyone help?

Don't you have any mirrors specified for your cpan?

-- 
http://www.dunkelheit.at/

The mind is its own place, and in itself
Can make a heaven of hell, a hell of heaven.  -- Milton, »Paradise Lost«



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

Date: Thu, 24 Feb 2005 18:30:04 GMT
From: nospam@geniegate.com
Subject: Re: Credit cards storage
Message-Id: <Lucy1109266480213720x6b6930@air.tunestar.net>

In: <1109176458.577902.57420@o13g2000cwo.googlegroups.com>, saidev@gmail.com wrote:
>Just want to get some ideas on how everyone store Credit Card
>information into MySQL.  I know I can't use the one way encryption, if
>the customer come back, I won't be able to provide the correct
>information to the bank.  What is the safest way to store user CC
>information?  I'll be modifying an existance Perl program to do this,
>any modules can help me do this?  Thanks.

Don't ever, under any circumstances or any conditions store a credit card
number on a public server. There is no reason to do this.

You may need to check, but I believe it could even be illegal.

If that still doesn't persuade you... you could store only the first few
numbers and bank name, plus a unique "link ID", give the customer
a chance to select by bank name and first few digits via a checkbox
or drop down list.

Store the credit card ## offline, and link up the id with the account
number. Thats a last resort if your boss threatens to fire you or 
something. (Then send him a bill for all the extra hardware it'd take
for the "feature") You might mention that even if it's not illegal now, 
it may soon be with all the identity theft taking place these days.

If your boss *still insists* ask him/her for their credit card ## "for testing"
and see if that stops them. :-)

Personally, it bothers me when a form allows me to use a previous credit card
(even if the full credit card ## isn't shown) because I don't want them storing
it and I don't know how their back-end implementation works. 

It used to give me a sense of security knowing that unless I provided the info,
I could not be charged. You might explain to your boss that this "feature" could
alienate and possibly even drive customers away.

I used to write shopping carts for people, I was truly amazed at how
many people insisted I email the credit ## information *clear text* 
through email after they'd gone through the trouble of installing 
and paying for a secure server. (The golden key basically gave customers
a false sense of security)

This isn't really a perl issue, it's more of a legal/ethical/ecommerce
issue.

Jamie
-- 
http://www.geniegate.com                    Custom web programming
guhzo_42@lnubb.pbz (rot13)                User Management Solutions


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

Date: 24 Feb 2005 16:52:51 GMT
From: xhoster@gmail.com
Subject: Re: glob
Message-Id: <20050224115251.818$wx@newsreader.com>

Jim Keenan <jkeen_via_google@yahoo.com> wrote:
> Emanuele Matli wrote:
> > Hi,
> >
> > I have a problem using glob on my cgi perl program.
> > If I try to call glob twice the program crashes giving one of this
> > errors:
> >
> > *** malloc[2302]: error for object 0xbffffe20: Pointer being
> > reallocated was not allocated
> > Out of memory!
> >
> > *** malloc[2396]: Deallocation of a pointer not malloced: 0x65726c00;
> > This could be a double free(), or free() called with the middle of an
> > allocated block; Try setting environment variable MallocHelp to see
> > tools to help debug
> > Segmentation fault
>
> Are you sure that these are Perl errors?

No, they would be perl errors, not Perl errors.  That is, errors from
the implementation of perl (which is implemented in the C language, and
thus gives C errors, not Perl errors).

> Could you please present the Perl code which is causing the problems?
> We would then have a better chance at diagnosing them.  Thanks.

And version information, too.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 24 Feb 2005 10:35:38 -0800
From: kongyew@w-manager.com
Subject: How to generate random emails?
Message-Id: <1109270138.486458.124370@l41g2000cwc.googlegroups.com>

Hi,

        I would like to test my email server. How can i can generate
random emails with random email address? Does anyone knows any perl
modules that does it?

Thanks.
kongyew@w-manager.com



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

Date: Thu, 24 Feb 2005 19:47:32 +0100
From: Robert Sedlacek <phaylon@dunkelheit.at>
Subject: Re: How to generate random emails?
Message-Id: <pan.2005.02.24.18.47.32.844813@dunkelheit.at>

kongyew wrote:

>         I would like to test my email server. How can i can generate
> random emails with random email address? Does anyone knows any perl
> modules that does it?

1. Generate random data
2. Add '@'.$yourmxdomain;
3. Generate Text (Why?)
4. Send the mail.

Which part is making problems to you?

-- 
http://www.dunkelheit.at/
Thru the darkness of futures past, the magician longs to see.
One chants out between two worlds: Fire, walk with me.
                                     -- Twin Peaks, »Bob«



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

Date: 24 Feb 2005 08:13:40 -0800
From: "jonnytheclown" <jonny@windmillwalton.demon.co.uk>
Subject: How to tell if a subroutine arg is a constant
Message-Id: <1109261620.655225.204100@o13g2000cwo.googlegroups.com>

Is there an easy way to test if a subroutine argument is a constant.

I know it can be done by trying to assign to the specific element in @_
within an eval and testing for an exception but this is a tad ugly -
not to mention inefficient.



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

Date: Thu, 24 Feb 2005 17:22:03 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How to tell if a subroutine arg is a constant
Message-Id: <386dvgF5m0nflU1@individual.net>

jonnytheclown wrote:
> Is there an easy way to test if a subroutine argument is a constant.
> 
> I know it can be done by trying to assign to the specific element in @_
> within an eval and testing for an exception but this is a tad ugly -
> not to mention inefficient.

Not sure what you mean by "constant" in this context. Can't you simply 
use the ref() function?

     sub myfunction {
         for (@_) {
             print "$_ is a constant\n" unless ref;
         }
         ...
     }

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 24 Feb 2005 08:43:11 -0800
From: "jonnytheclown" <jonny@windmillwalton.demon.co.uk>
Subject: Re: How to tell if a subroutine arg is a constant
Message-Id: <1109263391.956573.211900@l41g2000cwc.googlegroups.com>

I'm trying to detect if the caller passed in a literal or a scalar
variable - nothing to do with references, e.g.

foo('xyz');

versus...

$v = 'xyz';
foo($v);

If the caller uses the first syntax then the subroutine will not be
able to modify the argument.  If the second syntax is used then the
argument can be modified within the subroutine.



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

Date: Thu, 24 Feb 2005 18:10:03 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: How to tell if a subroutine arg is a constant
Message-Id: <slrnd1s2jb.1na.tassilo.von.parseval@localhost.localdomain>

Also sprach jonnytheclown:

> Is there an easy way to test if a subroutine argument is a constant.
>
> I know it can be done by trying to assign to the specific element in @_
> within an eval and testing for an exception but this is a tad ugly -
> not to mention inefficient.

This appears to be impossible from pure Perl (at least when avoiding the
method you outlined). With a very little bit of C however, it's easy:

    #! /usr/bin/perl -l

    use Inline C => <<EOC;
    int is_readonly (SV *sv) {
        return SvREADONLY(sv) != 0;
    }
    EOC

    print is_readonly("string");
    print is_readonly($s = "string");
    __END__
    1
    0

Tassilo
-- 
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);


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

Date: Thu, 24 Feb 2005 18:09:56 +0100
From: Robert Sedlacek <phaylon@dunkelheit.at>
Subject: Re: How to tell if a subroutine arg is a constant
Message-Id: <pan.2005.02.24.17.09.55.568141@dunkelheit.at>

jonnytheclown wrote:

> If the caller uses the first syntax then the subroutine will not be able
> to modify the argument.  If the second syntax is used then the argument
> can be modified within the subroutine.

If you just want to make sure you can change the value, you could use
prototypes to tell perl you want a reference:

  phaylon@hamlett:~> perl -Mstrict -Mwarnings
  sub test (\$) {	# prototyped
     print "@_\n";
  }
  my $a = 10;
  test($a);
  test(13);
  ^D
  Type of arg 1 to main::test must be scalar (not constant item) at - line
   6, near "13)"
  Execution of - aborted due to compilation errors.

hth,phay

-- 
http://www.dunkelheit.at/
That is not dead, which can eternal lie,
and with strange aeons even death may die.
		-- H.P. Lovecraft



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

Date: Thu, 24 Feb 2005 17:36:41 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: How to tell if a subroutine arg is a constant
Message-Id: <cvl316$qq4$1@sun3.bham.ac.uk>



jonnytheclown wrote:

> Is there an easy way to test if a subroutine argument is a constant.

Scalar::Util::readonly

> I know it can be done by trying to assign to the specific element in @_
> within an eval and testing for an exception but this is a tad ugly -
> not to mention inefficient.

I would suspect there's something wrong with the API of any subroutine 
that needs this information.



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

Date: 24 Feb 2005 16:39:53 GMT
From: xhoster@gmail.com
Subject: Re: maximum size of a hash table
Message-Id: <20050224113953.547$PZ@newsreader.com>

"Lee" <lskatz@gmail.com> wrote:
> I couldn't find a clear answer to this.  Seems to be a lot of hearsay.
>
> Does anyone absolutely know the maximum size that a hash table can
> achieve?

The maximum size of a hash table is 7 times bigger than the larget possible
skein of yarn.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Thu, 24 Feb 2005 19:42:48 +0200
From: Leslie Viljoen <leslievNO@SPAMicoc.co.za>
Subject: Re: OOP Tutorial
Message-Id: <h9OdnYRSb_LojoPfRVn-2w@is.co.za>

> (snip)
> (I stopped reading after 4/23 pages as I have to go now but I may take 
> another look later)
> 

Thank-you so much for the help!


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

Date: Thu, 24 Feb 2005 19:53:39 +0200
From: Leslie Viljoen <leslievNO@SPAMicoc.co.za>
Subject: Re: OOP Tutorial
Message-Id: <3YydnV-Rjb0-iYPfRVn-2g@is.co.za>

> (snip)
> (I stopped reading after 4/23 pages as I have to go now but I may take 
> another look later)
> 

Thank-you so much for the help!


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

Date: Thu, 24 Feb 2005 20:04:56 +0200
From: Leslie Viljoen <leslievNO@SPAMicoc.co.za>
Subject: Re: OOP Tutorial
Message-Id: <IuSdnaNqO_naioPfRVn-qg@is.co.za>

Anno Siegel wrote:
> Paul Uiterlinden  <no@spam.nl> wrote in comp.lang.perl.misc:
> 
>>Abigail wrote:
>>
>>>$$  http://www.icon.co.za/~mobeus/easyoop.doc.zip      (Word)
>>>$$  http://www.icon.co.za/~mobeus/easyoop.sxw.zip      (Open Office)
>>>
>>>Oh. Never mind. I don't do Windows.
>>
>>Huh? Open office works on *nix, and zip as well.
> 
> 
> Abigail didn't say she can't, she said she doesn't.

Yes but you don't need to do Windows for Open Office. I use Linux almost
exclusively - that's why I created an SXW file. I saved it as a DOC too
in case a Windows person wants to read it.

Leslie


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

Date: Thu, 24 Feb 2005 19:08:38 +0100
From: Robert Sedlacek <phaylon@dunkelheit.at>
Subject: Re: OOP Tutorial
Message-Id: <pan.2005.02.24.18.08.38.655206@dunkelheit.at>

Leslie Viljoen wrote:

> I saved it as a DOC too in case a Windows person wants to read it.

They count?
SCNR :D

-- 
http://www.dunkelheit.at/
I want, therefore I can.



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

Date: Thu, 24 Feb 2005 18:27:31 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: OOP Tutorial
Message-Id: <Pine.LNX.4.61.0502241826460.28834@ppepc56.ph.gla.ac.uk>

On Thu, 24 Feb 2005, Robert Sedlacek wrote:

> Leslie Viljoen wrote:
> 
> > I saved it as a DOC too in case a Windows person wants to read it.
> 
> They count?
> SCNR :D

No, they Start > Accessories > Calculator

(SCNR either)


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

Date: 24 Feb 2005 19:01:23 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: OOP Tutorial
Message-Id: <slrnd1s943.p92.abigail@alexandra.abigail.nl>

Leslie Viljoen (leslievNO@SPAMicoc.co.za) wrote on MMMMCXCV September
MCMXCIII in <URL:news:IuSdnaNqO_naioPfRVn-qg@is.co.za>:
}}  Anno Siegel wrote:
}} > Paul Uiterlinden  <no@spam.nl> wrote in comp.lang.perl.misc:
}} > 
}} >>Abigail wrote:
}} >>
}} >>>$$  http://www.icon.co.za/~mobeus/easyoop.doc.zip      (Word)
}} >>>$$  http://www.icon.co.za/~mobeus/easyoop.sxw.zip      (Open Office)
}} >>>
}} >>>Oh. Never mind. I don't do Windows.
}} >>
}} >>Huh? Open office works on *nix, and zip as well.
}} > 
}} > 
}} > Abigail didn't say she can't, she said she doesn't.
}}  
}}  Yes but you don't need to do Windows for Open Office. I use Linux almost
}}  exclusively - that's why I created an SXW file. I saved it as a DOC too
}}  in case a Windows person wants to read it.


Why would you need open office if you don't do Windows?

I'll read plain text, POD, (La)TeX (in order of preference), and I might
be bothered to start up a reader for a dvi, PostScript, PDF or an HTML
file. That's about it.



Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


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

Date: 24 Feb 2005 07:45:33 -0800
From: peter.lewerin@swipnet.se (Peter Lewerin)
Subject: Re: OT: Re: standard mode for arrow down
Message-Id: <b72f3640.0502240745.7cfbf2c@posting.google.com>

RedGrittyBrick <Red.Grittybrick@SpamWeary.Foo> wrote

> (Apologies for feeding the troll).

Troll?  I'd have expected a _wight_ at the Arrow Downs.


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

Date: Thu, 24 Feb 2005 12:13:46 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: OT: Re: standard mode for arrow down
Message-Id: <XdidnfDWPoPXloPfRVn-gQ@comcast.com>

Peter Lewerin wrote:

> RedGrittyBrick <Red.Grittybrick@SpamWeary.Foo> wrote
> 
>> (Apologies for feeding the troll).
> 
> Troll?  I'd have expected a _wight_ at the Arrow Downs.

Where's Tom Bombadil when you need him?
-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


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

Date: Thu, 24 Feb 2005 20:19:34 +0200
From: Leslie Viljoen <leslievNO@SPAMicoc.co.za>
Subject: That sig
Message-Id: <q7Wdna2rMcQmh4PfRVn-uw@is.co.za>

perl -wle 'eval {die [[qq [Just another Perl Hacker]]]};; print
            ${${${@}}[$#{@{${@}}}]}[$#{${@{${@}}}[$#{@{${@}}}]}]'

Abigail?
How on earth does this work?


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

Date: 24 Feb 2005 18:55:44 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: That sig
Message-Id: <slrnd1s8pg.p92.abigail@alexandra.abigail.nl>

Leslie Viljoen (leslievNO@SPAMicoc.co.za) wrote on MMMMCXCV September
MCMXCIII in <URL:news:q7Wdna2rMcQmh4PfRVn-uw@is.co.za>:
==  perl -wle 'eval {die [[qq [Just another Perl Hacker]]]};; print
==              ${${${@}}[$#{@{${@}}}]}[$#{${@{${@}}}[$#{@{${@}}}]}]'
==  
==  Abigail?
==  How on earth does this work?


It's a simple matter of dereferencing, and getting the last element
of the last element of a two-dimensional array.

I'm just not using any shortcuts, like arrows, negative indices, or
omitting braces.


Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


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

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 7824
***************************************


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