[18618] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 786 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 27 21:10:35 2001

Date: Fri, 27 Apr 2001 18:10:15 -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: <988420214-v10-i786@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 27 Apr 2001     Volume: 10 Number: 786

Today's topics:
    Re: creating an array of all filenames <ren@tivoli.com>
    Re: creating an array of all filenames (Randal L. Schwartz)
    Re: creating an array of all filenames (Abigail)
    Re: dynamic creation of classes? (Anno Siegel)
    Re: Finding all elements in an array matching a certian <krahnj@acm.org>
        First and last element in list loop <gtoomey@usa.net>
    Re: First and last element in list loop <sharding@ccbill.com>
    Re: First and last element in list loop (Anno Siegel)
    Re: First and last element in list loop <vmurphy@Cisco.Com>
    Re: First and last element in list loop (Anno Siegel)
    Re: First and last element in list loop <vmurphy@Cisco.Com>
        help me <renes@hot.ee>
    Re: help me <bwalton@rochester.rr.com>
        Help <hafateltec@hotmail.com>
    Re: How to down size /usr/bin/perl ? (Logan Shaw)
    Re: How to down size /usr/bin/perl ? <bart.lateur@skynet.be>
    Re: How to down size /usr/bin/perl ? (Randal L. Schwartz)
    Re: Levels of perl programming <gtoomey@usa.net>
    Re: match a range of number (Martien Verbruggen)
    Re: operators: != vs. ne, strange behaviour <ren@tivoli.com>
    Re: Perl compete: Java is dead on server side!! PHP is  <dot-common-sense@lineone.net>
    Re: Perl compete: Java is dead on server side!! PHP is  (Harold Sasaki)
    Re: Please help <krahnj@acm.org>
    Re: Regular expression for zip code (Anno Siegel)
    Re: Regular expression for zip code <xris@dont.send.spam>
    Re: Running Command Line Commands <sh0t2bts@hotmail.com>
    Re: So what do YOU use Perl for? <bchambless@nrlssc.navy.nil>
        Storing the CGI object in my module? <pottschmidtr@appstate.edu>
    Re: Strange string -> num conversion (Anno Siegel)
    Re: Strange string -> num conversion <ren@tivoli.com>
    Re: Strange string -> num conversion <ren@tivoli.com>
    Re: Strange string -> num conversion (Anno Siegel)
    Re: WI Performance Hit w/ Hash || Array v Scalar? <ren@tivoli.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 27 Apr 2001 18:16:30 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: creating an array of all filenames
Message-Id: <m3pudyorw1.fsf@dhcp9-172.support.tivoli.com>

On Fri, 27 Apr 2001, magrav@wnt.sas.com wrote:

> I'm trying to create an array that contains all of the filenames in
> a directory tree (recursive).  I'm almost there.  The below function
> is called with the directory where to start looking.

First, File::Find almost certainly does what you want, and you don't
even have to install it.

> sub get_files{
> 
> 	# the next three lines gets all files (and directories) in the
> dir	
> 	$local_dir = $_[0];
> 	opendir(DIR, $local_dir) || die "can't opendir $local_dir:
> $!";
> 	@file_collection = (@file_collection, grep(!/^\.\.?$/,
> readdir(DIR)));
> 		
> 	foreach (@file_collection) {
> 		if (-d $local_dir . "\\" . $_) {
> 			get_files($local_dir . "\\" . $_); 
> 		}
> 	}
> }
> 
> 
> Does anyone see what the problem is?

Which one?  There are several.

You don't have any local variables so your recursive calls are just
going to stomp all over their values.

Interestingly (well, to me anyway), you don't have the most common
problem, which is that the DIRHANDLE gets trashed by the recursion.
The reason you don't have this problem is that you are doing the
readdir all at once before recursing, so you're actually done with the
DIRHANDLE by the time you recurse.

The biggest problem you have is with @file_collection.  You're
iterating over it, but then adding to it within the foreach.  That's a
big no-no.  From perlsyn(1):

       If any part of LIST is an array, `foreach' will get very
       confused if you add or remove elements within the loop
       body, for example with `splice'.   So don't do that.

I'd fix it for you, but you should really just use File::Find...

perl -MFile::Find -e 'find sub { /^\.\.?$/ or print "$_ " }, "/tmp"'

-- 
Ren Maddox
ren@tivoli.com


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

Date: 27 Apr 2001 17:20:32 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: creating an array of all filenames
Message-Id: <m1itjpzxgv.fsf@halfdome.holdit.com>

>>>>> "Jon" == Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov> writes:

Jon> Max Gravitt <magrav@wnt.sas.com> writes:
>> I'm trying to create an array that contains all of the filenames in a
>> directory tree (recursive).  I'm almost there.  The below function is
>> called with the directory where to start looking.

Jon> Any reason you're not using File::Find?

