[22349] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4570 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 15 14:05:38 2003

Date: Sat, 15 Feb 2003 11:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 15 Feb 2003     Volume: 10 Number: 4570

Today's topics:
        "Deep recursion on subroutine" error <md0nilhe@mdstud.DIESPAMchalmers.se>
    Re: "Deep recursion on subroutine" error <abigail@abigail.nl>
    Re: "Deep recursion on subroutine" error <eric.ehlers@btopenworld.com.nospam>
    Re: "Deep recursion on subroutine" error (Tad McClellan)
        $^S == 0 inside eval (v5.6.1) (Paul Wood)
    Re: $^S == 0 inside eval (v5.6.1) <abigail@abigail.nl>
    Re: case insensitive hash key comparison <jurgenex@hotmail.com>
    Re: code to change a word in a file? (Tad McClellan)
    Re: code to change a word in a file? <usenet@dwall.fastmail.fm>
        configure 'PerlModule Apache2' in httpd.conf <Pop@goesthe.net>
    Re: how to do string concatenation <barryk2@SPAM-KILLER.mts.net>
    Re: New JAPH <spam@thecouch.homeip.net>
    Re: New JAPH (Jay Tilton)
    Re: newbie date comparison <Jodyman@hotmail.com>
    Re: newbie date comparison <bongie@gmx.net>
    Re: newbie date comparison (Anno Siegel)
    Re: newbie date comparison <Jodyman@hotmail.com>
    Re: newbie date comparison <Jodyman@hotmail.com>
    Re: newbie date comparison <Jodyman@hotmail.com>
    Re: Number of Items in a Hash? <notspam@spamfree.dud>
    Re: one liner in command line (Tad McClellan)
    Re: one liner in command line <shanem@nospam.ll.mit.edu>
    Re: String Compare Help <barryk2@SPAM-KILLER.mts.net>
    Re: Unable to load modules <brian.smart@blueyonder.co.uk>
    Re: Unable to load modules (Anno Siegel)
    Re: Unable to load modules <brian.smart@blueyonder.co.uk>
    Re: Using Archive::Tar for in-memory tarfiles <dont@want.spam>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 15 Feb 2003 13:43:01 +0100
From: henrik nilsson <md0nilhe@mdstud.DIESPAMchalmers.se>
Subject: "Deep recursion on subroutine" error
Message-Id: <3E4E35D5.3080805@mdstud.DIESPAMchalmers.se>

Hello

My Perl script sometimes generates a particularly nasty error where 
Mozilla suddenly and rapidly consumes all swap space and quickly brings 
RedHat to its knees. In the httpd error log, this is all I get (two 
times). The script itself is deemed free from errors with -cw.

[Sat Feb 15 13:20:18 2003] script.cgi: Deep recursion on subroutine 
"main::analysissweep" at /var/www/cgi-bi
n/newcomer7.cgi line 548., referer: http://localhost/newcomer.html

Anyone seen this before?

Thanks,

Henrik N



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

Date: 15 Feb 2003 13:06:24 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: "Deep recursion on subroutine" error
Message-Id: <slrnb4seqg.asa.abigail@alexandra.abigail.nl>

henrik nilsson (md0nilhe@mdstud.DIESPAMchalmers.se) wrote on MMMCDLV
September MCMXCIII in <URL:news:3E4E35D5.3080805@mdstud.DIESPAMchalmers.se>:
`'  Hello
`'  
`'  My Perl script sometimes generates a particularly nasty error where 
`'  Mozilla suddenly and rapidly consumes all swap space and quickly brings 
`'  RedHat to its knees. In the httpd error log, this is all I get (two 
`'  times). The script itself is deemed free from errors with -cw.
`'  
`'  [Sat Feb 15 13:20:18 2003] script.cgi: Deep recursion on subroutine 
`'  "main::analysissweep" at /var/www/cgi-bi
`'  n/newcomer7.cgi line 548., referer: http://localhost/newcomer.html
`'  
`'  Anyone seen this before?


Did you check 'man perldiag'? Perhaps you should. It's explained
in there.



Abigail
-- 
sub _ {$_ = shift and y/b-yB-Y/a-yB-Y/                xor      !@ _?
       exit print                                                  :
            print and push @_ => shift and goto &{(caller (0)) [3]}}
            split // => "KsvQtbuf fbsodpmu\ni flsI "  xor       & _


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

Date: Sat, 15 Feb 2003 13:18:33 +0000 (UTC)
From: "eric" <eric.ehlers@btopenworld.com.nospam>
Subject: Re: "Deep recursion on subroutine" error
Message-Id: <b2len9$8r6$1@helle.btinternet.com>

