[15819] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3232 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 2 03:05:37 2000

Date: Fri, 2 Jun 2000 00:05:10 -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: <959929509-v9-i3232@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 2 Jun 2000     Volume: 9 Number: 3232

Today's topics:
    Re: [Golf] Re: wc for perl <lr@hpl.hp.com>
    Re: AAAARRRRGGHHH! Please help <herr_stumpfenstiel@lycosmail.com>
        Any Zmodem module? dial, connect, upload and disconnect <johnlin@chttl.com.tw>
    Re: Case-Insensitive String Comparison <herr_stumpfenstiel@lycosmail.com>
        cgi- perl local..what in action="???"  (Jungle101)
        code cleanup <bill@billcampbell.com>
    Re: code cleanup (Neil Kandalgaonkar)
        cookie and login script <firdaus@mimos.my>
    Re: Cookies stopped working w/Perl 5.6 jbrzezi@my-deja.com
    Re: file dates being reported incorrectly..... <scumjr@deja.com>
    Re: Get the time, plus one hour (was: code cleanup) <phill@modulus.com.au>
        Installation of Perl5004_05 <andrewlam@oub.com.sg>
    Re: my Foo $self = shift; <tina@streetmail.com>
    Re: my Foo $self = shift; (Sam Holden)
        mysql insertid kenny@barmeister.com
    Re: Net::FTP question : Can I get control back on timeo <dan@tuatha.sidhe.org>
    Re: Non-reuse of memory for lexically-scoped variables? <dan@tuatha.sidhe.org>
    Re: Non-reuse of memory for lexically-scoped variables? zenin@bawdycaste.org
    Re: overriding Config.pm? <dan@tuatha.sidhe.org>
    Re: Perl unusable as a programming language <kaleja@estarcion.com>
    Re: Perl unusable as a programming language (Ilya Zakharevich)
        Please Help!!! Writing data file on Two Unix Servers... attama@my-deja.com
        Please Help!!! Writing data file on Two Unix Servers... attama@my-deja.com
    Re: the end of perl? <elaine@chaos.wustl.edu>
    Re: Very silly question <eg344@nyu.edu>
        webget failure <binary3418@my-deja.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 1 Jun 2000 18:17:12 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: [Golf] Re: wc for perl
Message-Id: <MPG.13a0aaf4eab32b3a98ab1a@nntp.hpl.hp.com>

In article <8h69sa$u8t$1@newsflash.concordia.ca> on 1 Jun 2000 18:26:18 
GMT, Neil Kandalgaonkar <nj_kanda@alcor.concordia.ca> says...
> In article <8h67oi$ntb$1@news.panix.com>, Abigail <abigail@arena-i.com> wrote:
> 
> >    perl -pale '$c+=length;$w+=@F}{$_="$. $w $c"'
> 
> $ wc testfile
>     297     850   13974 testfile
>                   ^^^^^
> $ perl -pale '$c+=length;$w+=@F}{$_="$. $w $c"' testfile
> 297 850 13677
>         ^^^^^
> 
> The culprit appears to be -l, which chomps away newlines. So you can do:
> 
> $ perl -pae '$c+=length;$w+=@F}{$_="$. $w $c\n"' testfile
> 297 850 13974
> 
> or, saving a few characters more:
> 
> $ perl -pale '$w+=@F}{$_="$. $w ".-s$ARGV' testfile     
> 297 850 13974

That trick doesn't work on Windows/DOS text files, because the line 
endings are two characters on the device (as reported by -s), but one 
character internally (as reported by length()).

So one has to resort to (-s $ARGV - $.) for the character count.

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


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

Date: Fri, 2 Jun 2000 02:51:33 +0200
From: "Herr Stumpfenstiel" <herr_stumpfenstiel@lycosmail.com>
Subject: Re: AAAARRRRGGHHH! Please help
Message-Id: <8h70b4$cdq62@mx2.hrz.uni-essen.de>

"Larry Rosler" <lr@hpl.hp.com> schrieb im Newsbeitrag
news:MPG.139f35bf40fab2ba98ab12@nntp.hpl.hp.com...
> In article <8h3u7v$8jg37@mx2.hrz.uni-essen.de> on Wed, 31 May 2000
> 22:57:17 +0200, Herr Stumpfenstiel <herr_stumpfenstiel@lycosmail.com>
> says...
> > Hmm, we should close the file, shouldn't we?
>
> Why?  What do you expect to happen when the program finishes execution?
>
> You *need* to close a file if it is to be used before execution
> terminates, especially on systems that cannot rename or unlink open
> files (such as Windows/DOS).
>
> You might want to close a file for logical clarity (close right after
> finishing the writing, for example), or simply to free up the resources >
used by the open file.
>
> You surely want to close a file that is a pipe, so you can check for
> successful execution.
>
> The case in question here is trivial, and none of the above.