Usually because it's homework. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Sat, 28 Apr 2001 00:54:07 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: creating an array of all filenames
Message-Id: <slrn9ek55f.mm6.abigail@tsathoggua.rlyeh.net>

Randal L. Schwartz (merlyn@stonehenge.com) wrote on MMDCCXCVII September
MCMXCIII in <URL:news:m1itjpzxgv.fsf@halfdome.holdit.com>:
)) >>>>> "Jon" == Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov> writes:
))  
)) Jon> Max Gravitt <magrav@wnt.sas.com> writes:
)) >> I'm trying to create an array that contains all of the filenames in a
)) >> directory tree (recursive).  I'm almost there.  The below function is
)) >> called with the directory where to start looking.
))  
)) Jon> Any reason you're not using File::Find?
))  
))  Usually because it's homework. :)


Heh, I was once given a similar question during a job interview.
There was a white board and a marker to write down the program. ;-)



Abigail
-- 
map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;        
print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";


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

Date: 27 Apr 2001 23:28:07 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: dynamic creation of classes?
Message-Id: <9ccva7$qdt$1@mamenchi.zrz.TU-Berlin.DE>

According to F. Xavier Noria <fxn@isoco.com>:
> Is there a way to create classes dynamically? Something with
> this semantics?
> 
>    $class = 'Foo::Bar';

This assignment happens at run time. That would be too late...

>    use $class;

 ...even if this worked.  "use" happens at compile time.

>    $object = $class->new;

I'll assume that with "dynamically" (a word so overused, it hardly
has any meaning without context) you mean that you want to store
the class name in a variable and later "use" that class.

As you probably have discovered, Perl syntax allows only a bare
module name after "use", but you can resort to its cousin "require",
which allows a file name (relative to @INC) given in any form.

This means that you must translate class "Foo::Bar" to "Foo/Bar.pm"
or whatever transition your system requires (trivial on any one
system, a bit tricky when it must be portable):

    $class =~ s!::!/!g;  $class .= '.pm';
    require $class;

Note that unlike "use", "require" happens at run time.  You may
want to wrap it in a BEGIN block, along with the setup of $class.
Since you are apparently using an object oriented module, import
semantics will probably not be an issue.  The exact relationship
of "use" and "require" is available through perldoc -f use.

Anno



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

Date: Fri, 27 Apr 2001 23:01:34 GMT
From: John W Krahn <krahnj@acm.org>
Subject: Re: Finding all elements in an array matching a certian criteria
Message-Id: <3AE984FE.F00065BC@acm.org>

nobull@mail.com wrote:
> 
> tadmc@augustmail.com (Tad McClellan) writes:
> 
> >    my @wanted = grep { /^$pattern/ } @allfiles;
> 
> I think you meant:
> 
> my @wanted = grep { /^($pattern)_/ } @allfiles;

I think he meant:

my @wanted = grep { /^${pattern}_/ } @allfiles;


John


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

Date: Sat, 28 Apr 2001 08:23:58 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: First and last element in list loop
Message-Id: <P6mG6.12804$482.64729@newsfeeds.bigpond.com>

When using the list loop context
for (@list)
  {  .... }

is there an easy way to test for the first and last element in the loop.
Something like $_.first or $.last?