"henrik nilsson" <md0nilhe@mdstud.DIESPAMchalmers.se> wrote in message
news:3E4E35D5.3080805@mdstud.DIESPAMchalmers.se...
> Hello
hi
>
> My Perl script sometimes generates a particularly nasty error where
> Mozilla suddenly and rapidly consumes all swap space and quickly brings
> RedHat to its knees. In the httpd error log, this is all I get (two
> times). The script itself is deemed free from errors with -cw.
>
> [Sat Feb 15 13:20:18 2003] script.cgi: Deep recursion on subroutine
> "main::analysissweep" at /var/www/cgi-bi
> n/newcomer7.cgi line 548., referer: http://localhost/newcomer.html
>
> Anyone seen this before?

not me.  but perldiag (5.8) says:

Deep recursion on subroutine ``%s''

(W recursion) This subroutine has called itself (directly or indirectly) 100
times more than it has returned. This probably indicates an infinite
recursion, unless you're writing strange benchmark programs, in which case
it indicates something else.

> Thanks,
>
> Henrik N

HTH,
-eric




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

Date: Sat, 15 Feb 2003 07:22:32 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: "Deep recursion on subroutine" error
Message-Id: <slrnb4sfoo.3ud.tadmc@magna.augustmail.com>

henrik nilsson <md0nilhe@mdstud.DIESPAMchalmers.se> wrote:

> My Perl script sometimes generates a particularly nasty error where 
> Mozilla suddenly and rapidly consumes all swap space and quickly brings 
> RedHat to its knees. 


Mozilla has nothing to do with your Perl program.

Mozilla is a client (browser).

Your Perl CGI program runs on a *server*.


> In the httpd error log, this is all I get (two 
> times). The script itself is deemed free from errors with -cw.


Passing -cw does NOT imply "free from errors".

It only means that there are no syntax errors.

There are plenty of other classes of errors apart from mere syntax.


> [Sat Feb 15 13:20:18 2003] script.cgi: Deep recursion on subroutine 
> "main::analysissweep" at /var/www/cgi-bi
> n/newcomer7.cgi line 548., referer: http://localhost/newcomer.html
> 
> Anyone seen this before?


Yes.

You should look it up in the std docs:

   perldoc perldiag

     =item Deep recursion on subroutine "%s"

     (W recursion) This subroutine has called itself (directly or indirectly)
     100 times more than it has returned.  This probably indicates an
     infinite recursion, unless you're writing strange benchmark programs, in
     which case it indicates something else.

Or put:

   use diagnostics;

in your program source, and perl will look it up for you.

(Have you seen the Posting Guidelines that are posted here frequently?)


So the real question becomes: why is your recursion going so deep?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 15 Feb 2003 04:21:06 -0800
From: paul@torporific.org (Paul Wood)
Subject: $^S == 0 inside eval (v5.6.1)
Message-Id: <a2702001.0302150421.35b35c1@posting.google.com>

Hi.

I'm having trouble with $^S being zero inside an eval { }. I've run a
small test script and $^S works fine in that, so I'm a bit confused.
The full code is _far_ too large to post here, so I'm just looking for
pointers really.

$^S is only referenced once in the entire code (when I test it for
truth). Any ideas on what could cause this to happen? (And yes, it is
_definitely_ inside an eval.)

Thanks.

-Paul.


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

Date: 15 Feb 2003 13:09:59 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: $^S == 0 inside eval (v5.6.1)
Message-Id: <slrnb4sf17.asa.abigail@alexandra.abigail.nl>

Paul Wood (paul@torporific.org) wrote on MMMCDLV September MCMXCIII in
<URL:news:a2702001.0302150421.35b35c1@posting.google.com>:
""  Hi.
""  
""  I'm having trouble with $^S being zero inside an eval { }. I've run a
""  small test script and $^S works fine in that, so I'm a bit confused.
""  The full code is _far_ too large to post here, so I'm just looking for
""  pointers really.
""  
""  $^S is only referenced once in the entire code (when I test it for
""  truth). Any ideas on what could cause this to happen? (And yes, it is
""  _definitely_ inside an eval.)


'man perlvar' explains when $^S can be undefined. If this isn't
the case in your program, please trim the code down to a *SMALL*
program that shows the same behaviour, and use perlbug to report
it (after you have checked whether this has been fixed in 5.8.0
already). 


Abigail
-- 
 :;$:=~s:
-:;another Perl Hacker
 :;chop
$:;$:=~y
 :;::d;print+Just.
$:;


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

Date: Sat, 15 Feb 2003 15:48:34 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: case insensitive hash key comparison
Message-Id: <mjt3a.19544$rE3.2655@nwrddc01.gnilink.net>

squillion wrote:
> i want to know if a given string is used as a key in a given hash, but
> i want the comparison to be case insensitive.  i can assume that the
> string will match at most one key - i.e. the hash keys are unique even
> when compared case-insensitively.
[...]
> can this be accomplished in a more hip and groovy way?