You are right. In *this* case it's trivial to close the file. But I think
it's a good habit to close a file after it was opened, because

- you might want to expand the script later on, and you won't remember that
you've opened the file before. Then you'll try to delete the file and it
won't work. (Your argument)

- if you open the file for writing, other processes won't be able to read
the data you've written to it until you close the file or your script
ends. (I don't know if this is valid for Unix)

- it gives you a good feeling to close a file which you've opened :-)

I've to confess that it isn't an error not to close the file, but a matter
of taste. And therefore this doesn't fit in the above cases.

herr_stumpfenstiel@lycosmail.com




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

Date: Fri, 2 Jun 2000 09:11:45 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Any Zmodem module? dial, connect, upload and disconnect
Message-Id: <8h71j5$lki@netnews.hinet.net>

Dear all,

I am looking for Perl programs or modules to transfer files
through modem, but not found at CPAN.  Do any of you ever
heard of such implementation (Win32 version preferred)?

Thank you.

John Lin





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

Date: Fri, 2 Jun 2000 03:49:02 +0200
From: "Herr Stumpfenstiel" <herr_stumpfenstiel@lycosmail.com>
Subject: Re: Case-Insensitive String Comparison
Message-Id: <8h73mv$8jg38@mx2.hrz.uni-essen.de>

"Courtney Tompos" <cdt9@cornell.edu> schrieb im Newsbeitrag
news:8h6ufm$o2p$1@news01.cit.cornell.edu...
> Warning: Newbie =)
>
> That said, I want to compare two strings to check whether one ($var2) is a
> substring of the other ($var1). Thus the first thing I did was $var1 =~
> $var2. Now here's my question! How can I alter the code so that its not
> case-sensitive?
>
> $var1 = "Thesaurus";
> $var2 = "THE";
>
> The check should return true, given these variables.

You shouldn't use regular expressions unless you can be sure that there
aren't any wildcards like [*+.] in $var2. ($var2 = "THE+" would match THE,
THEE, THEEE, ...)