One alternative is to use
foreach $i {0 .. $#list)
{ ... }

and test $i, but this introduces a new variable $i and is a bit clunky.

This there an elegant Perl solution for this?

gtoomey




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

Date: Fri, 27 Apr 2001 16:34:55 -0700
From: "Shay Harding" <sharding@ccbill.com>
Subject: Re: First and last element in list loop
Message-Id: <9ccv61$13m8$1@node17.cwnet.frontiernet.net>

"Gregory Toomey" <gtoomey@usa.net> wrote in message
news:P6mG6.12804$482.64729@newsfeeds.bigpond.com...
> When using the list loop context
> for (@list)
>   {  .... }
>
> is there an easy way to test for the first and last element in the loop.
> Something like $_.first or $.last?
>
> One alternative is to use
> foreach $i {0 .. $#list)
> { ... }
>
> and test $i, but this introduces a new variable $i and is a bit clunky.
>
> This there an elegant Perl solution for this?
>
> gtoomey

Not really sure what you are asking here. What kind of test? Exist, truth,
ref, etc?

If you just want to do an exist test (something there) then just test if the
array is not empty. If it has values (any number of values) there will be a
'first' and 'last' index. If only one item is in the array then 'first' =
'last'.

The first element in the array would be $list[0], while the last element
would be $list[-1].

Without knowing exactly what you are trying to accomplish I can't really
help much more than this.


Shay









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

Date: 27 Apr 2001 23:43:24 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: First and last element in list loop
Message-Id: <9cd06s$qtc$1@mamenchi.zrz.TU-Berlin.DE>

According to Shay Harding <sharding@ccbill.com>:
> "Gregory Toomey" <gtoomey@usa.net> wrote in message
> news:P6mG6.12804$482.64729@newsfeeds.bigpond.com...
> > When using the list loop context
> > for (@list)
> >   {  .... }
> >
> > is there an easy way to test for the first and last element in the loop.
> > Something like $_.first or $.last?
> >
> > One alternative is to use
> > foreach $i {0 .. $#list)
> > { ... }
> >
> > and test $i, but this introduces a new variable $i and is a bit clunky.
> >
> > This there an elegant Perl solution for this?
> >
> > gtoomey
> 
> Not really sure what you are asking here. What kind of test? Exist, truth,
> ref, etc?

[...]

"...test for the first and last element in the loop" seems pretty
clear to me.  The OP wants to know, inside the loop, when he is
processing the first and/or last element.

There is no "elegant" solution for that in Perl.  Even if you happen
to have a list with unique elements, testing for "$_ eq @list[ 0]" or 
"$_ eq @list[ -1]" is hardly elegant.  Use a counter, as proposed.

Maybe one day we will get $# to mean the loop index in foreach.  Then
this will be more convenient.

If you only need to test for the last element, you may detect traces
of elegance in

    while ( @list ) {
        my $i = shift @list;
        unless ( @list ) {
            # $i is the last element
        }
        ...
    }

Anno


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

Date: 27 Apr 2001 20:22:24 -0400
From: Vinny Murphy <vmurphy@Cisco.Com>
Subject: Re: First and last element in list loop
Message-Id: <m3d79x3mbj.fsf@vpnrel.cisco.com>

"Gregory Toomey" <gtoomey@usa.net> writes:

> When using the list loop context
> for (@list)
>   {  .... }
> 
> is there an easy way to test for the first and last element in the loop.
> Something like $_.first or $.last?

Something like:

my @a = ( "A" .. "Z");
for ( @a ) {
  print "first " if $a[0]  eq $_;
  print "last "  if $a[-1] eq $_;
  print "$_\n";
}

> 
> One alternative is to use
> foreach $i {0 .. $#list)
> { ... }
> 
> and test $i, but this introduces a new variable $i and is a bit clunky.
> 
> This there an elegant Perl solution for this?
> 
> gtoomey
> 
> 

-- 
Vinny


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

Date: 28 Apr 2001 00:25:51 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: First and last element in list loop
Message-Id: <9cd2mf$qtc$5@mamenchi.zrz.TU-Berlin.DE>

According to Vinny Murphy  <vmurphy@Cisco.Com>:
> "Gregory Toomey" <gtoomey@usa.net> writes:
> 
> > When using the list loop context
> > for (@list)
> >   {  .... }
> > 
> > is there an easy way to test for the first and last element in the loop.
> > Something like $_.first or $.last?
> 
> Something like:
> 
> my @a = ( "A" .. "Z");

what about @a = ( 1 ) x 100; ?

> for ( @a ) {
>   print "first " if $a[0]  eq $_;
>   print "last "  if $a[-1] eq $_;
>   print "$_\n";
> }

This is only an option if all enelemets in the list are distinct.

Anno


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

Date: 27 Apr 2001 21:03:14 -0400
From: Vinny Murphy <vmurphy@Cisco.Com>
Subject: Re: First and last element in list loop
Message-Id: <m38zkl3kfh.fsf@vpnrel.cisco.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:

> According to Vinny Murphy  <vmurphy@Cisco.Com>:
> > "Gregory Toomey" <gtoomey@usa.net> writes:
> > 
> > > When using the list loop context
> > > for (@list)
> > >   {  .... }
> > > 
> > > is there an easy way to test for the first and last element in the loop.
> > > Something like $_.first or $.last?
> > 
> > Something like:
> > 
> > my @a = ( "A" .. "Z");
> 
> what about @a = ( 1 ) x 100; ?
> 
> > for ( @a ) {
> >   print "first " if $a[0]  eq $_;
> >   print "last "  if $a[-1] eq $_;
> >   print "$_\n";
> > }
> 
> This is only an option if all enelemets in the list are distinct.

What was I thinking  - of course this only applies to distinct lists.

-- 
Vinny


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

Date: Sat, 28 Apr 2001 02:53:13 +0300
From: "RS" <renes@hot.ee>
Subject: help me
Message-Id: <3aea065e@news.estpak.ee>

HI

I 'm writing counter for my site and I would like to log my guests display
settings (resolution).

Is this possible???

I have Apache -> UNIX

stuffweb@hot.ee




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

Date: Sat, 28 Apr 2001 00:55:46 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: help me
Message-Id: <3AEA157A.1C65BD86@rochester.rr.com>

RS wrote:
 ...
> I 'm writing counter for my site and I would like to log my guests display
> settings (resolution).
> 
> Is this possible???
> 
> I have Apache -> UNIX
> 
> stuffweb@hot.ee
perldoc -q increment the counter


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

Date: Sat, 28 Apr 2001 10:01:26 +1000
From: "Michael R. McPherson" <hafateltec@hotmail.com>
Subject: Help
Message-Id: <9cd1hg02181@enews3.newsguy.com>

I know this is a bit off topic but I really am lost on this.  I am trying to
install DBD::ODBC yet I always fail with this error below when I try to run
tests.
I am using OpenLink with iodbc which I ran the odbctest on and it passes so
I know that I have my OpenLink installed.  I also looked in the MS access
database which I use as my DSN for testing the DBD::ODBC before I install it
and it has the data from the test in it.  I have
ODBCHOME=/home/mydir/openlink, DBI_PASS, DBI_USER,DBI_DSN=dbi:ODBC:demo all
in my environment before I run perl Makefile.PL.  Somebody out there has to
have had this problem before so could you PLEASE help me out and let me know
what you did to get this installed and WORK correctly.

ps. feel free to e-mail directly if this is to off topic

Thanks




PERL_DL_NONLAZY=1
/usr/local/bin/perl -Iblib/arch -Iblib/lib -I/usr/local/lib/pe
rl5/5.6.1/i686-linux -I/usr/local/lib/perl5/5.6.1 -e 'use Test::Harness
qw(&runt
ests $verbose); $verbose=0; runtests @ARGV;' t/*.t
t/01base............ok
t/02simple..........dubious
        Test returned status 0 (wstat 11, 0xb)
DIED. FAILED tests 13-14
        Failed 2/14 tests, 85.71% okay
t/03dbatt...........ok
t/05meth............ok
t/09bind............ok
Failed Test  Status Wstat Total Fail  Failed  List of Failed
----------------------------------------------------------------------------
----
t/02simple.t       0    11    14    2  14.29%  13-14
Failed 1/5 test scripts, 80.00% okay. 2/40 subtests failed, 95.00% okay.
make: *** [test_dynamic] Error 29




--
##############Þ
print "\n Welcome to NEPP";$Þ=1;while ($Þ){
print "\n$Þ";$Þ++;if ($Þ == 1000) {
print "\n$Þ"."\nWell almost never ending :þ";exit;}}
##############Þ




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

Date: 27 Apr 2001 17:14:48 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: How to down size /usr/bin/perl ?
Message-Id: <9ccr0o$nog$1@daggoo.cs.utexas.edu>

In article <9ccblp$d1f$3@mamenchi.zrz.TU-Berlin.DE>,
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>According to Logan Shaw <logan@cs.utexas.edu>:
>> Boy, I hope it doesn't take that long.  In the fall, I'm planning to
>> take a compilers class in which (I'm told) I will get to write my own
>> compiler (for Pascal, yippie), and this takes only a semester.
>
>That doesn't involve designing Pascal.

No, it doesn't, but this isn't the 1960's, and Pascal has already been
designed, as have lots of other languages that are better than Pascal.

It seems to me that language design today is mostly about coming up
with a few good ideas and stealing everything else from whatever
languages you like.

First, you've got to decide whether the C/C++/Perl/Java family of
syntaxes is wonderful and the Algol/Pascal/Modula-2/Ada family is evil,
or vice versa.  Then you decide whether you want to misuse the ascii
character set as much as possible, or whether you want to engage in a
pyrrhic effort to make your syntax as much like some other notation
(i.e. mathematical formulas) as possible, or whether you just want
everything to be words (because words are by definition easy to
understand, whereas special purpose symbols are by definition difficult
to remember and understand[1])[2].

Oh yeah, and then you have to decide on bondage and discipline vs. not
giving the compiler any way of detecting obvious problems in your
code.  You probably *don't* have to decide on lexically vs. dynamically
scoped variables, though, since it seems that people who decide on the
latter live to regret it.  (At least some of them call it an
unfortunate design decision instead of a bug.)

  - Logan

[1]  This still applies even if the easy-to-remember word stands for an
     arbitrary symbol, like say "lambda".

[2]  And because you want the syntax to be as simple as possible.  On
     the first level.  On the second level, you wind up with all kinds
     of idiomatic syntax that doesn't count as complexity (even though
     you still to have to learn it) because it isn't technically part
     of the core language's syntax.
-- 
my  your   his  her   our   their   _its_
I'm you're he's she's we're they're _it's_


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

Date: Fri, 27 Apr 2001 23:00:47 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How to down size /usr/bin/perl ?
Message-Id: <ahujetkle978vro20p2spul27c1e530ri3@4ax.com>

Pally Kuo wrote:

>I wanna down size perl interpreter /usr/bin/perl
>the original size is about 502k
>I must make it to below 200k, in order to post into flash rom...
>Is there any way to do that ?

You can use another language. Lua, for example.
<http://www.tecgraf.puc-rio.br/lua/about.html>.

-- 
	Bart.


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

Date: 27 Apr 2001 17:18:23 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: How to down size /usr/bin/perl ?
Message-Id: <m1pudxzxkg.fsf@halfdome.holdit.com>

>>>>> "Logan" == Logan Shaw <logan@cs.utexas.edu> writes:

Logan> First, you've got to decide whether the C/C++/Perl/Java family of
Logan> syntaxes is wonderful and the Algol/Pascal/Modula-2/Ada family is evil,
Logan> or vice versa.

Well, before that, you need to decide whether the Smalltalk-ish, Prolog-ish,
Algol-ish, or Lisp-ish families are appropriate first.

:-)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Sat, 28 Apr 2001 08:32:42 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: Levels of perl programming
Message-Id: <0fmG6.12806$482.64609@newsfeeds.bigpond.com>

It's quite funny too!!

gtoomey
--------
"Samuel Thomas" <sthomas@ws5120.nc.fnc.fujitsu.com> wrote in message
news:tl6hezayyt3.fsf@ws5120.nc.fnc.fujitsu.com...
> tadmc@augustmail.com (Tad McClellan) writes:
>
>
> ...only a few more things to do before i hit expert :)
>
> --
>                 /\
> Sam Thomas     /  \     "hello, sailor"
> Ext 1161      / ** \    Nothing happens here.
>      /______\




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

Date: Sat, 28 Apr 2001 10:54:34 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: match a range of number
Message-Id: <slrn9ek56a.hic.mgjv@martien.heliotrope.home>

On Wed, 25 Apr 2001 21:43:20 -0000,
	Craig Berry <cberry@cinenet.net> wrote:
> Eric Bohlman (ebohlman@omsdev.com) wrote:
>: > Is there some magic reason you don't need to pass @_ on the recursive
>: > call?  I'm almost remembering something like that, but can't quite put my
>: > finger on it.
>: 
>: Leading ampersand and no parens cause the call to inherit @_ from the 
>: caller.
> 
> Thanks!  That was going to drive me crazy.  Couldn't find it in the docs.

# man perlsub
[snip]
       To call subroutines:

           NAME(LIST);    # & is optional with parentheses.
           NAME LIST;     # Parentheses optional if predeclared/imported.
           &NAME(LIST);   # Circumvent prototypes.
           &NAME;         # Makes current @_ visible to called subroutine.
[snip]
       Subroutines may be called recursively.  If a subroutine is
       called using the "&" form, the argument list is optional,
       and if omitted, no "@_" array is set up for the subrou­
       tine: the "@_" array at the time of the call is visible to
       subroutine instead.  This is an efficiency mechanism that
       new users may wish to avoid.
[snip]

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | life ain't fair, but the root
Commercial Dynamics Pty. Ltd.   | password helps. -- BOFH
NSW, Australia                  | 


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

Date: 27 Apr 2001 16:53:43 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: operators: != vs. ne, strange behaviour
Message-Id: <m3ae52qaag.fsf@dhcp9-172.support.tivoli.com>

On Fri, 27 Apr 2001, eins@durchnull.de wrote:

> perl -e "print 1e300 * 1e300";

That gives "1.#INF".

> The same -1.#IND or something else? Maybe they are really NaN and 
> INF but ActivePerl does not support them (the FPU does, and AP does 
> not check).

I'd say that's a pretty good theory.

Looks like:

-1.#IND <==> NaN <==> nan <==> NaNQ
1.#INF <==> INF <==> inf

-- 
Ren Maddox
ren@tivoli.com


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

Date: Fri, 27 Apr 2001 23:33:33 +0100
From: "Dot Common Sense" <dot-common-sense@lineone.net>
Subject: Re: Perl compete: Java is dead on server side!! PHP is 4 times faster than  JSP,CF,ASP!!
Message-Id: <9ccs49$asp$1@taliesin.netcom.net.uk>

Mmmm. I'm not so sure.

--
----------------------------------------------------------------------------
--
Used vinyl & Cd's at:
http://www.dot-common-sense.co.uk/blackplastic
"Al Dev" <alavoor@yahoo.com> wrote in message
news:3AE989C9.15E45560@yahoo.com...
> Perl competetion: Java is dead on server side!! PHP is 4 times faster
> than JSP,CF,ASP!!
>
> PHP is born from "Perl + Java" and is the fastest growing language in
> the world!!
> PHP is object oriented. Analogy is perl is "C" and PHP is "C++" !!
>
> PHP is the fastest web-scripting language and is 4 times faster than
> JSP(Java
> Server Pages). PHP is becoming new "Java language", it is getting all
> the Java
> keywords like class, extends, implements, interface, inner classes etc..
>
> What is the purpose of java on server side programming if PHP is
> java-like
> and is 4 times faster???
>
> The benchmark says PHP is faster than ASP and ASP faster than
> ColdFusion..
> The order is : PHP > ASP > CF > JSP
> The JSP is the worst!! It is the slowest of all technology!!
>
> Read the benchmarks in "PHP howto" given at
>   http://aldev.8m.com
> and due to heavy traffic go to mirror sites at
>   http://aldev.webjump.com
>   http://www.angelfire.com/nv/aldev
>   http://www.geocities.com/alavoor/index.html
>   http://aldev.virtualave.net
>   http://aldev.bizland.com
>   http://members.theglobe.com/aldev/index.html
>   http://members.nbci.com/alavoor
>   http://aldev.terrashare.com
>   http://members.fortunecity.com/aldev
>   http://aldev.freewebsites.com
>   http://members.tripod.lycos.com/aldev
>   http://members.spree.com/technology/aldev
>   http://www3.bcity.com/aldev
>
> Go to one of these sites and click on PHP howto.
>




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

Date: Sat, 28 Apr 2001 00:37:39 +0000 (UTC)
From: hsasaki@harold.com (Harold Sasaki)
Subject: Re: Perl compete: Java is dead on server side!! PHP is 4 times faster than  JSP,CF,ASP!!
Message-Id: <9cd3cj$dkt$1@nntp1.ba.best.com>

In comp.lang.perl.modules Al Dev <alavoor@yahoo.com> wrote:

=> The order is : PHP > ASP > CF > JSP
=> The JSP is the worst!! It is the slowest of all technology!!

How were these tests done?  Isn't JSP cached as a servlet and put into
servlet memory and ASP is interpreted on the fly?

Isn't JSP the most flexible in terms of separating design and business
logic and for reusing beans?

-- 
-----
Harold Sasaki


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

Date: Fri, 27 Apr 2001 23:55:37 GMT
From: John W Krahn <krahnj@acm.org>
Subject: Re: Please help
Message-Id: <3AE991AE.208A9536@acm.org>

Benjamin Goldberg wrote:
> 
> Actually...
> perl -e 'print map { $_ % 10 ? "$_, " : "tenth\n" } ( 101 .. 150 )'
> You have an anonymous sub here ^^^, and you have an array here ^^^.
> And the result of map is also an array.

I think that you are confused about the difference between a list and an
array. :-)

perldoc -q 'difference between a list and an array'


John


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

Date: 27 Apr 2001 22:26:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regular expression for zip code
Message-Id: <9ccrn9$ilk$3@mamenchi.zrz.TU-Berlin.DE>

According to xris  <xris@dont.send.spam>:
> In article <9cch18$gfu$3@mamenchi.zrz.TU-Berlin.DE>,
>  anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> 
> > Look closer.  No speedup is to be expected as long as the regex in
> > question doesn't contain variables to be interpolated.
> 
> ah, ok...  the wording in the Perl book made me think that the 
> compiler/optimizer did something special to regex patterns besides just 
> interpreting variables, such that all patterns could benefit from this 
> option.  guess it's good to know it doesn't, though I'd hope it wouldn't 
> hurt to include the 'o' anyway...

But it would.  Not Perl, but your fellow programmers who read the
code.  If I found m//o in a program, I'd look for the interpolated
variable(s).  If there were none, I'd a) be annoyed to have wasted my
time, and b) conclude that the author doesn't seem to be quite sure
what they're doing.  It would make me less inclined to trust the
program as a whole.