The standard way would be to define a normal form.
Something trivial like e.g. the keys are always all lower case. Then your
task becomes trivial with "exist()"
If you still need the original representation then you can store that as an
additional value together with the other values for each hash entry.

jue




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

Date: Sat, 15 Feb 2003 07:08:53 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: code to change a word in a file?
Message-Id: <slrnb4sev5.3ud.tadmc@magna.augustmail.com>

David Bruno <dbruno@ucla.edu> wrote:

> I saw this in an archive of this newsgroup:
> "% perl -pi.bak -e 's/word1/word2/'  file_name;"
> 
> I tried this, but only got errors.  


It looks OK to me.

What errors did you get?

Error messages are meant to help in debugging.

Help us helpers help you by providing the _exact text_ of
any helpful messages you are getting.


> Is there a module I need
> to use to get this to work?  


No.


> Does the file have to be opened first?


Yes, but the code above _does_ open the file.

You really really should NOT run other people's code without
understanding it. It might be a trick that does Something Bad.

   perldoc perlrun

and check out what it is that the 3 switches you are using do.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 15 Feb 2003 16:16:34 GMT
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: code to change a word in a file?
Message-Id: <Xns932372B51FEA8dkwwashere@204.127.204.17>

"David Bruno" <dbruno@ucla.edu> wrote:

> I'm trying to make a script change one word in a file.
> I saw this in an archive of this newsgroup:
> "% perl -pi.bak -e 's/word1/word2/'  file_name;"
> 
> I tried this, but only got errors.  Is there a module I need
> to use to get this to work?  Does the file have to be opened first?

I didn't notice this last night, but it appears you're using some flavor 
of Windows.  Try replacing the single quotes with double quotes:

perl -pi.bak -e "s/word1/word2/"  file_name

But you should still pay attention to the advice Jürgen and Tad gave you.

-- 
David Wall - me@dwall.fastmail.fm
"Oook."


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

Date: Sat, 15 Feb 2003 15:19:33 GMT
From: "Papa Oohmawmaw" <Pop@goesthe.net>
Subject: configure 'PerlModule Apache2' in httpd.conf
Message-Id: <9Us3a.111250$SD6.5316@sccrnsc03>

I finally got Mod_perl installed and have a problem, the program said to:

"Don't forget to:
- configure 'PerlModule Apache2' in httpd.conf"

I don't know the syntax for adding this. I've tried a few ways to add it but
always get an error. Can anyone help me with the syntax to add this? Thanks.




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

Date: Sat, 15 Feb 2003 08:21:46 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: how to do string concatenation
Message-Id: <MPG.18b808f4b361ca729896fc@news.mts.net>


In article <df4dcc52.0302141420.47efce3e@posting.google.com>, eWisdom 
(hemen.oza@med.ge.com) says...
> I am trying to add two strings like,
> $str1 = "FirstName";
> $str2 = "LastName";
> $str3 = $str1 + " " + $str2;
> 
> How can I do this in perl?
> 

$str3 = $str1 . " " . $str2;


-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: Sat, 15 Feb 2003 11:04:31 -0500
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: New JAPH
Message-Id: <uyt3a.44025$Tv6.495212@wagner.videotron.net>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Benjamin Goldberg wrote:
 > $,=q=,JtutsarfornreehaPefhkfcl=;$;=25;sub _{
 > my$__ if 0;++$__;print substr$,,$;&&$__%$;,1
 > ,q;;;--$;;$__>2&&&_;}$,=~tr;f; ;;_ for 1..9;
 >
 > This is of course dependent on the funky behavior of my $foo if 0;, and
 > thus is subject to breakage on any future perls which alter that
 > behavior.
 >
 > [Tested with AS Perl 5.6.1 build 631]
 >

While we're at it, here's mine.. it's been sitting in a dark corner of
my web page for a few months..

#!/usr/bin/perl

# JAPH by Mina Naguib
# http://www.topfx.com
#
# Note HEX-encoded string is only 15 bytes
# Output "just another perl hacker" is 23 bytes!

   $_="89ca994173f390981f892b1f201489";$d=join("",map{chr hex}/(..)/g);
   for$a(0..23){for$b(0..4){vec($c,$b,1)=vec($d,($a*5)+$b,1)}print(($c=
   chr(ord($c)+97))eq"z"?" ":$c);undef$c}print"\n";


-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+TmUaeS99pGMif6wRAlh4AJ918AoRwrRbUKdMIvOd3ZgaAd43rwCgs4U1
ZexfJBtsd8M7TpIu/cLj+Sg=
=07J0
-----END PGP SIGNATURE-----



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

Date: Sat, 15 Feb 2003 17:53:56 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: New JAPH
Message-Id: <3e4e7169.54162666@news.erols.com>

Benjamin Goldberg <goldbb2@earthlink.net> wrote:

: $,=q=,JtutsarfornreehaPefhkfcl=;$;=25;sub _{
: my$__ if 0;++$__;print substr$,,$;&&$__%$;,1
: ,q;;;--$;;$__>2&&&_;}$,=~tr;f; ;;_ for 1..9;
: 
: This is of course dependent on the funky behavior of my $foo if 0;, and
: thus is subject to breakage on any future perls which alter that
: behavior.

Nice.  The " $,=~tr;f; ; " part had me puzzled for a moment.  I was
trying to find its significance to the algorithm.  :)

Naturally, I had to noodle around with it.

$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print

Fundamentally the same, but different.

I rather like the transform of "my $__ if 0" into "0 && my $__",
especially how the "my $__" looks like its own statement.

And I've been waiting for a good reason to say "y yiy y".



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

Date: Sat, 15 Feb 2003 15:29:19 GMT
From: "Jodyman" <Jodyman@hotmail.com>
Subject: Re: newbie date comparison
Message-Id: <j1t3a.2905$YU4.270591@newsread1.prod.itd.earthlink.net>

"Tad McClellan" <tadmc@augustmail.com> wrote in message
> Jodyman <Jodyman@hotmail.com> wrote:
> > "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
>
> >> > > >     $_ = sprintf "%02d", $_ for $new_month, $new_day, $new_year;
> >> > >        ^^^^                        ^^^^^^
> >> > > Anno, can you explain what his is doing and how it works?  Didn't
find
> >> > > the answer in perldoc -f sprintf.
>
>
> > That's pretty cool.  Where can I read more about this little trick?
>
>
> The "Foreach Loops" section in:
>
>    perldoc perlsyn
>
>
I found this in perldoc perlsyn:

LABEL for (EXPR; EXPR; EXPR) BLOCK
LABEL foreach VAR (LIST) BLOCK
LABEL foreach VAR (LIST) BLOCK continue BLOCK
LABEL BLOCK continue BLOCK

> >> > > >     $_ = sprintf "%02d", $_ for $new_month, $new_day, $new_year;
> >> > >        ^^^^                        ^^^^^^

Which format is the above?

This in perldoc -f sprintf:

 sprintf FORMAT, LIST

> >> > > >     $_ = sprintf "%02d", $_ for $new_month, $new_day, $new_year;
> >> > >        ^^^^                        ^^^^^^

So:  $_ for $new_month, $new_day, $new_year;
is the LIST part.
$_ =  assigns the format of 2 places zero filled to $_
but, why doesn't $_ have anything in it afterwards?  I just don't get
it and don't see the answer in perlsyn either.  Please open my eyes.

Jody




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

Date: Sat, 15 Feb 2003 17:17:35 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: newbie date comparison
Message-Id: <7576722.9fi9SUHvvU@nyoga.dubu.de>

Jodyman wrote:
[regarding the code
    $_ = sprintf "%02d", $_ for $new_month, $new_day, $new_year;
]

> So:  $_ for $new_month, $new_day, $new_year;
> is the LIST part.

No.  You should read it like
    $_ = sprintf("%02d", $_) for ($new_month, $new_day, $new_year);

The code above could also be written as
    for ($new_month, $new_day, $new_year) {
        $_ = sprintf ("%02d", $_);
    }

The $_ is local to the loop.  For each iteration of the loop, $_ is
aliased to (not copied from!) the next element in the list, so this is
the same as
    $new_month = sprintf "%02d", $new_month;
    $new_day   = sprintf "%02d", $new_day;
    $new_year  = sprintf "%02d", $new_year;
only shorter and without repeating identical code. :-)

Ciao,
        Harald
-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> What's the opposite of 'omniscient'?
I don't know.                   [from alt.usage.english]


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

Date: 15 Feb 2003 16:34:09 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: newbie date comparison
Message-Id: <b2lq61$asg$1@mamenchi.zrz.TU-Berlin.DE>

Jodyman <Jodyman@hotmail.com> wrote in comp.lang.perl.misc:
> "Tad McClellan" <tadmc@augustmail.com> wrote in message
> > Jodyman <Jodyman@hotmail.com> wrote:
> > > "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> >
> > >> > > >     $_ = sprintf "%02d", $_ for $new_month, $new_day, $new_year;
> > >> > >        ^^^^                        ^^^^^^
> > >> > > Anno, can you explain what his is doing and how it works?  Didn't
> find
> > >> > > the answer in perldoc -f sprintf.
> >
> >
> > > That's pretty cool.  Where can I read more about this little trick?
> >
> >
> > The "Foreach Loops" section in:
> >
> >    perldoc perlsyn
> >
> >
> I found this in perldoc perlsyn:
> 
> LABEL for (EXPR; EXPR; EXPR) BLOCK
> LABEL foreach VAR (LIST) BLOCK
> LABEL foreach VAR (LIST) BLOCK continue BLOCK
> LABEL BLOCK continue BLOCK
> 
> > >> > > >     $_ = sprintf "%02d", $_ for $new_month, $new_day, $new_year;
> > >> > >        ^^^^                        ^^^^^^
> 
> Which format is the above?
> 
> This in perldoc -f sprintf:
> 
>  sprintf FORMAT, LIST
> 
> > >> > > >     $_ = sprintf "%02d", $_ for $new_month, $new_day, $new_year;
> > >> > >        ^^^^                        ^^^^^^
> 
> So:  $_ for $new_month, $new_day, $new_year;
> is the LIST part.
> $_ =  assigns the format of 2 places zero filled to $_

