[22200] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4421 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 17 14:05:50 2003

Date: Fri, 17 Jan 2003 11:05:10 -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           Fri, 17 Jan 2003     Volume: 10 Number: 4421

Today's topics:
    Re: *** HELP perl/cgi script help output~ (Tad McClellan)
    Re: *** HELP perl/cgi script help output~ <bongie@gmx.net>
    Re: APL's relation to perl (Walter Roberson)
    Re: code to read /var/mail/USER <clay@panix.com>
    Re: CPAN install causes Winzip to Open and Error (Scott H)
    Re: CPAN install causes Winzip to Open and Error (Ben Morrow)
    Re: Equivalent of /g for unpack? (Ben Morrow)
    Re: Extraction from variable <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
    Re: Extraction from variable <jon@rogers.tv>
    Re: Extraction from variable Andrew Lee
    Re: Extraction from variable (Tad McClellan)
    Re: Extraction from variable <bongie@gmx.net>
    Re: Extraction from variable <usenet@tinita.de>
        How do I calculate today minus any given number (Sherman Willden)
    Re: How do I calculate today minus any given number <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
    Re: How do I calculate today minus any given number <TGVCDPVNTLMI@spammotel.com>
    Re: How do I calculate today minus any given number <perl-dvd@darklaser.com>
    Re: How do I calculate today minus any given number Andrew Lee
        more problems with storable. <spikey-wan@bigfoot.com>
    Re: more problems with storable. <bongie@gmx.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 17 Jan 2003 11:52:44 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: *** HELP perl/cgi script help output~
Message-Id: <slrnb2ggnc.4t4.tadmc@magna.augustmail.com>


[ Please limit your line lengths to the convention 70-72 characters ]


inderjit S Gabrie <i.gabrie@mis.gla.ac.uk> wrote:

> Subject: *** HELP perl/cgi script help output~
           ^^^ ^^^^                            ^
           ^^^ ^^^^                            ^

Playing "tricks" with your Subject header like that is likely to
*reduce* the number of people that open it up and read it.

In practice it has an effect opposite of what you were
likely trying to achieve.


> I am writing a perl/cgi script which will display a simple counter 


So they don't get overlooked in all of the other comments below,
let me point out here at the top the 2 major problems you have.


1) You have CGI or server setup problem rather than a Perl problem.
   You are looking for the problem in the wrong place.

2) You _must_ implement file locking, or your count can become corrupted.


>  i try to call it from my
> .shtml file by <!--exec
> cgi="/cgi-bin/count.cgi"--> etc etc i get the error " error processing
> directive ", any
> ideas where i am going wrong 


Try it with a dead-simple Perl program first. Replace count.cgi with:

   #!/usr/local/bin/perl
   use strict;
   use warnings;
   print "Hello from my SSI\n";

And try it again.

If it still errors out, then you do not have a Perl problem.

As a further check, run the same program from the command line.

If it runs from the command line, but does not run under the web
server, then that is a dead-giveaway that your problem is not
Perl related.

Problems with CGI/server setup are best asked in a newsgroup
where those topics are discussed, such as:

      comp.infosystems.www.authoring.cgi
      comp.infosystems.www.servers.unix


> #!/usr/local/bin/perl


You should ask for all the help you can get by enabling warnings
and strictures. Turning either one of those on would have caught
at least one problem that you probably haven't even noticed yet.
More on that below.

   #!/usr/local/bin/perl
   use strict;
   use warnings;


> $count = '/mnt/web/guide/aestheticsurgerycenter/test/count.dat';


Now that you have strictures turned on, you'll need to declare
your each variable the first time you use it:

   my $count = '/mnt/web/guide/aestheticsurgerycenter/test/count.dat';