Anno


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

Date: Fri, 27 Apr 2001 19:09:02 -0500
From: xris <xris@dont.send.spam>
Subject: Re: Regular expression for zip code
Message-Id: <xris-E42280.19090227042001@news.evergo.net>

In article <9ccn4o$11k4$1@node17.cwnet.frontiernet.net>,
 "Shay Harding" <sharding@ccbill.com> wrote:

> > > s/\b(?<!\S)\d{5}(-\d{4})?(?!\S)\b/X/g;
> >
> > shouldn't that be:
> >
> >    s/\b(?<!\S)\d{5}(-\d{4})?(?!\S)\b/X$1/go;
> 
> I don't see why $1 is needed for the right-hand side? $1 will only contain
> the '-\d{4}' portion of a match, if anything at all. Am I missing something
> you refer to?
> So for '12345-1234' the result would be X-1234.

actually, since you actually reference that (-\d{4}) it gets included in 
the pattern match, and thus the whole thing is replaced by "X" - not 
keeing the last 4 digits like the original poster wanted.

you're also using (?<!\S) which doesn't seem to work in all versions of 
perl, either.  (I'm curious which versions it DOES work in, since i've 
wanted something that does what I think this does for quite awhile.

something like:

   $x =~ s/\b\d{5}(?=-\d{4})\b/X/g;

would probably work better, unless for some reason he/she needs 
something more precise than \b as a border verification.

-xris



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

Date: Sat, 28 Apr 2001 01:16:27 +0100
From: "Linux" <sh0t2bts@hotmail.com>
Subject: Re: Running Command Line Commands
Message-Id: <vZnG6.1668$ux3.16539@news11-gui.server.ntli.net>

 Cheers All,

Got it working... ;-)