No, you're misparsing it.  Let's rewrite the line to make clearer what
it does:

    $_ = sprintf( "%02d", $_) foreach ( $new_month, $new_day, $new_year);

So the LIST part of sprintf is only $_ (corresponding to the FORMAT,
which provides for only one value).

> but, why doesn't $_ have anything in it afterwards?  I just don't get
> it and don't see the answer in perlsyn either.

I have replaced "for" with "foreach".  These are synonyms in Perl, and
the documentation speaks mostly of foreach.  Look it up in perlsyn
and see what it says about localizing variables.

>                                                  Please open my eyes.

I believe perlsyn will now.

Anno




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

Date: Sat, 15 Feb 2003 16:42:45 GMT
From: "Jodyman" <Jodyman@hotmail.com>
Subject: Re: newbie date comparison
Message-Id: <96u3a.2967$YU4.281400@newsread1.prod.itd.earthlink.net>

"Tad McClellan" <tadmc@augustmail.com> wrote in message
> Jodyman <Jodyman@hotmail.com> wrote:
> > "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
>
> >> > > >     $_ = sprintf "%02d", $_ for $new_month, $new_day, $new_year;
> >> > >        ^^^^                        ^^^^^^
> >> > > Anno, can you explain what his is doing and how it works?  Didn't
find
> >> > > the answer in perldoc -f sprintf.
>
>
> > That's pretty cool.  Where can I read more about this little trick?
>
>
> The "Foreach Loops" section in:
>
>    perldoc perlsyn
>
>
I found this in perldoc perlsyn:

LABEL for (EXPR; EXPR; EXPR) BLOCK
LABEL foreach VAR (LIST) BLOCK
LABEL foreach VAR (LIST) BLOCK continue BLOCK
LABEL BLOCK continue BLOCK

> >> > > >     $_ = sprintf "%02d", $_ for $new_month, $new_day, $new_year;
> >> > >        ^^^^                        ^^^^^^

Which format is the above?

This in perldoc -f sprintf:

 sprintf FORMAT, LIST

> >> > > >     $_ = sprintf "%02d", $_ for $new_month, $new_day, $new_year;
> >> > >        ^^^^                        ^^^^^^

So:  $_ for $new_month, $new_day, $new_year;
is the LIST part.
$_ =  assigns the format of 2 places zero filled to $_
but, why doesn't $_ have anything in it afterwards?  I just don't get
it and don't see the answer in perlsyn either.  Please open my eyes.

Jody






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

Date: Sat, 15 Feb 2003 17:04:00 GMT
From: "Jodyman" <Jodyman@hotmail.com>
Subject: Re: newbie date comparison
Message-Id: <4qu3a.2983$YU4.283993@newsread1.prod.itd.earthlink.net>

"Harald H.-J. Bongartz" <bongie@gmx.net> wrote in message
> Jodyman wrote:
> [regarding the code
>     $_ = sprintf "%02d", $_ for $new_month, $new_day, $new_year;
> ]
>
> > So:  $_ for $new_month, $new_day, $new_year;
> > is the LIST part.
>
> No.  You should read it like
>     $_ = sprintf("%02d", $_) for ($new_month, $new_day, $new_year);
>
> The code above could also be written as
>     for ($new_month, $new_day, $new_year) {
>         $_ = sprintf ("%02d", $_);
>     }

This format is easier to understand.  I know about $_ in for and
foreach loops.  I got the aliasing part.  I just didn't understand it
written the top way with $_ = in the front.  I still don't get it.  I
know there are many ways to do it in Perl, but, this particular
way has got me stumped.

In most documentation $_ can be implied, in this case we are
explicitly showing it.  Can you demonstrate this format in another
context so I might understand it?  Examples would be great.

Jody




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

Date: Sat, 15 Feb 2003 17:04:07 GMT
From: "Jodyman" <Jodyman@hotmail.com>
Subject: Re: newbie date comparison
Message-Id: <bqu3a.2984$YU4.283993@newsread1.prod.itd.earthlink.net>