You *could* use (If there aren't any wildcards)
$var1 =~ /$var2/i;
to match case insensitive (see perlre)

But you should use the index function (see perlfunc)
index(lc $var1, lc $var2) != -1;
This returns true if, and only if $var2 is a (case insensitive) substring of
$var1.

If you have modified $[, then you should use:
index(lc $var1, lc $var2) != $[ - 1;

If you only want to match at the beginning of $var1 (i.e. $var2 = "Sau"
shouldn't match) then you can use
!index(lc $var1, lc $var2);

Could be a FAQ?

herr_stumpfenstiel@lycosmail.com





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

Date: 02 Jun 2000 03:52:04 GMT
From: jungle101@aol.com (Jungle101)
Subject: cgi- perl local..what in action="???" 
Message-Id: <20000601235204.17229.00000013@ng-ff1.aol.com>

Anyone use Microsoft Personal Web Server all local and try cgi perl?
Can't get anything in ACTION keyword to work.
Thanks in advance.


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

Date: Fri, 02 Jun 2000 03:56:44 GMT
From: "Bill" <bill@billcampbell.com>
Subject: code cleanup
Message-Id: <0gGZ4.138886$55.2945335@news2.rdc1.on.home.com>

I'm still new to PERL. Below, I've posted my very S L O P P Y and slow
solution to my attempt to obtain the time 1 hour from the current time in a
particular format. I think I have indented it such that someone would easily
be able to offer suggestions on cleaning it up ? My main problem wasn't in
obtaining 1 hour from the current time so much as figuring out how to put it
in the required format. I am using Win2000 for my system "date" and "time"
calls. Here is the working code (and yes I realize this won't accomodate Feb
29 - hopefully I will have something better by then):

$curtimefile="curtime.xxx";
$curdatefile="curdate.xxx";

system "time /t > $curtimefile";
open MFILE, "<$curtimefile" || die "help!";
read MFILE, $hh, 2;     # hour
read MFILE, $sp, 1;     # next character (don't need it)
read MFILE, $min, 2;    # minute
close MFILE;

system "date /t > $curdatefile";
open MFILE, "<$curdatefile" || die "help!";
read MFILE, $ww, 3;     # day of week
read MFILE, $sp, 1;     # next character (don't need it)
read MFILE, $mm, 2;     # month
read MFILE, $sp, 1;     # next character (don't need it)
read MFILE, $dd, 2;     # day of month
read MFILE, $sp, 1;     # next character (don't need it)
read MFILE, $yy, 4;     # year
close MFILE;

$hh++;        # increment the hour

if ($hh eq "24") {
        $daychange = "1";
        $hh = "00";
}

if ($daychange eq "1") {
        if ($ww eq "Mon") {
                $ww = "Tue";
        } elsif ($ww eq "Tue") {
                $ww = "Wed";
        } elsif ($ww eq "Wed") {
                $ww = "Thu";
        } elsif ($ww eq "Thu") {
                $ww = "Fri";
        } elsif ($ww eq "Fri") {
                $ww = "Sat";
        } elsif ($ww eq "Sat") {
                $ww = "Sun";
        } else {
                $ww = "Mon";
        }
        $dd++
}

if ($dd eq "32") {
        $dd = "01";
        $mm++;
}

if (($dd eq "31") && (($mm eq "04") || ($mm eq "06") || ($mm eq "09") ||
($mm eq "11"))){
                $dd = "01";
                $mm++;
}

if (($dd eq "29") && ($mm eq "02")) {
      $dd = "01";
      $mm++;
}

if ($mm eq "13") {
      $mm = "01";
      $yy++;
}

@months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
"Oct", "Nov", "Dec");
$newmm = $months[--$mm];

$newline = "\"$ww, $dd-$newmm-$yy $hh:$min:00 GMT\"";
print "one hour from now is $newline";







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

Date: 2 Jun 2000 05:06:03 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: code cleanup
Message-Id: <8h7fbr$6fd$1@newsflash.concordia.ca>

In article <0gGZ4.138886$55.2945335@news2.rdc1.on.home.com>,
Bill <bill@billcampbell.com> wrote:
>I'm still new to PERL. Below, I've posted my very S L O P P Y and slow
>solution to my attempt to obtain the time 1 hour from the current time in a
>particular format. I think I have indented it such that someone would easily
>be able to offer suggestions on cleaning it up ? My main problem wasn't in
>obtaining 1 hour from the current time so much as figuring out how to put it
>in the required format. I am using Win2000 for my system "date" and "time"
>calls. Here is the working code (and yes I realize this won't accomodate Feb
>29 - hopefully I will have something better by then):

>$newline = "\"$ww, $dd-$newmm-$yy $hh:$min:00 GMT\"";

I don't have a windows system handy, but this works on linux. Alter the
shebang line (the #! line) to whatever works on Windows.

  #!/usr/bin/perl -w
    
  use strict;
  my @month = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
  my @weekday = qw(Sun Mon Tue Wed Thu Fri Sat);
    
  my ($sec, $min, $hr, $mday, $mon, $yr, $wkday) = gmtime ( time + 60 * 60 );
  $yr += 1900;
    
  my $hour_later = 
       sprintf("%s, %02d-%s-%04d %02d:%02d:%02d GMT",
                $weekday[$wkday], $mday, $month[$mon], $yr, $hr, $min, $sec);
    

You will find documentation on all the above functions in 
perldoc perlfunc and partly in perldoc perlop. 

Also check out localtime(), and possibly the module Time::Local.


-- 
Neil Kandalgaonkar
neil@brevity.org


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

Date: Fri, 02 Jun 2000 09:36:46 +0800
From: Firdaus Mah <firdaus@mimos.my>
Subject: cookie and login script
Message-Id: <39370FAE.B2E51DC9@mimos.my>

Hi,
Need some help in trying to create cookies in perl on an apache linux
machine.

1. Do I need to configure in Apache to enable cookie?
2. Anyone can recommend a site which has a good perl login example using
cookies.

thanks
firdaus



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

Date: Fri, 02 Jun 2000 01:27:46 GMT
From: jbrzezi@my-deja.com
Subject: Re: Cookies stopped working w/Perl 5.6
Message-Id: <8h72ia$p83$1@nnrp1.deja.com>

Eric,

It looks like I had the same problem.
In our case it helped to set PATH value for a cookie. Without setting
it the cookies came back empty.

However we still have problem with modifying/expiring cookies. It looks
like the cookies can not be modified or experied.
If you know how to modify/expire them succesfully please let me know.

Thanks,
Jerzy (jerzy@nando.net)


In article <8h66ar$71e$1@nnrp1.deja.com>,
  ericwinslow@yahoo.com wrote:
> Hello.
>
> I've been using cookies with CGI.pm under 5.005_04 without problems. I
> installed 5.6 on another Solaris 2.6 machine and the same 'working'
> cookie code refused to work. Retrieving the cookie always came up
empty-
> handed. Has anybody else encountered problems with 5.6 in this way? I
> checked out the documentation regarding changes in 5.6 and the latest
> version of CGI.pm, but came across nothing that would have indicated
> that I needed to change anything. Code is below:
>
> Set Cookie:
> ----------
> #!/usr/bin/perl -w
>
> use CGI qw(:standard);
>
> $r=new CGI;
> $r->use_named_parameters(1);
>
> #pull-off cookie values
> $user=$r->param('user');
> $closing=$r->param('closing');
> $month=substr $closing, 0, 2;
> $year=substr $closing, 2, 2;
> $close=substr $closing, 5, 1;
> $ind=$r->param('ind');
>
> # make a 4 digit year
>
> $cookies{'user'}=$user;
> $cookies{'closing'}=$closing;
> $cookies{'year'}=$year;
> $cookies{'ind'}=$ind;
> $shit=$r->cookie('name'=>'them',
> 			'value'=>\%cookies);
>
> print $r->header('cookie'=>$shit);
>
> Retrieve cookie:
> ----------------
> #!/usr/bin/perl -w
>
> use CGI qw(:standard);
>
> $r=new CGI;
> $r->use_named_parameters(1);
>
> print $r->header();
> %cooks=$r->cookie('name'=>'them');
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


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


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

Date: Fri, 02 Jun 2000 03:40:55 GMT
From: "scumjr" <scumjr@deja.com>
Subject: Re: file dates being reported incorrectly.....
Message-Id: <b1GZ4.10861$uw6.236892@news20.bellglobal.com>

> I assume you meant e.g. (for example) rather than i.e. (that is) there?

Yeah, that's what I meant.....I don't know what I was thinking.....believe
it or not, I do know the difference between the two! ;)

> I find it suspicious that 31 Dec 69 is the day before the
> Unix epoch. Might that be a clue?

Not a clue to me??  What is the Unix Epoch?

> What do the -A and -M filetests do?

I don't believe I tried those tests....I'll give them a go tomorrow at work.
Should/would they yield different results?   Would they be quicker at
getting the dates than stat()?


***
last post from Bart
***
> Could it be that the "time" returned was -1?

That's something I probably should have checked on first.

> It looks to me like Your OS didn't find the file.

The OS (NT) is what passed the file list to Perl....I made a dir system call
and stored the contents in an array.  It does report the size of the file
correctly.

>....(actually, a lot) to do with it. Perhaps you need to convert the
>character set from Windows to DOS or vice versa...
>If so, and if you're using Activestate, I'd think it's a bug. You
>shouldn't have to do that. From a DOS Perl, running under Windows, I can
>understand it...

I'm running the script on an NT 4 system, so wouldn't the command prompt be
using the same character set?





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

Date: Fri, 02 Jun 2000 15:31:57 +1000
From: Peter Hill <phill@modulus.com.au>
Subject: Re: Get the time, plus one hour (was: code cleanup)
Message-Id: <393746CD.76FE@modulus.com.au>

Bill wrote:
> 
> I'm still new to PERL. Below, I've posted my very S L O P P Y and slow
> solution to my attempt to obtain the time 1 hour from the current time in a
> particular format. I think I have indented it such that someone would easily
> be able to offer suggestions on cleaning it up ? My main problem wasn't in
> obtaining 1 hour from the current time so much as figuring out how to put it
> in the required format. I am using Win2000 for my system "date" and "time"
> calls. Here is the working code (and yes I realize this won't accomodate Feb
> 29 - hopefully I will have something better by then):
> 
> $curtimefile="curtime.xxx";
> $curdatefile="curdate.xxx";
> 
> system "time /t > $curtimefile";
> open MFILE, "<$curtimefile" || die "help!";
> read MFILE, $hh, 2;     # hour
> read MFILE, $sp, 1;     # next character (don't need it)
> read MFILE, $min, 2;    # minute
> close MFILE;
> 
> system "date /t > $curdatefile";
> open MFILE, "<$curdatefile" || die "help!";
> read MFILE, $ww, 3;     # day of week
> read MFILE, $sp, 1;     # next character (don't need it)
> read MFILE, $mm, 2;     # month
> read MFILE, $sp, 1;     # next character (don't need it)
> read MFILE, $dd, 2;     # day of month
> read MFILE, $sp, 1;     # next character (don't need it)
> read MFILE, $yy, 4;     # year
> close MFILE;
> 
> $hh++;        # increment the hour
> 
> if ($hh eq "24") {
>         $daychange = "1";
>         $hh = "00";
> }
> 
> if ($daychange eq "1") {
>         if ($ww eq "Mon") {
>                 $ww = "Tue";
>         } elsif ($ww eq "Tue") {
>                 $ww = "Wed";
>         } elsif ($ww eq "Wed") {
>                 $ww = "Thu";
>         } elsif ($ww eq "Thu") {
>                 $ww = "Fri";
>         } elsif ($ww eq "Fri") {
>                 $ww = "Sat";
>         } elsif ($ww eq "Sat") {
>                 $ww = "Sun";
>         } else {
>                 $ww = "Mon";
>         }
>         $dd++
> }
> 
> if ($dd eq "32") {
>         $dd = "01";
>         $mm++;
> }
> 
> if (($dd eq "31") && (($mm eq "04") || ($mm eq "06") || ($mm eq "09") ||
> ($mm eq "11"))){
>                 $dd = "01";
>                 $mm++;
> }
> 
> if (($dd eq "29") && ($mm eq "02")) {
>       $dd = "01";
>       $mm++;
> }
> 
> if ($mm eq "13") {
>       $mm = "01";
>       $yy++;
> }
> 
> @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
> "Oct", "Nov", "Dec");
> $newmm = $months[--$mm];
> 
> $newline = "\"$ww, $dd-$newmm-$yy $hh:$min:00 GMT\"";
> print "one hour from now is $newline";

I think you're trying too hard. Perl's inbuilt functions can do most of
the work for you.
perldoc -f localtime
perldoc -f gmtime
perldoc -f sprintf

#! /bin/perl -w
use strict;
my @months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',
'Sep','Oct', 'Nov', 'Dec');
my @days = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');

#local time
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$ydat,$isdst) =
localtime(time + 3600);
$year += 1900;
print "One hour from now is ";
printf("%s, $mday-$mon-$year %02d:%02d:%02d %s local time\n",
$days[$wday], $hour, $min, $sec, $months[$mon]);