"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrn9eg9m5.1c3.tadmc@tadmc26.august.net...
> bowman <bowman@montana.com> wrote:
>
> >At one
> >time there was a project to replicate the *nix tools in Perl, but I
haven't
> >followed the progress on that.
>
>
> Perl Power Tools:
>
>    http://language.perl.com/ppt/
>
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas




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

Date: 28 Apr 2001 00:29:33 GMT
From: Billy Chambless <bchambless@nrlssc.navy.nil>
Subject: Re: So what do YOU use Perl for?
Message-Id: <9cd2td$lgg$1@news.datasync.com>

In article <3AE01962.BC90947E@holzerath.de>,
Hermann Fass  <hermann@holzerath.de> wrote:
>For me Perl is usefull for:
>- Evaluation of all kinds of logfiles (putting the results in text- or
>html-files).

You betcha. The project I'm supporting right now involves
four different flavors of semicolon-delimited files with a fairly
complicated structure. Counting semicolons to check whether the 12th 
field of the 132rd line of the fourth section didn't strike me as
being as fun as writing a Perl program to analyse that garbage
for me.

>- Generation of static HTML-files from data plus templates.

Hand up everybody who's used CGI.pm calls to produce static HTML. :)

>- As a command-line tool (sometimes just because I forgot how to do it in
>grep or awk)