"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> Jodyman <Jodyman@hotmail.com> wrote in comp.lang.perl.misc:
> > "Tad McClellan" <tadmc@augustmail.com> wrote in message
> > > Jodyman <Jodyman@hotmail.com> wrote:
> > > > "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> > >
> > > >> > > >     $_ = sprintf "%02d", $_ for $new_month, $new_day,
$new_year;
> > > >> > >        ^^^^                        ^^^^^^
> > > >> > > Anno, can you explain what his is doing and how it works?
Didn't
> > find
> > > >> > > the answer in perldoc -f sprintf.
> > >
> > >
> > > > That's pretty cool.  Where can I read more about this little trick?
> > >
> > >
> > > The "Foreach Loops" section in:
> > >
> > >    perldoc perlsyn
> > >
> > >
> > I found this in perldoc perlsyn:
> >
> > LABEL for (EXPR; EXPR; EXPR) BLOCK
> > LABEL foreach VAR (LIST) BLOCK
> > LABEL foreach VAR (LIST) BLOCK continue BLOCK
> > LABEL BLOCK continue BLOCK
> >
> > > >> > > >     $_ = sprintf "%02d", $_ for $new_month, $new_day,
$new_year;
> > > >> > >        ^^^^                        ^^^^^^
> >
> > Which format is the above?
> >
> > This in perldoc -f sprintf:
> >
> >  sprintf FORMAT, LIST
> >
> > > >> > > >     $_ = sprintf "%02d", $_ for $new_month, $new_day,
$new_year;
> > > >> > >        ^^^^                        ^^^^^^
> >
> > So:  $_ for $new_month, $new_day, $new_year;
> > is the LIST part.
> > $_ =  assigns the format of 2 places zero filled to $_
>
> No, you're misparsing it.  Let's rewrite the line to make clearer what
> it does:
>
>     $_ = sprintf( "%02d", $_) foreach ( $new_month, $new_day, $new_year);
>
> So the LIST part of sprintf is only $_ (corresponding to the FORMAT,
> which provides for only one value).
>
> > but, why doesn't $_ have anything in it afterwards?  I just don't get
> > it and don't see the answer in perlsyn either.
>
> I have replaced "for" with "foreach".  These are synonyms in Perl, and
> the documentation speaks mostly of foreach.  Look it up in perlsyn
> and see what it says about localizing variables.
>
> >                                                  Please open my eyes.
>
> I believe perlsyn will now.

I'm trying.

Jody




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

Date: Sat, 15 Feb 2003 19:02:23 GMT
From: Sean O'Dwyer <notspam@spamfree.dud>
Subject: Re: Number of Items in a Hash?
Message-Id: <notspam-8FF803.14022415022003@syrcnyrdrs-03-ge0.nyroc.rr.com>

In article <Xns93228D641214Delhber1lidotechnet@62.89.127.66>,
 "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net> wrote:

> Sean O'Dwyer wrote:
> 
> > Newbie question. How can I get a quick tot of the number of items in a 
> > hash? If I use something like $tot = %hashname I get a weird return 
> > value such as 247/153 rather than a single number...
> 
> my $no_of_items = keys %hashname;


Perfect, thank you.

Sean


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

Date: Sat, 15 Feb 2003 07:15:54 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: one liner in command line
Message-Id: <slrnb4sfca.3ud.tadmc@magna.augustmail.com>

David Bruno <dbruno@ucla.edu> wrote:

> how can use a variable in a one line program
> if it's in the command line?


The same way you use a variable in a multi-line program that
is stored in a file. ie. there is no difference.

Did you try it? What happened?


> can one liners be in the body of the code?


You can run any external programs you want, whether they are
written in Perl or in anything else.

But if it is a Perl one-liner, it is probably more sensible to
convert it to regular code in your "parent" Perl program rather
than firing off a separate process to do it.


I'm pretty sure you have an "XY problem".

   An XY problem is when you want to do X, but you ask how to do Y
   instead, because you've decided that Y is the best way to accomplish X.

What is your "X"?

That is, what is it that you are ultimately trying to accomplish?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 15 Feb 2003 12:12:12 -0500
From: Shane McDaniel <shanem@nospam.ll.mit.edu>
Subject: Re: one liner in command line
Message-Id: <3E4E74EC.26D68823@nospam.ll.mit.edu>



David Bruno wrote:
> 
> how can use a variable in a one line program
> if it's in the command line?
> 
> can one liners be in the body of the code?


You need to state what you want to do much better than this.  It makes
little sense other than you want to do something with the command line,
I think.

-shane


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

Date: Sat, 15 Feb 2003 08:19:54 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: String Compare Help
Message-Id: <MPG.18b808849f150969896fb@news.mts.net>