#GMT based
($sec,$min,$hour,$mday,$mon,$year,$wday,$ydat,$isdst) = gmtime(time +
3600);
$year += 1900;
print "One hour from now is ";
printf("%s, $mday-$mon-$year %02d:%02d:%02d %s GMT\n", $days[$wday],
$hour, $min, $sec, $months[$mon]);

#quick and dirty
my $tmp = localtime(time + 3600);
print "One hour from now is $tmp local time\n";
__END__
-- 
Peter Hill,
Modulus Pty. Ltd.,
http://www.modulus.com.au/


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

Date: Fri, 2 Jun 2000 14:11:44 +0800
From: "Andrew Lam Tug Wye" <andrewlam@oub.com.sg>
Subject: Installation of Perl5004_05
Message-Id: <8h7ipk$g27$1@newton.pacific.net.sg>

Hi,

I was trying to install perl5004_05 and had followed the instructions. I
have the following message when I do a 'make' .
I have installed gcc as my compiler and had set a path for it. The following
is the error message. Will appreciate any help or advise.


'sh cflags libperl.a miniperlmain.o' miniperlmain.c
    CCMD=gcc -DPERL_CORE -c -I/usr/local/include -O
sh: gcc: not found
*** Error code 1
make: Fatal error: Command failed for target 'miniperlmain.o'