I discovered Perl about the time I was getting good at shell programming.
Perl's MUCH more fun... although for true cryptcode, awk is hard to beat.

Lately I've been using Perl to generate C code; there's an example of this
in the book "The Pragmatic Programmer" <http://www.pragmaticprogrammer.com/>
showing a Perl program to generate code for C enumerated type. I've used 
a variation on this to save myself bunches of time.

In general, if I find myself doing something boring and tedious on a computer,
I start thinking about a Perl program. 


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

Date: Fri, 27 Apr 2001 15:04:17 -0400
From: Robert Pottschmidt <pottschmidtr@appstate.edu>
Subject: Storing the CGI object in my module?
Message-Id: <3AE9C2B1.CC1FF3B0@appstate.edu>


Hello,

	I am new to OO with Perl. I want to write a module to handle file up
loads. I need to be able to pass in the CGI object and or create a new
cgi object inside my module($self) and then access it. 

Here is a code snippet:

sub new{
    my $self = {};
    .... 
    $self -> {CGI} = undef;
    ....
    bless $self;
    return $self;
}

sub init{
    my $self  = shift;
    ....
    if($param{'cgi'}){
	$self -> {CGI} = $param{'cgi'};
    }
    else{
	my $cgi = new CGI;
	$self -> {CGI} = $cgi;
    }
    .....
}