In article <WBOdnQoTx7JFq9CjXTWcqw@comcast.com>, Ryan 
(ryanscheller@comcast.net) says...
> What is wrong with this?  The evaluation of the strings is wrong somehow?
> 
> $name = "abc";
> $testdir = "zxy";
> 
> if($name == $testdir)
> {
>     $result = "True";
> }
> else
> {
>     $result = "False";
> }
> 
> 
> 


The "==" operator is fpr testing binary values
(eg. integers)

The "eq" operator is for comparing strings

-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: Sat, 15 Feb 2003 15:59:00 -0000
From: "Brian Smart" <brian.smart@blueyonder.co.uk>
Subject: Re: Unable to load modules
Message-Id: <3kt3a.1590$I23.1135@news-binary.blueyonder.co.uk>

Hello All,
Further to my earlie post:
Because I keep running into problems when loading a module with the need to
update the CPAN module to version 1.65, I have tried to update the CPAN
module by adding it to my web site. The following text is th last part of
the installation information.

All tests successful.
Files=4,  Tests=39,  5 wallclock secs ( 4.96 cusr +  0.47 csys =  5.43 CPU)
[bsmart CPAN-1.65]$ make install
Installing /home/sites/www.bms.me.uk/web/cgi-bin/CPAN/MakeMaker.pm
Installing /home/sites/www.bms.me.uk/web/cgi-bin/CPAN/FirstTime.pm
Installing /home/sites/www.bms.me.uk/web/cgi-bin/CPAN/Admin.pm
Installing /home/sites/www.bms.me.uk/web/cgi-bin/CPAN/Nox.pm
Installing /home/sites/www.bms.me.uk/web/cgi-bin/CPAN.pm
Installing /home/sites/www.bms.me.uk/web/cgi-bin/Bundle/CPAN.pm
Installing /home/sites/www.bms.me.uk/web/cgi-bin/man/man1/cpan.1
Installing /home/sites/www.bms.me.uk/web/cgi-bin/bin/cpan
Writing /home/sites/www.bms.me.uk/web/cgi-bin/i386-linux/auto/CPAN/.packlist
Appending installation info to
/home/sites/www.bms.me.uk/web/cgi-bin/i386-linux/perllocal.pod
[bsmart CPAN-1.65]$

Does this look as though I have installed CPAN 1.65 OK?
If yes how do I make sure that I use it rather than the version on the
server root, when I try to install more modules?

Regards

Brian Smart




"Brian Smart" <brian.smart@blueyonder.co.uk> wrote in message
news:L5o3a.45533$sZ5.31118@news-binary.blueyonder.co.uk...
> Hi all,
> I have had to start this subject again as the original thread has
> disappeared. When I try to load a module, I get the following series of
> statements.
>
> " There's a new CPAN.pm version (v1.65) available!
>   You might want to try
>     install Bundle::CPAN
>     reload cpan
>   without quitting the current session. It should be a seamless upgrade
>   while we are running...
>
> Fetching with LWP:
>   ftp://cpan.teleglobe.net/pub/CPAN/modules/03modlist.data.gz
> Going to read y/sources/modules/03modlist.data.gz
> Running make for J/JH/JHI/perl-5.8.0.tar.gz
> Fetching with LWP:
>   ftp://cpan.teleglobe.net/pub/CPAN/authors/id/J/JH/JHI/perl-5.8.0.tar.gz
> CPAN: MD5 loaded ok
> Fetching with LWP:
>   ftp://cpan.teleglobe.net/pub/CPAN/authors/id/J/JH/JHI/CHECKSUMS
> Could not gzopen y/sources/authors/id/J/JH/JHI/perl-5.8.0.tar.gz at
> /usr/lib/perl5/5.00503/CPAN.pm line 4159."
>
> Various suggestions have been made but probably my ignorance has stopped
me
> from fixing the problem.
>
> Can anybody work with me to resolve the problem. I will provide any
> information requested about my web site and the server upon which it
> resides. Unfortunately as a beginner, the previous suggestions via this
site
> have been a little too criptic for me to understand.
>
> Thanks for any help you can provide.
>
> Brian Smart
>
>
>
>




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

Date: 15 Feb 2003 17:09:18 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Unable to load modules
Message-Id: <b2ls7u$cgd$1@mamenchi.zrz.TU-Berlin.DE>