Thanks
Andrew Lam





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

Date: 2 Jun 2000 02:15:26 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: my Foo $self = shift;
Message-Id: <8h75bu$2gs2g$1@fu-berlin.de>

hi,

Kai Henningsen <kaih=7f04f891w-B@khms.westfalen.de> wrote:
> The above is from the perl 5.6 fields.pm documentation.

maybe the documentatin can tell you more about that.

> I haven't been able to find any documentation at all on what this syntax  
> *means* (though I've found it *mentioned* in two or three other places,  
> enough to believe it's not a typo). Where is it hidden?

my Foo $self = shift;
means, you're copying an object of the type Foo into
the variable $self.

tina

-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception


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

Date: 2 Jun 2000 02:34:27 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: my Foo $self = shift;
Message-Id: <slrn8je79i.jmf.sholden@pgrad.cs.usyd.edu.au>

On 2 Jun 2000 02:15:26 GMT, Tina Mueller <tina@streetmail.com> wrote:
>hi,
>
>Kai Henningsen <kaih=7f04f891w-B@khms.westfalen.de> wrote:
>> The above is from the perl 5.6 fields.pm documentation.
>
>maybe the documentatin can tell you more about that.
>
>> I haven't been able to find any documentation at all on what this syntax  
>> *means* (though I've found it *mentioned* in two or three other places,  
>> enough to believe it's not a typo). Where is it hidden?
>
>my Foo $self = shift;
>means, you're copying an object of the type Foo into
>the variable $self.

It means no such thing, witness:

package Foo;
my Foo $self = 42;
print "$self\n";

From the fields docs:
       If a typed lexical variable holding a reference is used to
       access a hash element and a package with the same name as
       the type has declared class fields using this pragma, then
       the operation is turned into an array access at compile
       time.

Using a typed lexical variable makes Psuedo-hash access be turned into
an array access at compile time.... see 'perldoc perlref' (the section
on Pseudo-hashes) for more information.

As always you are making a promise to perl. Nothing stops you breaking those
promises... though bad things might happen...

-- 
Sam

The very fact that it's possible to write messy programs in Perl is also
what makes it possible to write programs that are cleaner in Perl than
they could ever be in a language that attempts to enforce cleanliness.
	--Larry Wall


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

Date: Fri, 02 Jun 2000 05:39:32 GMT
From: kenny@barmeister.com
Subject: mysql insertid
Message-Id: <8h7haj$26d$1@nnrp1.deja.com>

I am trying to get the insertid of the last insert I did in a MySQL
table.  The column is auto incremented and the primary key.  I have used
both:

my $new_id = $dbh->{'mysql_insertid'};
my $new_id = $sth->{insertid};

However I am not getting any results with these.  Has anyone else run
into this??  I would appreciate any help anyone could give me on this.

Thanks.


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


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

Date: Fri, 02 Jun 2000 03:01:32 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Net::FTP question : Can I get control back on timeout?
Message-Id: <gsFZ4.99991$hT2.406636@news1.rdc1.ct.home.com>

Toni Vatcher <tmvatcher@bigfoot.com> wrote:
> I am using Net::FTP to get a bunch of files from a server. 
> Occasionally, I get a timeout on the $ftp->get but I want processing to
> continue with the rest of the files.  In telnet, there is an option
> "Errmode" that you can set to "return".  Is there anything like this for
> FTP?

perldoc -f eval

				Dan


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

Date: Fri, 02 Jun 2000 02:56:07 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Non-reuse of memory for lexically-scoped variables?
Message-Id: <bnFZ4.99989$hT2.406636@news1.rdc1.ct.home.com>

In comp.lang.perl.misc Denis Haskin <dwhaskin@earthlink.net> wrote:
> Ilya Zakharevich wrote:

>> No it is not.  Lexicals, compile-time and scratch variables are
>> sticky: whatever goes there, remains there.
>>
>>   my $a = 'a';
>>   my $b = 'b' x 1e6 . $a . $a;
>>
>> would take 3M (in recent Perls): one for 'b' x 1e6 (done at compile
>> time), one for a scratch variable which contained b...ba, and one
>> which sits in $b.  [Older Perls would take an extra 1M for b...baa in
>> a scratch variable.]
>>
>> Only one of these Ms is recoverable, one in $b, and only by explicit
>>
>>   undef $b;
>>
>> Ilya

> Arrrrrgh!  Is this really true?  This is nuts (but it may explain why I
> think I have a memory leak)!

> Shouldn't this be considered a bug?  So if I say:

Well, it's an optimization.

>     {
>         my $b; # yes I know I can my and init at same time.
>         $b = 'x' x 1e6;
>     }
> even though $b is out of scope once I'm out of the block, that memory has
> been allocated and is not reused?  How can anyone write anything of
> reasonable size & complexity in Perl if that's the case?

> Is there a (good) reason that things work this way?

Yep. If you entered the block once you may well enter it again, which
means that perl keeps that memory more or less reserved just in case.
basically the first scratchpad allocated for the block sticks around.
Enter the block recursively and perl will allocate a new scratchpad for
each reentry, but those are freed up on exit. (I think) It's an
optimization to reduce repeated mallocs and the resulting churn of your
free memory pool.

I'm not sure how to dodge this one--I think exiting an extra level of
scope will do it, but I'm not 100% sure.

use less 'memory'; # anyone?

				Dan


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

Date: 02 Jun 2000 05:03:30 GMT
From: zenin@bawdycaste.org
Subject: Re: Non-reuse of memory for lexically-scoped variables?
Message-Id: <959922436.91169@thrush.omix.com>

Denis Haskin <dwhaskin@earthlink.net> wrote:
: Ilya Zakharevich wrote:
:> No it is not.  Lexicals, compile-time and scratch variables are sticky:
:> whatever goes there, remains there.
	>snip<
: Arrrrrgh!  Is this really true?

	Yes.

: This is nuts

	Well, yes and no.

: (but it may explain why I think I have a memory leak)!
: 
: Shouldn't this be considered a bug?

	No; it's a feature. :-)

: So if I say:
:     {
:         my $b; # yes I know I can my and init at same time.
:         $b = 'x' x 1e6;
:     }
: even though $b is out of scope once I'm out of the block, that memory has
: been allocated and is not reused?

	Correct, maybe.

: How can anyone write anything of reasonable size & complexity in Perl if
: that's the case?

	Easy.  Rarely are large parts of a large program not called many
	times, which means the memory *is* reused...just not reallocated.

: Is there a (good) reason that things work this way?

	The memory is not reclaimed as it is very likely to be reused.  It
	isn't wasted:

		sub foo {
		    my $bar = 'whatever';
		    ...changes $bar, whatever...
		}

	The space for $bar never gets reclaimed, but it does get reused upon
	every invocation of foo().  Far more often then not, $bar is going
	to be about the same size so perl simply uses the same memory for
	$bar every time foo() is called (recursive calls are handled
	slightly differently, AFAIK).  No need to reallocate or dynamically
	grow in most cases, which speeds things up.

: What's a recommended workaround?

	Don't write code that's only ever called once. :-)

	In general, it's safe to ignore it as it will mostly help you.

: If I'm writing classes (oops: 'packages'),

	No, you were right the first time; "classes". -In Perl, "classes"
	are defined using a "package".

: this means all the memory allocated by my lexical variables (and I use a
: lot of them) never gets reused... I guess I could make them all member
: variables (e.g. $self->{myVariable}) but that seems like tremendous
: overkill.
: 
: Geez...

	Do you really want your entire class and/or methods to reallocate
	memory every time you call a method or instantiate an instance of
	the class?

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Fri, 02 Jun 2000 03:00:37 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: overriding Config.pm?
Message-Id: <prFZ4.99990$hT2.406636@news1.rdc1.ct.home.com>

Ken MacFarlane <ksm+usenet@universal.dca.net> wrote:
> Coming to terms with lack of admin privileges and idiotic "guidelined
> packages" on a client system leaves me in the following dilema:

> I'm trying to make an XS-supported module using my own installation of
> gcc.  When attempting the "perl Makefile.PL" step, the system Perl
> installation uses its Config.pm, which was created based on the brain-dead
> non-ANSI system compiler; as a result, the make fails.

On most Unix systems it's a bad idea to mix and match compilers for bits
of a program, so you may well find that this doesn't at all work well.
(GCC seems to not play well with others in general, but I might just have
an odd set of experiences with it)

However... You can always set PERL5LIB to have a local directory in it and
make a cpoy of Config.pm there, suitably edited, and hope for the best.
You might get lucky.

				Dan


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

Date: Thu, 01 Jun 2000 15:49:40 -0700
From: Russell Bornschlegel <kaleja@estarcion.com>
Subject: Re: Perl unusable as a programming language
Message-Id: <3936E884.F50B51A0@estarcion.com>

Ilya Zakharevich wrote:
> Your run the same construct under different versions of Perl, and get
> different results.  Now in which way is this "deterministic", as
> programming languages go?
> 
> Scripting:            "I tried it, and it works."
> 
> Programming:          "If it does not work in next version of Perl, I will
>                        report it as a bug."

Programming in Microsoft Visual C++:
"If it does not work in the next version of the compiler, I will sigh and 
try to find a workaround, because I'm not going to get a useful answer 
from Microsoft."

Programming in Perl:
"If it does not work in the next version of Perl, I will check on c.l.p.m(s)
and see if I'm misunderstanding something. Failing that, I will report it 
as a bug."

-RB


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

Date: 2 Jun 2000 04:33:56 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl unusable as a programming language
Message-Id: <8h7dfk$j1i$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Russell Bornschlegel 
<kaleja@estarcion.com>],
who wrote in article <3936E884.F50B51A0@estarcion.com>:
> > Programming:          "If it does not work in next version of Perl, I will
> >                        report it as a bug."