sub retrieve_file{
    my $self = shift;
    my %param = @_;
    .....
    else{
	if($param{'cgi'} and $param{'param_name'}){
	    my $cgi = $param{'cgi'};
	    .....
	}
	else{
	    my $cgi = $self -> {CGI};
            .....
	}
	my $file = $cgi -> param($param_name);
    }	
    .....
}


My question is how do I store the CGI object and than reference it?

Thank you very much for the help.

Thx

RCP
-- 
+------------------------------------------------------------------------+
 Robert C Pottschmidt			     Appalachian State University
 Internet Applications Developer                          University
Hall
 Appalachian Regional Development Institute    	           P.O. Box
32131
 Email: pottschmidtr@appstate.edu                    Boone, NC
28608-2131 
 Phone: (828) 262-6553				      Fax: (828) 262-6553				
+------------------------------------------------------------------------+


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

Date: 27 Apr 2001 22:18:24 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Strange string -> num conversion
Message-Id: <9ccr7g$ilk$2@mamenchi.zrz.TU-Berlin.DE>

According to Jean-Louis Leroy  <jll63@easynet.be>:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> 
> > Something is fishy.  What Perl version are you using?  On what
> > system?
> 
> I found out on a Red Hat 6.2 system that had perl 5.005. I don't have
> access to it right now. The examples I posted were made on my home
> computer (see below).
> 
> Now if I try this on perl 5.6.0 on NT 4 in a vmware computer, I get
> the expected result (i.e. 1).
> 
> And when I try again on my computer at work (SUSe 7) I get 19 (looks
> like 0x12 is interpreted as a hex number; makes sense).

In that case the quotes around "0x12" probably got eaten by a shell.
The string "0x12" is 0 in numeric context.  The fractional number you
apparently got remains mysterious.
 
> So the problem would be...glibc??

Unlikely.  That would have to be a pretty massive bug.

Anno


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

Date: 27 Apr 2001 16:13:58 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Strange string -> num conversion
Message-Id: <m3n192qc4p.fsf@dhcp9-172.support.tivoli.com>

On 28 Apr 2001, jll63@easynet.be wrote:

> Why does this:
> 
>         perl -e "print '0x12' + 1"
> 
> ...print 2.125 ??

Well, for me it doesn't.  It prints 1, as expected.

Actually, I take that back... it seems to vary:

Here are several outputs of:

  perl -le 'print "$]($^O):", "0x12" + 1'