Brian Smart <brian.smart@blueyonder.co.uk> wrote in comp.lang.perl.misc:
> Hi all,
> I have had to start this subject again as the original thread has
> disappeared. When I try to load a module, I get the following series of
> statements.
> 
> " There's a new CPAN.pm version (v1.65) available!
>   You might want to try
>     install Bundle::CPAN
>     reload cpan
>   without quitting the current session. It should be a seamless upgrade
>   while we are running...
> 
> Fetching with LWP:
>   ftp://cpan.teleglobe.net/pub/CPAN/modules/03modlist.data.gz
> Going to read y/sources/modules/03modlist.data.gz
> Running make for J/JH/JHI/perl-5.8.0.tar.gz
> Fetching with LWP:
>   ftp://cpan.teleglobe.net/pub/CPAN/authors/id/J/JH/JHI/perl-5.8.0.tar.gz
> CPAN: MD5 loaded ok
> Fetching with LWP:
>   ftp://cpan.teleglobe.net/pub/CPAN/authors/id/J/JH/JHI/CHECKSUMS
> Could not gzopen y/sources/authors/id/J/JH/JHI/perl-5.8.0.tar.gz at
> /usr/lib/perl5/5.00503/CPAN.pm line 4159."
> 
> Various suggestions have been made but probably my ignorance has stopped me
> from fixing the problem.
> 
> Can anybody work with me to resolve the problem. I will provide any
> information requested about my web site and the server upon which it
> resides. Unfortunately as a beginner, the previous suggestions via this site
> have been a little too criptic for me to understand.

Your best bet is to re-install CPAN from scratch.  If I remember the
situation right, it believes your .cpan directory is somewhere below
some cgi-bin.  It doesn't belong there, and AFAIK this can only happen
when the system-wide defaults are messed up.

Anno


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

Date: Sat, 15 Feb 2003 18:55:35 -0000
From: "Brian Smart" <brian.smart@blueyonder.co.uk>
Subject: Re: Unable to load modules
Message-Id: <CVv3a.3705$FG3.199@news-binary.blueyonder.co.uk>

Hello Anno,
I have reinstalled CPAN from scratch and AFAIK I have followed all the
instructions correctly. Did you see my follow up email that relates to the
latest attempt?

Regards

Brian Smart

"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:b2ls7u$cgd$1@mamenchi.zrz.TU-Berlin.DE...
> Brian Smart <brian.smart@blueyonder.co.uk> wrote in comp.lang.perl.misc:
> > Hi all,
> > I have had to start this subject again as the original thread has
> > disappeared. When I try to load a module, I get the following series of
> > statements.
> >
> > " There's a new CPAN.pm version (v1.65) available!
> >   You might want to try
> >     install Bundle::CPAN
> >     reload cpan
> >   without quitting the current session. It should be a seamless upgrade
> >   while we are running...
> >
> > Fetching with LWP:
> >   ftp://cpan.teleglobe.net/pub/CPAN/modules/03modlist.data.gz
> > Going to read y/sources/modules/03modlist.data.gz
> > Running make for J/JH/JHI/perl-5.8.0.tar.gz
> > Fetching with LWP:
> >
ftp://cpan.teleglobe.net/pub/CPAN/authors/id/J/JH/JHI/perl-5.8.0.tar.gz
> > CPAN: MD5 loaded ok
> > Fetching with LWP:
> >   ftp://cpan.teleglobe.net/pub/CPAN/authors/id/J/JH/JHI/CHECKSUMS
> > Could not gzopen y/sources/authors/id/J/JH/JHI/perl-5.8.0.tar.gz at
> > /usr/lib/perl5/5.00503/CPAN.pm line 4159."
> >
> > Various suggestions have been made but probably my ignorance has stopped
me
> > from fixing the problem.
> >
> > Can anybody work with me to resolve the problem. I will provide any
> > information requested about my web site and the server upon which it
> > resides. Unfortunately as a beginner, the previous suggestions via this
site
> > have been a little too criptic for me to understand.
>
> Your best bet is to re-install CPAN from scratch.  If I remember the
> situation right, it believes your .cpan directory is somewhere below
> some cgi-bin.  It doesn't belong there, and AFAIK this can only happen
> when the system-wide defaults are messed up.
>
> Anno




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

Date: Sat, 15 Feb 2003 14:07:39 +0000
From: Chris Lowth <dont@want.spam>
Subject: Re: Using Archive::Tar for in-memory tarfiles
Message-Id: <g%r3a.5392$MD6.1659337@newsfep2-win.server.ntli.net>

Eric Schwartz wrote:

> $ ./testtar data
> Use of uninitialized value in print at ./testtar line 13.
> 
> -=Eric

After a little bit of playing, it seems Archive::Tar has a bug in this area. 
You can overcome it like this (not slick, but it works!)

        use warnings;
        use strict;
        use Archive::Tar;

        my $tar = Archive::Tar->new();
        foreach my $file ( @ARGV ) {
                open( F, "< $file") or die;
                my $data = do { local $/; <F>; };
                close(F);
                $tar->add_files( $file );
                $tar->replace_content( $file, $data );
        }
        my $buf = $tar->write();
        
        open(OUT, "> out") || die;
        print OUT $buf;
        close(OUT);

Tested with perl 5.6.1 and Archive::Tar 0.22.

Hope this helps.

Chris
-- 
My real e-mail address is
chris <at> lowth <dot> 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 4570
***************************************


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