> Programming in Perl:
> "If it does not work in the next version of Perl, I will check on c.l.p.m(s)
> and see if I'm misunderstanding something. Failing that, I will report it 
> as a bug."

When programming, they make sure they understand *first*, not when
things start to fail.

Ilya


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

Date: Fri, 02 Jun 2000 06:27:28 GMT
From: attama@my-deja.com
Subject: Please Help!!! Writing data file on Two Unix Servers...
Message-Id: <8h7k4c$3sq$1@nnrp1.deja.com>

Hi,

I have a CGI perl script on an external unix server outside
the firewall that records data of a web survey into a flat file.

I have to record/transport the same data simultaniously into another
file on an internal unix server behind the firewall.

I thought of the following. But, none of them is feasible.

1. I can mount the disk if both servers are either inside or
outside the firewall. But I can't do this with a firewall in
between.

2. I can have a cron job on the external server that FTPs the data file
into the internal unix server. But for this I will have to hard code
the username/password in the perl script. Because this script
resides in external server this is not acceptable for security reasons.

Any help would be greatly appreciated.

Thanks.
-A


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


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

Date: Fri, 02 Jun 2000 06:28:23 GMT
From: attama@my-deja.com
Subject: Please Help!!! Writing data file on Two Unix Servers...
Message-Id: <8h7k62$3su$1@nnrp1.deja.com>