5.006(linux):19
5.003(aix):1
5.006():1                 ** ActiveState on W2K

But I can't find your 2.125 output anywhere.

That 19 implies that at some point the conversion from string to
number started accepting non-decimal forms, though I don't find any
mention in my v5.6.0 perldelta(1) (or perldata(1)).

-- 
Ren Maddox
ren@tivoli.com


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

Date: 27 Apr 2001 17:30:29 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Strange string -> num conversion
Message-Id: <m3y9smou0q.fsf@dhcp9-172.support.tivoli.com>

On 27 Apr 2001, anno4000@lublin.zrz.tu-berlin.de wrote:

>> And when I try again on my computer at work (SUSe 7) I get 19
>> (looks like 0x12 is interpreted as a hex number; makes sense).
> 
> In that case the quotes around "0x12" probably got eaten by a shell.
> The string "0x12" is 0 in numeric context.  The fractional number
> you apparently got remains mysterious.

You would think... but:

$ perl -wle 'print "$]($^O):", "0x12" + 1'
Argument "0x12" isn't numeric in addition (+) at -e line 1.
5.006(linux):19

The warning pretty clearly indicates that Perl sees it as a string,
yet the result is still 19.

>> So the problem would be...glibc??
> 
> Unlikely.  That would have to be a pretty massive bug.

Or documented behavior.  From strtol(3):

       long int strtol(const char *nptr, char **endptr, int base);

DESCRIPTION
       The  strtol()  function  converts  the string in nptr to a
       long integer value according to the given base, which must
       be  between 2 and 36 inclusive, or be the special value 0.

       The string must begin with an arbitrary  amount  of  white
       space  (as  determined by isspace(3)) followed by a single
       optional `+' or `-' sign.  If base  is  zero  or  16,  the
       string may then include a `0x' prefix, and the number will
       be read in base 16; otherwise, a zero base is taken as  10
       (decimal)  unless the next character is `0', in which case
       it is taken as 8 (octal).

Of course, atol(3) is supposed to use base 10, not 0 or 16.  I guess
the question is, is Perl using strtol with base 0 in some situations?
It appears to be.

-- 
Ren Maddox
ren@tivoli.com


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

Date: 27 Apr 2001 23:55:53 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Strange string -> num conversion
Message-Id: <9cd0u9$qtc$3@mamenchi.zrz.TU-Berlin.DE>

According to Ren Maddox  <ren@tivoli.com>:
> On 27 Apr 2001, anno4000@lublin.zrz.tu-berlin.de wrote:
> 
> >> And when I try again on my computer at work (SUSe 7) I get 19
> >> (looks like 0x12 is interpreted as a hex number; makes sense).
> > 
> > In that case the quotes around "0x12" probably got eaten by a shell.
> > The string "0x12" is 0 in numeric context.  The fractional number
> > you apparently got remains mysterious.
> 
> You would think... but:
> 
> $ perl -wle 'print "$]($^O):", "0x12" + 1'
> Argument "0x12" isn't numeric in addition (+) at -e line 1.
> 5.006(linux):19
> 
> The warning pretty clearly indicates that Perl sees it as a string,
> yet the result is still 19.
> 
> >> So the problem would be...glibc??
> > 
> > Unlikely.  That would have to be a pretty massive bug.
> 
> Or documented behavior.  From strtol(3):

[snip]

Thanks for that.  Yes, that explains "19", even in the case (which
I had overlooked) where the string is converted, though the latter
would be a buglet in Perl.  It doesn't explain the fractional 2.125
the OP has repeatedly seen.

Anno


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

Date: 27 Apr 2001 17:38:59 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: WI Performance Hit w/ Hash || Array v Scalar?
Message-Id: <m3u23aotmk.fsf@dhcp9-172.support.tivoli.com>

On Fri, 27 Apr 2001, ameen @ dausha . net wrote:

> What is the performance hit in using a Hash or Array in lieu of
> scalars?
> 
> I mean, what if I used a hash with ten keys in a subroutine instead
> of ten scalars in the same routine?

First, it's quite likely that you shouldn't care about this.  The only
type of optimization that you should do *before* you get code working
is general algorithm selection, and the only kind of optimization you
should do *after* you get code working is via profiling.

That being said, this has been discussed before and I believe that the
result was something similar to:

* package scalars are very slightly faster than hash keys

This is because package variables are actually very similar to hash
keys, with the package symbol table as the hash.

* lexical scalars are faster to access than package variables, but
there is additional overhead when they come in to and go out of scope

Which basically means that if you access the variable *a lot* before
it goes out of scope, then it may be faster than the package version.
How this compares to a hash key lookup where the hash is either a
package variable or a lexical variable, I don't recall.


In the end, if you're worried about this level of optimization, you
probably shouldn't be solving the problem with Perl.  (Or, more
likely, you're worried about the wrong thing.)

-- 
Ren Maddox
ren@tivoli.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.  

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


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