> if ($ENV{'REMOTE_ADDR'} eq $your_ip) {
> }
> 
> else {


An empty block is most often an indicator that there is a "better way":

   if ($ENV{'REMOTE_ADDR'} ne $your_ip) {
                           ^^
or

   unless ($ENV{'REMOTE_ADDR'} eq $your_ip) {


>     open (COUNT, "$count");
                   ^      ^
                   ^      ^ a useless use of double quotes

You should always, yes *always*, check the return value from open():

   open (COUNT, $count) or die "could not open '$count'  $!";



>     $counter = <COUNT>;
>     close (COUNT);


Uh oh. Now you have a "race condition" that can lead to your
count data becoming corrupted. You need file locking:

   perldoc -q "\block"

      "How can I lock a file?"

      "Why can't I just open(FH, ">file.lock")?"

      "I still don't get locking.  I just want to increment 
       the number in the file.  How can I do this?"



>     $output = "<img src=\"$base_url$number$gif\" alt=\"$CNum\">";
                                                         ^^^^^

You never gave that variable a value. Warnings and/or strictures
would have caught that mistake for you, if you had turned them on.


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


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

Date: Fri, 17 Jan 2003 19:44:11 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: *** HELP perl/cgi script help output~
Message-Id: <1133555.acC8YAQWDm@nyoga.dubu.de>

Tad McClellan wrote:
> Try it with a dead-simple Perl program first. Replace count.cgi with:

At least Apache 1.x demands that an SSI processed CGI also sends an HTTP
header.

> 
>    #!/usr/local/bin/perl
>    use strict;
>    use warnings;

     use CGI qw(:standard);
     print header;

>    print "Hello from my SSI\n";
> 
> And try it again.

Ciao,
        Harald
-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Q: Why do programmers always get Christmas and Halloween mixed up?
A: Because DEC 25 = OCT 31



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

Date: 17 Jan 2003 16:35:28 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: APL's relation to perl
Message-Id: <b09bcg$1gf$1@canopus.cc.umanitoba.ca>

In article <rCRV9.24893$ZE1.524843@news1.nokia.com>,
J\(ust\) a\(nother\) phet <japhet@hushhushmail.com> wrote:
:Has perl herited anything from APL?
:If not should it?!

Yes, it inherited the idea that "There is always more than one way
to do things!".

It also inherited the thorn operator, but renamed it to '#'.
-- 
   Rump-Titty-Titty-Tum-TAH-Tee             -- Fritz Lieber


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

Date: Fri, 17 Jan 2003 17:45:34 +0000 (UTC)
From: Clay Irving <clay@panix.com>
Subject: Re: code to read /var/mail/USER
Message-Id: <slrnb2gg9u.6u6.clay@panix2.panix.com>

In article <6NVV9.593268$GR5.381437@rwcrnsc51.ops.asp.att.net>, Rich Buentello 
wrote:

> Does anyone have any code to read /var/mail/USER.  I need a way to determine
> if mail bounced or had any other errors.

open F, "/var/mail/USER" or die "$!\n";
while (<F>) {
   # do whatever you want to do...
}

-- 
Clay Irving <clay@panix.com>
I'm already not yet convinced. 
- Larry Wall


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

Date: 17 Jan 2003 08:23:28 -0800
From: shammond@att.com (Scott H)
Subject: Re: CPAN install causes Winzip to Open and Error
Message-Id: <8086c70d.0301170823.56973fb3@posting.google.com>

mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow) wrote in message news:<b04lfq$g1f$1@wisteria.csv.warwick.ac.uk>...
> shammond@att.com (Scott H) wrote:
> >I need your help.  OK, from the command prompt (Win2k box), I type
> >"perl -MCPAN -e shell", which brings me to the cpan> prompt.  I then
> >type install LWP::UserAgent and hit <enter>.  Every time, it pops up
> >Winzip like it wants me to add something to a zip file in
> >c:\perl\cpan\build\tmp\ dir.  There is nothing to add nor is there
> >anything in the main winzip window (that opened).  I also get a dialog
> >that says "winzip parameter validation error".
> >
> >I'm wondering if this is due to my original configuration.  I used the
> >c:\progra~1\winzip\winzip.exe file as the application for gzip, tar
> >and unzip config options.
> 
> I guess from this that you built Perl yourself?

No, I downloaded version 5.8 from ActiveState
(http://downloads.activestate.com/ActivePerl/Windows/5.8/ActivePerl-5.8.0.804-MSWin32-x86.msi).

> The solution to your problem is to rebuild Perl, specifying command-line
> tools to handle those things. The tools you want are called (surprise) gzip,
> tar and unzip, respectively. If you built Perl using Cygwin, then you can use
> the cygwin version out of c:/cygwin/bin (or wherever): you may need to install
> the packages with the cygwin package mangler. If you're using MinGW or VC then
> you can get versions from http://unxutils.sourceforge.net/. I can't quite
> work out from that page if it includes unzip or not: if it doesn't, there's a
> link to info-zip further down the page, who have Win32 native versions.
> 
> Ben

Actually, I think this is a result of my configuration of CPAN during
the manual config.  Here's my actual output right up to where it
launches Winzip.

******************

c:\Documents and Settings\Administrator>perl -MCPAN -e shell

cpan shell -- CPAN exploration and modules installation (v1.61)
ReadLine support available (try 'install Bundle::CPAN')

cpan> install LWP::UserAgent
CPAN: Storable loaded ok
Going to read C:\perl\cpan\Metadata
  Database was generated on Wed, 15 Jan 2003 09:48:19 GMT
Subroutine new redefined at C:/Perl/site/lib/LWP\UserAgent.pm line
162, <FIN> li
ne 1.
Subroutine _request_sanity_check redefined at
C:/Perl/site/lib/LWP\UserAgent.pm
line 237, <FIN> line 1.
Subroutine send_request redefined at C:/Perl/site/lib/LWP\UserAgent.pm
line 278,
 <FIN> line 1.
Subroutine prepare_request redefined at
C:/Perl/site/lib/LWP\UserAgent.pm line 3
80, <FIN> line 1.
Subroutine simple_request redefined at
C:/Perl/site/lib/LWP\UserAgent.pm line 41
4, <FIN> line 1.
Subroutine request redefined at C:/Perl/site/lib/LWP\UserAgent.pm line
433, <FIN
> line 1.
Subroutine get redefined at C:/Perl/site/lib/LWP\UserAgent.pm line
572, <FIN> li
ne 1.
Subroutine post redefined at C:/Perl/site/lib/LWP\UserAgent.pm line
577, <FIN> l
ine 1.
Subroutine head redefined at C:/Perl/site/lib/LWP\UserAgent.pm line
582, <FIN> l
ine 1.
Subroutine put redefined at C:/Perl/site/lib/LWP\UserAgent.pm line
587, <FIN> li
ne 1.
Subroutine is_protocol_supported redefined at
C:/Perl/site/lib/LWP\UserAgent.pm
line 647, <FIN> line 1.
Subroutine protocols_allowed redefined at
C:/Perl/site/lib/LWP\UserAgent.pm line
 686, <FIN> line 1.
Subroutine protocols_forbidden redefined at
C:/Perl/site/lib/LWP\UserAgent.pm li
ne 687, <FIN> line 1.
Subroutine requests_redirectable redefined at
C:/Perl/site/lib/LWP\UserAgent.pm
line 688, <FIN> line 1.
Subroutine redirect_ok redefined at C:/Perl/site/lib/LWP\UserAgent.pm
line 712,
<FIN> line 1.
Subroutine credentials redefined at C:/Perl/site/lib/LWP\UserAgent.pm
line 745,
<FIN> line 1.
Subroutine get_basic_credentials redefined at
C:/Perl/site/lib/LWP\UserAgent.pm
line 767, <FIN> line 1.
Subroutine agent redefined at C:/Perl/site/lib/LWP\UserAgent.pm line
807, <FIN>
line 1.
Subroutine _agent redefined at C:/Perl/site/lib/LWP\UserAgent.pm line
818, <FIN>
 line 1.
Subroutine timeout redefined at C:/Perl/site/lib/LWP\UserAgent.pm line
880, <FIN
> line 1.
Subroutine from redefined at C:/Perl/site/lib/LWP\UserAgent.pm line
881, <FIN> l
ine 1.
Subroutine parse_head redefined at C:/Perl/site/lib/LWP\UserAgent.pm
line 882, <
FIN> line 1.
Subroutine max_size redefined at C:/Perl/site/lib/LWP\UserAgent.pm
line 883, <FI
N> line 1.
Subroutine cookie_jar redefined at C:/Perl/site/lib/LWP\UserAgent.pm
line 885, <
FIN> line 1.
Subroutine conn_cache redefined at C:/Perl/site/lib/LWP\UserAgent.pm
line 899, <
FIN> line 1.
Subroutine use_eval redefined at C:/Perl/site/lib/LWP\UserAgent.pm
line 914, <FI
N> line 1.
Subroutine use_alarm redefined at C:/Perl/site/lib/LWP\UserAgent.pm
line 916, <F
IN> line 1.
Subroutine clone redefined at C:/Perl/site/lib/LWP\UserAgent.pm line
931, <FIN>
line 1.
Subroutine mirror redefined at C:/Perl/site/lib/LWP\UserAgent.pm line
958, <FIN>
 line 1.
Subroutine proxy redefined at C:/Perl/site/lib/LWP\UserAgent.pm line
1025, <FIN>
 line 1.
Subroutine env_proxy redefined at C:/Perl/site/lib/LWP\UserAgent.pm
line 1059, <
FIN> line 1.
Subroutine no_proxy redefined at C:/Perl/site/lib/LWP\UserAgent.pm
line 1090, <F
IN> line 1.
Subroutine _need_proxy redefined at C:/Perl/site/lib/LWP\UserAgent.pm
line 1104,
 <FIN> line 1.
Subroutine _new_response redefined at
C:/Perl/site/lib/LWP\UserAgent.pm line 112
7, <FIN> line 1.
CPAN: LWP::UserAgent loaded ok
Fetching with LWP:
  ftp://archive.progeny.com/CPAN/authors/01mailrc.txt.gz
Going to read C:\perl\cpan\sources\authors\01mailrc.txt.gz
Subroutine AUTOLOAD redefined at C:/Perl/site/lib/Compress\Zlib.pm
line 84, <FIN
> line 1.
Subroutine isaFilehandle redefined at
C:/Perl/site/lib/Compress\Zlib.pm line 99,
 <FIN> line 1.
Subroutine isaFilename redefined at C:/Perl/site/lib/Compress\Zlib.pm
line 108,
<FIN> line 1.
Subroutine gzopen redefined at C:/Perl/site/lib/Compress\Zlib.pm line
115, <FIN>
 line 1.
Subroutine ParseParameters redefined at
C:/Perl/site/lib/Compress\Zlib.pm line 1
31, <FIN> line 1.
Subroutine deflateInit redefined at C:/Perl/site/lib/Compress\Zlib.pm
line 193,
<FIN> line 1.
Subroutine inflateInit redefined at C:/Perl/site/lib/Compress\Zlib.pm
line 202,
<FIN> line 1.
Subroutine compress redefined at C:/Perl/site/lib/Compress\Zlib.pm
line 209, <FI
N> line 1.
Subroutine uncompress redefined at C:/Perl/site/lib/Compress\Zlib.pm
line 237, <
FIN> line 1.
Constant subroutine Compress::Zlib::MAGIC1 redefined at
C:/Perl/lib/constant.pm
line 108, <FIN> line 1.
Constant subroutine Compress::Zlib::MAGIC2 redefined at
C:/Perl/lib/constant.pm
line 108, <FIN> line 1.
Constant subroutine Compress::Zlib::OSCODE redefined at
C:/Perl/lib/constant.pm
line 108, <FIN> line 1.
Constant subroutine Compress::Zlib::FTEXT redefined at
C:/Perl/lib/constant.pm l
ine 108, <FIN> line 1.
Constant subroutine Compress::Zlib::FHCRC redefined at
C:/Perl/lib/constant.pm l
ine 108, <FIN> line 1.
Constant subroutine Compress::Zlib::FEXTRA redefined at
C:/Perl/lib/constant.pm
line 108, <FIN> line 1.
Constant subroutine Compress::Zlib::FNAME redefined at
C:/Perl/lib/constant.pm l
ine 108, <FIN> line 1.
Constant subroutine Compress::Zlib::FCOMMENT redefined at
C:/Perl/lib/constant.p
m line 108, <FIN> line 1.
Constant subroutine Compress::Zlib::NULL redefined at
C:/Perl/lib/constant.pm li
ne 108, <FIN> line 1.
Constant subroutine Compress::Zlib::RESERVED redefined at
C:/Perl/lib/constant.p
m line 108, <FIN> line 1.
Constant subroutine Compress::Zlib::MIN_HDR_SIZE redefined at
C:/Perl/lib/consta
nt.pm line 108, <FIN> line 1.
Subroutine memGzip redefined at C:/Perl/site/lib/Compress\Zlib.pm line
276, <FIN
> line 1.
Subroutine _removeGzipHeader redefined at
C:/Perl/site/lib/Compress\Zlib.pm line
 307, <FIN> line 1.
Subroutine memGunzip redefined at C:/Perl/site/lib/Compress\Zlib.pm
line 366, <F
IN> line 1.
Subroutine Compress::Zlib::constant redefined at
C:/Perl/site/lib/Compress\Zlib.
pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::zlib_version redefined at
C:/Perl/site/lib/Compress\Z
lib.pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::gzopen_ redefined at
C:/Perl/site/lib/Compress\Zlib.p
m line 94, <FIN> line 1.
Subroutine Compress::Zlib::gzdopen_ redefined at
C:/Perl/site/lib/Compress\Zlib.
pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::gzFile::gzread redefined at
C:/Perl/site/lib/Compress
\Zlib.pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::gzFile::gzreadline redefined at
C:/Perl/site/lib/Comp
ress\Zlib.pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::gzFile::gzwrite redefined at
C:/Perl/site/lib/Compres
s\Zlib.pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::gzFile::gzflush redefined at
C:/Perl/site/lib/Compres
s\Zlib.pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::gzFile::gzclose redefined at
C:/Perl/site/lib/Compres
s\Zlib.pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::gzFile::DESTROY redefined at
C:/Perl/site/lib/Compres
s\Zlib.pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::gzFile::gzerror redefined at
C:/Perl/site/lib/Compres
s\Zlib.pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::adler32 redefined at
C:/Perl/site/lib/Compress\Zlib.p
m line 94, <FIN> line 1.
Subroutine Compress::Zlib::crc32 redefined at
C:/Perl/site/lib/Compress\Zlib.pm
line 94, <FIN> line 1.
Subroutine Compress::Zlib::_deflateInit redefined at
C:/Perl/site/lib/Compress\Z
lib.pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::_inflateInit redefined at
C:/Perl/site/lib/Compress\Z
lib.pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::deflateStream::deflate redefined at
C:/Perl/site/lib/
Compress\Zlib.pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::deflateStream::DESTROY redefined at
C:/Perl/site/lib/
Compress\Zlib.pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::deflateStream::flush redefined at
C:/Perl/site/lib/Co
mpress\Zlib.pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::deflateStream::dict_adler redefined at
C:/Perl/site/l
ib/Compress\Zlib.pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::deflateStream::msg redefined at
C:/Perl/site/lib/Comp
ress\Zlib.pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::inflateStream::__unc_inflate redefined at
C:/Perl/sit
e/lib/Compress\Zlib.pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::inflateStream::inflate redefined at
C:/Perl/site/lib/
Compress\Zlib.pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::inflateStream::DESTROY redefined at
C:/Perl/site/lib/
Compress\Zlib.pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::inflateStream::dict_adler redefined at
C:/Perl/site/l
ib/Compress\Zlib.pm line 94, <FIN> line 1.
Subroutine Compress::Zlib::inflateStream::msg redefined at
C:/Perl/site/lib/Comp
ress\Zlib.pm line 94, <FIN> line 1.
CPAN: Compress::Zlib loaded ok
Fetching with LWP:
  ftp://archive.progeny.com/CPAN/modules/02packages.details.txt.gz
Going to read C:\perl\cpan\sources\modules\02packages.details.txt.gz
  Database was generated on Fri, 17 Jan 2003 06:51:49 GMT
Subroutine time2str redefined at C:/Perl/site/lib/HTTP\Date.pm line
23.
Subroutine str2time redefined at C:/Perl/site/lib/HTTP\Date.pm line
35.
Subroutine parse_date redefined at C:/Perl/site/lib/HTTP\Date.pm line
85.
Subroutine time2iso redefined at C:/Perl/site/lib/HTTP\Date.pm line
241.
Subroutine time2isoz redefined at C:/Perl/site/lib/HTTP\Date.pm line
251.
CPAN: HTTP::Date loaded ok

  There's a new CPAN.pm version (v1.63) available!
  [Current version is v1.61]
  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://archive.progeny.com/CPAN/modules/03modlist.data.gz
Going to read C:\perl\cpan\sources\modules\03modlist.data.gz
Going to write C:\perl\cpan\Metadata
Running install for module LWP::UserAgent
Running make for G/GA/GAAS/libwww-perl-5.68.tar.gz
CPAN: Digest::MD5 loaded ok
Checksum for C:\perl\cpan\sources\authors\id\G\GA\GAAS\libwww-perl-5.68.tar.gz
ok

****************

This is where winzip pops up with an "Add to archive window" for
c:\Perl\cpan\build\tmp directory.

Scott


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

Date: Fri, 17 Jan 2003 19:02:34 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: CPAN install causes Winzip to Open and Error
Message-Id: <b09k0a$nip$1@wisteria.csv.warwick.ac.uk>

shammond@att.com (Scott H) wrote:
>mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow) wrote in message news:<b04lfq$g1f$1@wisteria.csv.warwick.ac.uk>...
>> shammond@att.com (Scott H) wrote:
>> >I need your help.  OK, from the command prompt (Win2k box), I type
>> >"perl -MCPAN -e shell", which brings me to the cpan> prompt.  I then
>> >type install LWP::UserAgent and hit <enter>.  Every time, it pops up
>> >Winzip like it wants me to add something to a zip file in
>> >c:\perl\cpan\build\tmp\ dir.  There is nothing to add nor is there
>> >anything in the main winzip window (that opened).  I also get a dialog
>> >that says "winzip parameter validation error".
>> >
>> >I'm wondering if this is due to my original configuration.  I used the
>> >c:\progra~1\winzip\winzip.exe file as the application for gzip, tar
>> >and unzip config options.
>> 
>> I guess from this that you built Perl yourself?
>
>No, I downloaded version 5.8 from ActiveState
>(http://downloads.activestate.com/ActivePerl/Windows/5.8/ActivePerl-5.8.0.804-MSWin32-x86.msi).

Oh, right, sorry. In which case, why don't you just use PPM?

<snip my wrong answer :>

>Actually, I think this is a result of my configuration of CPAN during
>the manual config.  Here's my actual output right up to where it
>launches Winzip.
>
>******************
>
>c:\Documents and Settings\Administrator>perl -MCPAN -e shell
>
>cpan shell -- CPAN exploration and modules installation (v1.61)
>ReadLine support available (try 'install Bundle::CPAN')
>
>cpan> install LWP::UserAgent
>CPAN: Storable loaded ok
>Going to read C:\perl\cpan\Metadata
>  Database was generated on Wed, 15 Jan 2003 09:48:19 GMT
>Subroutine new redefined at C:/Perl/site/lib/LWP\UserAgent.pm line
>162, <FIN> li
>ne 1.

<snip _lots_ more of this, then more in Compress::Zlib and HTTP::Date>

>Fetching with LWP:
>  ftp://archive.progeny.com/CPAN/modules/03modlist.data.gz
>Going to read C:\perl\cpan\sources\modules\03modlist.data.gz
>Going to write C:\perl\cpan\Metadata
>Running install for module LWP::UserAgent
>Running make for G/GA/GAAS/libwww-perl-5.68.tar.gz
>CPAN: Digest::MD5 loaded ok
>Checksum for C:\perl\cpan\sources\authors\id\G\GA\GAAS\libwww-perl-5.68.tar.gz
>ok
>
>****************
>
>This is where winzip pops up with an "Add to archive window" for
>c:\Perl\cpan\build\tmp directory.

Right.
Now, firstly, do you not have LWP::UserAgent installed already? Something in
your system seems to be in a right royal mess.
Secondly, yes, the answer to your OQ is to delete your .cpan directory (looks
like it is c:\Perl\cpan) and start again. This should make CPAN.pm reconfigure
itself, and you can give it proper utils this time.
Thirdly, why are you using CPAN.pm? Try ppm. You realise you need a C compiler
for CPAN.pm to work for most modules?

Ben


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

Date: Fri, 17 Jan 2003 18:34:04 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Equivalent of /g for unpack?
Message-Id: <b09ias$lru$1@wisteria.csv.warwick.ac.uk>

adwser@hotmail.com (jtd) wrote:
>Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:
>> Reading from a file, then performing substr() on the data sounds rather
>> innefficient.
>> 
>> You probably want something like this:
>
>Thanks, can I do something similar with strings in memory? I need to
>separate unpacking from file access for a number of reasons.

Well, you could use 5.8's PerlIO::scalar... :)

Ben


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

Date: Fri, 17 Jan 2003 17:20:39 +0100
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: Extraction from variable
Message-Id: <newscache$fe9v8h$wfb$1@news.emea.compuware.com>

Tad McClellan wrote (Friday 17 January 2003 16:39):

>> ...to extract only the letters and the digits, how should I do
>> what?

>    $var =~ s/[^a-zA-Z0-9]+//g;


Gee, this works indeed. But how then in s/ mode? Matching ( m/ ) for targets 
is one thing. But substituting the targets with // and still ending up with 
the targets (even if /g) is beyond me. Does /g make it remember and return 
the intermediate matches and throw away the result? And what does the ^ do 
in this case? 

-- 
KP



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

Date: Fri, 17 Jan 2003 18:50:01 +0100
From: Jon Rogers <jon@rogers.tv>
Subject: Re: Extraction from variable
Message-Id: <3E284243.E6C08704@rogers.tv>


Would this mean that $var now is untainted if I use -T mode?

/ Jonas

>    $var =~ s/[^a-zA-Z0-9]+//g;
> 
> or if you don't mind leaving underscores in:


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

Date: Fri, 17 Jan 2003 12:47:47 -0500
From: Andrew Lee
Subject: Re: Extraction from variable
Message-Id: <97gg2vsnv3m9vjeqrdt9dfat75nnbum226@4ax.com>

On Fri, 17 Jan 2003 17:20:39 +0100, Koos Pol
<koos_pol@NO.nl.JUNK.compuware.MAIL.com> wrote:

>Tad McClellan wrote (Friday 17 January 2003 16:39):
>
>>> ...to extract only the letters and the digits, how should I do
>>> what?
>
>>    $var =~ s/[^a-zA-Z0-9]+//g;
>
>
>Gee, this works indeed. But how then in s/ mode? Matching ( m/ ) for targets 
>is one thing. But substituting the targets with // and still ending up with 
>the targets (even if /g) is beyond me. Does /g make it remember and return 
>the intermediate matches and throw away the result? And what does the ^ do 
>in this case? 

The ^ is the NOT operator in this case (as opposed to start of line
anchor).  So [^a-zA-Z0-9] is the class of characters not listed (i.e.
non-alphanumerics).  The /g modifier tells the operation to be greedy
and not stop at the first match.

HTH



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

Date: Fri, 17 Jan 2003 11:01:08 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Extraction from variable
Message-Id: <slrnb2gdmk.4t4.tadmc@magna.augustmail.com>

Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com> wrote:
> Tad McClellan wrote (Friday 17 January 2003 16:39):
> 
>>> ...to extract only the letters and the digits, how should I do
>>> what?
> 
>>    $var =~ s/[^a-zA-Z0-9]+//g;
> 
> 
> Gee, this works indeed. But how then in s/ mode?


> And what does the ^ do 
> in this case? 


Makes it work.  :-)

Caret in a char class "negates" the class, akin to "c" in tr///c


From the "Version 8 Regular Expressions" section in perlre.pod

   If the first character after the "[" is "^", the class matches 
   any character not in the list.


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


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

Date: Fri, 17 Jan 2003 19:21:39 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: Extraction from variable
Message-Id: <1406705.XSpfgeNm4p@nyoga.dubu.de>

Jon Rogers wrote:
> If I from
> $var="abcdef12376&%%€%##56/)&";
> would like to extract only the letters and the digits, how should I do
> what?

# Changing the variable itself
$var =~ y/a-zA-Z0-9//cd;

# Assigning to a new, "clean" variable
(my $new = $var) =~ y/a-zA-Z0-9//cd;

Ciao,
        Harald
-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Interesting Error Messages #8:
Press [ESC] to detonate or any other key to explode. 



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

Date: 17 Jan 2003 18:38:46 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: Extraction from variable
Message-Id: <b09ijm$n8766$1@ID-24002.news.dfncis.de>

Tad McClellan <tadmc@augustmail.com> wrote:
> Jon Rogers <jon@rogers.tv> wrote:
>> If I from
>> $var="abcdef12376&%%€%##56/)&";
>> would like to extract only the letters and the digits, how should I do what?

>    $var =~ s/[^a-zA-Z0-9]+//g;

or:
  $var =~ tr/a-zA-Z0-9//cd;

regards, tina


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

Date: 17 Jan 2003 08:14:57 -0800
From: sherman.willden@hp.com (Sherman Willden)
Subject: How do I calculate today minus any given number
Message-Id: <3a80d8d6.0301170814.7edf7c07@posting.google.com>

Problem: Given today minus some number I have to know what that past
date is. Example: If the user enters 30, what is the date 30 days ago
from today. Today is 01/17/03 so what is the algorithm to return the
December 2002 date?

I have reviewed the faq and some past messages but I didn't find this
particular problem. I probably have to use Date::Calc but I'm not
sure. I have found some add routines but I didn't see any subtract
routines.

Thanks;

Sherman L. Willden
(719)548-2852
sherman.willden@hp.com


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

Date: Fri, 17 Jan 2003 17:22:47 +0100
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: How do I calculate today minus any given number
Message-Id: <newscache$zh9v8h$wfb$1@news.emea.compuware.com>

Sherman Willden wrote (Friday 17 January 2003 17:14):

> Problem: Given today minus some number I have to know what that past
> date is. Example: If the user enters 30, what is the date 30 days ago
> from today. Today is 01/17/03 so what is the algorithm to return the
> December 2002 date?
> 
> I have reviewed the faq and some past messages but I didn't find this
> particular problem. I probably have to use Date::Calc but I'm not
> sure. I have found some add routines but I didn't see any subtract
> routines.


Date::Manip can do this for you.


-- 
KP



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

Date: Fri, 17 Jan 2003 17:51:10 +0100
From: Ron Blaschke <TGVCDPVNTLMI@spammotel.com>
Subject: Re: How do I calculate today minus any given number
Message-Id: <jeyjwy6oyq3y$.1etg49t11j0o9$.dlg@40tude.net>

On 17 Jan 2003 08:14:57 -0800, Sherman Willden wrote:

> Problem: Given today minus some number I have to know what that past
> date is. Example: If the user enters 30, what is the date 30 days ago
> from today. Today is 01/17/03 so what is the algorithm to return the
> December 2002 date?

How about:

use Date::Calc qw(Add_Delta_Days Today);
use strict;

my ($year, $month, $day) = Add_Delta_Days(Today, -30);
print "$year-$month-$day\n";


Cheers,
Ron


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

Date: Fri, 17 Jan 2003 17:02:24 GMT
From: "David" <perl-dvd@darklaser.com>
Subject: Re: How do I calculate today minus any given number
Message-Id: <AGWV9.23$q81.7138@news-west.eli.net>

"Sherman Willden" <sherman.willden@hp.com> wrote in message
news:3a80d8d6.0301170814.7edf7c07@posting.google.com...
> Problem: Given today minus some number I have to know what that past
> date is. Example: If the user enters 30, what is the date 30 days ago
> from today. Today is 01/17/03 so what is the algorithm to return the
> December 2002 date?
>
> I have reviewed the faq and some past messages but I didn't find this
> particular problem. I probably have to use Date::Calc but I'm not
> sure. I have found some add routines but I didn't see any subtract
> routines.

There's really no need to use an external module, Perl does all this for
you with a combination of time() and localtime().  time() and
localtime() deal with time in second since epoch (jan 1 midnight of
1970)
Note: my code looks much longer than it needs to be because I added a
bunch of comments for you

##############################################
my $daysago = 30;
my @date = localtime(time() - ($daysago * 86400));
# elements
# $date[0] seconds
# $date[1] minutes
# $date[2] hours 0 based military time
# $date[3] day of the month
# $date[4] month 0 based, 0 = Jan
# $date[5] year minus 1900
# $date[6] day of the week, 0 = Sun, 1 = Mon
# $date[7] day of the year 0 based 0 - 364
# $date[8] is daylight savings time in effect

$date[4]++; # make month 1 based
$date[5] += 1900; # fix year
##############################################

At this point, you have all of your date and time pieces, and you can
format your date string however you want.

Regards,
David




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

Date: Fri, 17 Jan 2003 13:18:10 -0500
From: Andrew Lee
Subject: Re: How do I calculate today minus any given number
Message-Id: <1ohg2v4dmcpoc34qrjr38ihs46n6vjc6a4@4ax.com>

On 17 Jan 2003 08:14:57 -0800, sherman.willden@hp.com (Sherman
Willden) wrote:

>Problem: Given today minus some number I have to know what that past
>date is. Example: If the user enters 30, what is the date 30 days ago
>from today. Today is 01/17/03 so what is the algorithm to return the
>December 2002 date?
>

You can use localtime().

my $cur_time = time();	# utime 
my $prev_time = $cur_time - 60*60*24*30;	  # 30 days ago
print localtime($prev_time), "\n";

(untested)


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

Date: Fri, 17 Jan 2003 16:56:56 -0000
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: more problems with storable.
Message-Id: <b09cmb$loi$1@newshost.mot.com>

Hello World!

I'm still having trouble with storable...

My script first checks to see if the storage file exists, and if so, it
loads it, otherwise it sets the hash to its default values, like this...

use strict;
use warnings;
use Storable;
use Tk;
use Tk::LabEntry;
my %vars;
my $entry;

# Load saved variables, or use default values.
my $ref = retrieve 'saved.dat' if -e 'saved.dat';

if ($ref) {
 print "Saved values found\n\n";
 %vars = $ref;
} else {
 print "Using default values\n\n";
 %vars = (
  dog_name => {
   question => "Please enter your dog's name: ",
   answer  => "Rover",
   order  => 1,
   entry  => undef,
   },
  fav_food => {
   question => "What is your favourite food? ",
   answer  => "Cheese",
   order  => 2,
   entry  => undef,
   },
  testicles => {
   question => "How many testicles do you have? ",
   answer  => 3,
   order  => 3,
   entry  => undef,
   },
  fear => {
   question => "What is your biggest fear? ",
   answer  => "Elephants",
   order  => 4,
   entry  => undef,
   },
  );
}

When you press the save values button, it does this...

sub savevalues{
 &get_values;
 store \%vars, 'saved.dat';
 print "save complete\n";
}

When I run this (obviously incomplete) script, and the file saved.dat
doesn't exist, all is well. If I press the save values button, then exit and
re-run, I get the following error:

Saved values found

Reference found where even-sized list expected at hash3.pl line 14.

What am I doing wrong?
What do I have to do to get the values from saved.dat back into the %vars
hash, correctly?

Thanks.

R.





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

Date: Fri, 17 Jan 2003 19:35:44 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: more problems with storable.
Message-Id: <1167751.VliVIbM0mH@nyoga.dubu.de>

Richard S Beckett wrote:
> I'm still having trouble with storable...

Didn't you read Ben's response?
(Message-ID: <b06qfe$gkm$1@wisteria.csv.warwick.ac.uk>)

[...]
> # Load saved variables, or use default values.
> my $ref = retrieve 'saved.dat' if -e 'saved.dat';

I would prefer
        ... if -f 'saved.dat' && -r _;
to check if it's a plain file and readable.

> if ($ref) {
>  print "Saved values found\n\n";
>  %vars = $ref;

See Ben's posting:
        %vars = %$ref;

Ciao,
        Harald
-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Interesting Error Messages #5:
REALITY.SYS corrupted- reboot Universe (Y/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.  

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


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