Hi,

I have a CGI perl script on an external unix server outside
the firewall that records data of a web survey into a flat file.

I have to record/transport the same data simultaniously into another
file on an internal unix server behind the firewall.

I thought of the following. But, none of them is feasible.

1. I can mount the disk if both servers are either inside or
outside the firewall. But I can't do this with a firewall in
between.

2. I can have a cron job on the external server that FTPs the data file
into the internal unix server. But for this I will have to hard code
the username/password in the perl script. Because this script
resides in external server this is not acceptable for security reasons.

Any help would be greatly appreciated.

Thanks.
-A


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


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

Date: Fri, 02 Jun 2000 01:22:38 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: the end of perl?
Message-Id: <B55C849C.5440%elaine@chaos.wustl.edu>

in article 3936CD61.5963D8FE@flashmail.com, Flounder at japh@flashmail.com
quoth:
 
> This has to be total bull@%*&

It's a joke son..you know, a joke...:)

e.




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

Date: Thu, 1 Jun 2000 22:05:03 -0400
From: "Edward Grinvald" <eg344@nyu.edu>
Subject: Re: Very silly question
Message-Id: <zEEZ4.11$Vf1.628@typhoon.nyu.edu>

DBI is a module that allows database connectivity from perl scripts. Look at
CPAN for more info


"Jon Gage" <jon@videoflicks.com> wrote in message
news:RdzZ4.36$fY1.19027@198.235.216.4...
> I'm a total Perl novice, and I'm trying to get an app we received running.
> Unfortunately I don't have DBI installed.  This is where I begin to sound
> retarded; I don't know what DBI is, or what it does.  I'm trying to
install
> the package at the command line with "ppm install dbi", as per
instructions
> but I keep getting a message indicating that a PPD couldn't be found.
>
> Can anyone help?
>
> Thanks,
> Jon
>
>




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

Date: Fri, 02 Jun 2000 01:48:47 GMT
From: Deja User <binary3418@my-deja.com>
Subject: webget failure
Message-Id: <8h73pt$pvh$1@nnrp1.deja.com>

Hi, there:

  I'm a novice user of Perl. I want to fetch a document from a
Web site and process it. With a search in Deja, I get to know
that there is a example called webget comming along with the
Perl document. I found it and made a copy of it. But it didn't
seem to work for this:

  webget www.perl.com /guanaco.html

  On a Win98 box running ActivePerl v 5.6, I got the following
error message:

    cannot connect to http daemon on www.perl.com

  On a Linux box running Perl 5.005_03, I got

    IO::Socket::INET: Connection refused
    cannot connect to http daemon on www.perl.com

  What's wrong?

  Thanks,

Liu Bin


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


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 3232
**************************************


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