[23377] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5596 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 1 09:06:07 2003

Date: Wed, 1 Oct 2003 06:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 1 Oct 2003     Volume: 10 Number: 5596

Today's topics:
        Active Perl upgrade problems (Thomas C)
    Re: Can another Perl script without using exec or syste <jwillmore@cyberia.com>
    Re: code not working..ideas please? <geoff.cox@blueyonder.co.uk>
    Re: code not working..ideas please? <geoff.cox@blueyonder.co.uk>
    Re: code not working..ideas please? <geoff.cox@blueyonder.co.uk>
    Re: code not working..ideas please? <geoff.cox@blueyonder.co.uk>
    Re: code not working..ideas please? <HelgiBriem_1@hotmail.com>
    Re: date in hash keys & sorting <king21122@yahoo.com>
    Re: Debug Messages (Anno Siegel)
    Re: How are spammers exploiting my wwwboard code? <abigail@abigail.nl>
    Re: How are spammers exploiting my wwwboard code? <REMOVEsdnCAPS@comcast.net>
    Re: How are spammers exploiting my wwwboard code? <flavell@ph.gla.ac.uk>
    Re: How To activate command line history in debugger? <kurt.kronschnabl-nospam@ica-intercom-akademie.de>
        Newbie Q - Nicer way to lc something? <chris@FLARBLEinfinitemonkeys.org.uk>
    Re: Numbers not acting like numbers <abigail@abigail.nl>
    Re: Numbers not acting like numbers (Anno Siegel)
    Re: Oops, 5.8.1 broke my program <abigail@abigail.nl>
        open (F, "$fname") vs open $F, $fname; (Great Deals)
    Re: open (F, "$fname") vs open $F, $fname; <abigail@abigail.nl>
    Re: Perl script crashing at lockfile ? (Anno Siegel)
    Re: Problem in Set/Get Cookie <nospam@bigpond.com>
    Re: Prog. testing. <jwillmore@cyberia.com>
        Read limited size of HTTP content (Great Deals)
    Re: Regexp - optimisation <HelgiBriem_1@hotmail.com>
    Re: script help to update member profiles <jwillmore@cyberia.com>
    Re: Testeo de News <abigail@abigail.nl>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 1 Oct 2003 05:39:25 -0700
From: tlcole@thepcschool.com (Thomas C)
Subject: Active Perl upgrade problems
Message-Id: <aa33e448.0310010439.43e8ce75@posting.google.com>

I upgraded my IIS web site on a 2K box from 5.6.0 to 5.6.1 and now
instead of the .pl scripts running they want to either open or save.  
I even tried uninstalling the newer version and reinstalling the newer
version with no luck.  I also insured the pl association was made in
IIS and that the perl\bin was in the path statement of the
environment.  I am out of ideas!  The whole company world wide uses
this site and it being down is causing lots of trouble.


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

Date: Wed, 01 Oct 2003 10:19:03 GMT
From: James Willmore <jwillmore@cyberia.com>
Subject: Re: Can another Perl script without using exec or system
Message-Id: <20031001061801.108f346e.jwillmore@cyberia.com>

On 30 Sep 2003 20:50:54 -0700
deals@slip-12-64-108-121.mis.prserv.net (Great Deals) wrote:

> I don't have shell access from the hosting company, so I cannot use
> exec or system, but I need to run several perl scripts at once. So
> in a pure perl enviroment, totally indepentent from shell/os, how
> can I call other perl scripts from another perl script? use,
> include, ...?

perldoc perlboot
perldoc perltoot
perldoc perlbot
perldoc perlmod
perldoc -f require
perldoc -f do

Take your pick :-)

You may also consider learning portable Perl.  Meaning, learn to code
in Perl _without_ calling out to a shell.  _Most_, if not all actions
you can perform at the shell you can do within Perl.  Not to mention -
_if_ you decide to change platforms (ex you change web hosts - you go
from a Windows host to a Linux host), you won't have to alter your
code at all -or- it will be minimal.

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Excellent day for drinking heavily.  Spike office water cooler. 



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

Date: Wed, 01 Oct 2003 08:37:02 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: Re: code not working..ideas please?
Message-Id: <de4lnvcl10nlt8aueun67j1a4bk1hms4b6@4ax.com>

On 30 Sep 2003 21:14:57 GMT, Glenn Jackman <xx087@freenet.carleton.ca>
wrote:

>Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
>>  On 30 Sep 2003 19:55:07 GMT, Glenn Jackman <xx087@freenet.carleton.ca>
>>  wrote:
>> >        push @schools, $1 if $line =~ /^(\S+)/;
>>  
>>  I assume this matches the first group of non white space characters?
>
>It matches the first group on non white space characters, only if they
>are at the beginning of the line (note the ^ anchor)
>
>> >        print OUT $line if grep { $line =~ /\Q$_/i } @schools;
>>  
>>  not clear on above line - how does grep work? 
>
>http://www.perldoc.com/perl5.6/pod/func/grep.html
>
>@schools is an array of patterns.  I want to check each of these
>patterns against the current line.  grep is a concise function to
>iterate over an array and perform some action.  In this case, the return
>value of grep is the number of elements in @schools that "match" $line.
>
>The regex /\Q$_/i contains this magic:
>    $_  (the current placeholder to an element in the @schools array), 
>    \Q  which means any regex metacharacters in $_ (such as * or +)
>        should be escaped of their special meaning, and 
>    /i  to ignore case.
>
>Another way to code that line could be:
>    foreach my $element (@schools) {
>        if ($line =~ /\Q$element/i) {
>            print OUT $line;
>        }
>    }
>
>I highly recommend these O'Reilly books:  "Learning Perl", "Programming
>Perl" and "Mastering Regular Expressions".

Glenn,

Thanks - have now much better idea of what is happening...thanks for
the book suggestions too.

Cheers

Geoff



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

Date: Wed, 01 Oct 2003 08:37:45 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: Re: code not working..ideas please?
Message-Id: <0i4lnvgsd4bo94e91381h0cdmrp7fttsl5@4ax.com>

On 30 Sep 2003 17:07:58 -0400, Ryan Shondell
<shondell@cis.ohio-state.edu> wrote:

>Geoff Cox <geoff.cox@blueyonder.co.uk> writes:
>
>> Ryan
>> 
>> Thanks for your comments...I have changed to code below but it only
>> gives me one email address in the emails file ! I must be missing
>> something obvious?
>> 
>> Could you explain the
>> 
>> $word = shift line of yours?
>
>When you pass arguments to a sub, they are passed in the @_ array. The
>shift function removes the first value from an array and returns
>it. If you don't specify the name of the array, it uses @_.
>
>So by doing
>
>        my $word = shift;
>
>I'm setting $word to the first value in @_. In other words, the first
>arg passed into the sub.

Got it ! Thanks

Geoff



>
>> Cheers
>> 
>> Geoff
>> 
>> use warnings;
>> use strict;
>> 
>> open (IN, "secondary") or die "Can't open secondary: $!";
>> open (INN, "cornwall") or die "Can't open cornwall: $!";
>> open (OUT, ">>emails") or die "Can't open emails: $!";
>> 
>> while (defined (my $line =<IN>)) {
>>                           if ($line =~ /(\w+)/) {
>>                                        email($1);
>>                                                 }
>>                                  }
>> 
>> sub email {
>> 
>> my $word = $1;
>> $word =~ tr/A-Z/a-z/;
>
>Instead of this, you should probably use the /i option to m// below.
>
>> while (defined (my $line2 = <INN>)) {
>>                           if ($line2 =~ /$word/) {
>
>        if ($line =~ /$word/i) {
>
>>                           print OUT ($line2);
>>                                                }
>>                                     }
>> }
>
>You should definitely follow the example posted elsewhere in this
>thread on how to solve your problem. One of the problems you have of
>doing it this way is that if you have already pulled the lines from
>INN that contain what you want to match, you won't match.
>
>Okay, that came out a bit confusing... :-)
>
>For example, say that your files look like this...
>
>__IN__
>some
>things
>here
>__IN__
>
>__INN__
>things
>some
>foo
>__INN__
>
>Your program will read in the word "some", and then start searching
>through INN until it finds a match. So it will grab and discard the
>word "things" from INN.
>
>When your program processes the word "things" from your first file, it
>will then start looking through the second file _at the place where
>you stopped_ the first time. So it will have missed a word it should
>have gotten.
>
>In trying to solve some of your smaller problems, I completely missed
>the bigger one; the implementation. Sorry bout that... :-(
>
>Ryan



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

Date: Wed, 01 Oct 2003 08:39:46 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: Re: code not working..ideas please?
Message-Id: <pk4lnvo1k8rfl6u07sali79vpkvm60362t@4ax.com>

On Tue, 30 Sep 2003 16:04:07 -0500, tadmc@augustmail.com (Tad
McClellan) wrote:

>Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
>
>> $word =~ tr/A-Z/a-z/;
>
>
>You should use the function for lowercasing when you want to
>lowercase. Your method does not respect locales:

>   $word = lc($word);

Tad,

Thanks for your reply but "respect locales" ? 

Geoff



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

Date: Wed, 01 Oct 2003 08:40:53 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: Re: code not working..ideas please?
Message-Id: <fn4lnvg9dvujl8bic98a24nts4om8lbf90@4ax.com>

On 30 Sep 2003 15:42:28 -0700, carltonbrown@hotmail.com (Carlton
Brown) wrote:

>Geoff Cox <geoff.cox@blueyonder.co.uk> wrote in message news:<jajjnvkc8qeq0qeu7lo5mg166dfrus9iv1@4ax.com>...
><snip>
>
>Looks like you're assuming that perl args to a subroutine show up as
>numbered positionals, like in a shell script.  Bzzt.  They show up in
>an array called @_ which can be shifted or directly referenced like
>any other array.
>
>> sub email {
>  my $school = shift @_; # (this would work)
>  my $school = $_[0]; # (or this, if you prefer)
>> 

Carlton,

Thanks - now appreciate what the shift does..

Cheers

Geoff



>> while (defined (my $line2 = <INN>)) {
>#                Bleh.              if ($line2 =~ /$1/i) {
>               Better.              if ($line2 =~ /$school/i) {
>>                                   print OUT ($line2);
>>                                                               }
>>                                                        }
>> }
>
>PS - if you use hashes, you will experience joy should you ever need
>to refactor this code in the future.
>PPS - Your symbol names are kinda bad.  "INN?"  Bleh.



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

Date: Wed, 01 Oct 2003 11:59:57 +0000
From: Helgi Briem <HelgiBriem_1@hotmail.com>
Subject: Re: code not working..ideas please?
Message-Id: <o4glnvkqj3i9bdonq7hnopm5ol1ccj3ocp@4ax.com>

On Wed, 01 Oct 2003 08:39:46 GMT, Geoff Cox
<geoff.cox@blueyonder.co.uk> wrote:

>On Tue, 30 Sep 2003 16:04:07 -0500, tadmc@augustmail.com (Tad
>McClellan) wrote:
>
>>Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
>>
>>> $word =~ tr/A-Z/a-z/;

>>You should use the function for lowercasing when you want to
>>lowercase. Your method does not respect locales:
>
>>   $word = lc($word);

>Thanks for your reply but "respect locales" ? 

Would your way recognise that 'Þ' (ord=222) is a valid letter in 
 Icelandic and has the lowercase version 'þ' (ord=254)?
That's locale.  Here's an example:

use locale qw(Icelandic);
print lc('ÞÓR');

Output:
þór


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

Date: Wed, 01 Oct 2003 20:50:45 +1000
From: King <king21122@yahoo.com>
Subject: Re: date in hash keys & sorting
Message-Id: <3F7AB185.4020402@yahoo.com>

Gunnar Hjalmarsson wrote:
> King wrote:
> 
>> Gunnar Hjalmarsson wrote:
>>
>>> Sam wrote:
>>>
>>>> one of the problems I am facing is converting the date, the result
>>>> are
>>>> 2002124 for 2002-Jan-24
>>>> 2002124 for 2002-Dec-4
>>>> that sorting will not work, any idea is appriciated
>>>
>>>
>>> Check out the sprintf() function. Example:
>>>
>>>     @dates = ('2002-Jan-24', '2002-Dec-4');
>>>
>>>     %months = ( Jan => 1, Feb => 2, Mar => 3, Apr => 4,
>>>                 Maj => 5, Jun => 6, Jul => 7, Aug => 8,
>>>                 Sep => 9, Oct => 10, Nov => 11, Dec => 12 );
>>>
>>>     @sortabledates = map { sprintf '%d%02d%02d',
>>>         map { /[a-z]{3}/i ? $months{$_} : $_ } split /-/
>>>     } @dates;
>>
>>
>> what if the dates are
>> 02-Jan-24
>> 02-Dec-4
>> 99-Jan-24
>> 99-Dec-4
> 
> 
> Then the code needs to be modified, obviously. But that's beyond the 
> question, isn't it?
> 


     my $dates = "02-Aug-4";  #this could be 98-Aug-04

     my %months = ( Jan => 1, Feb => 2, Mar => 3, Apr => 4,
                 Maj => 5, Jun => 6, Jul => 7, Aug => 8,
                 Sep => 9, Oct => 10, Nov => 11, Dec => 12 );

my $pat;
     my $sortabledates = sprintf $pat,
         ((map { /[a-z]{3}/i ? $months{$_} : $_ } split /-/, $dates)[0] 
 > 35 ? $pat = 19'%d%02d%02d' : $pat = 20'%d%02d%02d') ;  # 19 and 20 
before the pattern is what I need but this is not the correct way to do 
it, just to show you what I am thinking, how could it be written?
print $sortabledates;

thanks



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

Date: 1 Oct 2003 07:29:45 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Debug Messages
Message-Id: <bldvp9$b3b$1@mamenchi.zrz.TU-Berlin.DE>

Ilya Zakharevich  <nospam-abuse@ilyaz.org> wrote in comp.lang.perl.misc:
> [A complimentary Cc of this posting was sent to
> Anno Siegel
> <anno4000@lublin.zrz.tu-berlin.de>], who wrote in article
> <blc1nd$2vn$1@mamenchi.zrz.TU-Berlin.DE>:
> > In Perl, the corresponding approach would be to have
> > 
> >     use constant DEBUG => 0; # set to true for debugging
> > 
> > near the beginning of the program, and later do
> > 
> >     print "Done one thing, starting another\n" if DEBUG;
> 
> > Also like in C, it can't be (easily) activated from the command line.
> 
> ???   my $debug;
>       BEGIN {$debug++, shift @ARGV if @ARGV and $ARGV[0] eq '--debug'}
>       use constant DEBUG => $debug;
> 
> This works at least for --debug being at the fixed position.  Otherwise
> utilize/move (sic! ;-) getopt() in a BEGIN block.

Sure.  That's what I meant with "not easily" :)

Anno


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

Date: 01 Oct 2003 08:56:38 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: How are spammers exploiting my wwwboard code?
Message-Id: <slrnbnl5m6.dr.abigail@alexandra.abigail.nl>

Buck (Nekid@jaybird.com) wrote on MMMDCLXXXIII September MCMXCIII in
<URL:news:pan.2003.10.01.00.30.04.71282@jaybird.com>:
}}  On Tue, 30 Sep 2003 12:29:51 +0100, Alan J. Flavell wrote:
}}  
}} > On Mon, 29 Sep 2003, Buck wrote:
}} > 
}} >> Well... I didn't have time to read the *entire* script...
}} >> First off, what is the permission to cgi-bin directory?
}} >> Is it 711 -> rwx--x--x  ?
}} >>
}} >> That will stop them reading your scripts.
}}  
}}  No.  Incorrect! Now a point for the clueless.
}}  
}}  The 711 on a directory (NOTICE: I did say cgi-bin directory) provides
}}  traverse access, and blocks LISTing of the directory.  If the cgi-bin
}}  directory were 755 as you say, just pointing to the cgi-bin directory -
}}  any one can see each and every script in the directory.

Only with web servers that are configured by idiots.

}}  711 on a directory, does not stop a script with 755 from being read and
}}  run!  I always setup cgi-bin as 711, it keeps the directory private.  It
}}  does not stop someone from getting the scripts, but it does hinder them
}}  because they have to know the exact filename for retrieval.

Anyone who's trying to use file permissions to prevent web access
to documents doesn't have enough clues. You configure your web
server, not your filesystem.

Of course, none of this has anything to do with Perl.



Abigail
-- 
$_ = "\112\165\163\1648\141\156\157\164\150\145\1628\120\145"
   . "\162\1548\110\141\143\153\145\162\0128\177"  and &japh;
sub japh {print "@_" and return if pop; split /\d/ and &japh}


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

Date: Wed, 01 Oct 2003 06:28:44 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: How are spammers exploiting my wwwboard code?
Message-Id: <Xns94074C0EF140sdn.comcast@206.127.4.25>

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

Buck <Nekid@jaybird.com> wrote in news:pan.2003.10.01.00.30.04.71282
@jaybird.com:

> The 711 on a directory (NOTICE: I did say cgi-bin directory) provides
> traverse access, and blocks LISTing of the directory.  If the cgi-bin
> directory were 755 as you say, just pointing to the cgi-bin directory -
> any one can see each and every script in the directory.

Only if the web server is configured very badly.

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP3q6YWPeouIeTNHoEQKCMQCfUZXrlgw8uODnSjTqFrtCyJLu/2AAoKZo
4Rnk/kChfkFGW4edhaGmWduQ
=K9+Z
-----END PGP SIGNATURE-----


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

Date: Wed, 1 Oct 2003 11:49:35 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: How are spammers exploiting my wwwboard code?
Message-Id: <Pine.LNX.4.53.0310011140270.10112@ppepc56.ph.gla.ac.uk>

On Tue, 30 Sep 2003, Buck wrote:

> The 711 on a directory (NOTICE: I did say cgi-bin directory)

So you did.  I apologise for that detail.

> If the cgi-bin directory were 755 as you say, just pointing to the
> cgi-bin directory - any one can see

Who is "any one" in this statement?

> each and every script in the directory.

Try mine for sighs:  http://ppewww.ph.gla.ac.uk/cgi-bin/

drwxr-xr-x   4 root     root         4096 Mar  4  2003 cgi-bin

The web server says:

Forbidden
You don't have permission to access /cgi-bin/ on this server.

>  I always setup cgi-bin as 711, it keeps the directory private.  It
> does not stop someone from getting the scripts,

Are you trying to say that they can retrieve the source of the scripts
via the web server?  That would be most unusual and inappropriate for
a cgi-bin directory.

Of course this still isn't on-topic for a group that's about the Perl
programming language.


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

Date: Wed, 01 Oct 2003 14:35:39 +0200
From: Kurt Kronschnabl <kurt.kronschnabl-nospam@ica-intercom-akademie.de>
Subject: Re: How To activate command line history in debugger?
Message-Id: <blej1d$o27$00$1@news.t-online.com>

Hello Peter.

As already told, there is no "ReadKey.pm" in a Knoppix and Suse 8.2 
installation. ReadLine is available in both distries. But only under 
Suse it works.

Here the results for ReadKey:

knoppix@p01kno:~$ perl -MTERM::ReadKey -e 0
Can't locate TERM/ReadKey.pm in @INC (@INC contains: /etc/perl 
/usr/local/lib/perl/5.8.0 /usr/local/share/perl/5.8.0 /usr/lib/perl5 
/usr/share/perl5 /usr/lib/perl/5.8.0 /usr/share/perl/5.8.0 
/usr/local/lib/site_perl .).
BEGIN failed--compilation aborted.

knoppix@p01kno:~$ perl -dle 'print $INC{"Term/ReadKey.pm"}'

Loading DB routines from perl5db.pl version 1.19
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(-e:1):   print $INC{"Term/ReadKey.pm"}
   DB<1> c

Debugged program terminated.  Use q to quit or R to restart,
   use O inhibit_exit to avoid stopping after program termination,
   h q, h R or h O to get additional info.
   DB<1>

knoppix@p01kno:~$ perl -MCPAN -le 'print $INC{"Term/ReadKey.pm"}'

knoppix@p01kno:~$

> Are you sure that root doesn't have a
> different path causing it to run a different perl?

Yes, very shure. Under root it is the same effect.

And here the results for ReadLine:

knoppix@p01kno:~$ perl -dle 'print $INC{"Term/ReadKey.pm"}'

Loading DB routines from perl5db.pl version 1.19
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(-e:1):   print $INC{"Term/ReadKey.pm"}
   DB<1> c

Debugged program terminated.  Use q to quit or R to restart,
   use O inhibit_exit to avoid stopping after program termination,
   h q, h R or h O to get additional info.
   DB<1> q
knoppix@p01kno:~$ perl -MCPAN -le 'print $INC{"Term/ReadKey.pm"}'

knoppix@p01kno:~$ perl -MTERM::ReadLine -e 0
Can't locate TERM/ReadLine.pm in @INC (@INC contains: /etc/perl 
/usr/local/lib/perl/5.8.0 /usr/local/share/perl/5.8.0 /usr/lib/perl5 
/usr/share/perl5 /usr/lib/perl/5.8.0 /usr/share/perl/5.8.0 
/usr/local/lib/site_perl .).
BEGIN failed--compilation aborted.
knoppix@p01kno:~$ perl -dle 'print $INC{"Term/ReadLine.pm"}'

Loading DB routines from perl5db.pl version 1.19
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(-e:1):   print $INC{"Term/ReadLine.pm"}
   DB<1> c
/usr/share/perl/5.8.0/Term/ReadLine.pm
Debugged program terminated.  Use q to quit or R to restart,
   use O inhibit_exit to avoid stopping after program termination,
   h q, h R or h O to get additional info.
   DB<1> q
knoppix@p01kno:~$ perl -MCPAN -le 'print $INC{"Term/ReadLine.pm"}'

knoppix@p01kno:~$

Hope this tells you more than me :=)

Best Regards, Kurt



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

Date: Wed, 01 Oct 2003 13:41:02 +0100
From: Chris Smith <chris@FLARBLEinfinitemonkeys.org.uk>
Subject: Newbie Q - Nicer way to lc something?
Message-Id: <blei68$kb5$1$8300dec7@news.demon.co.uk>

Hi,

Is there a nicer way of doing the following?

    $a = lc($a);

Doesn't look "perlish" if you know what I mean.

Cheers,

-- 
Chris Smith
http://www.infinitemonkeys.org.uk/


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

Date: 01 Oct 2003 08:59:59 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Numbers not acting like numbers
Message-Id: <slrnbnl5se.dr.abigail@alexandra.abigail.nl>

D'Anne Asquith (dasquith@austin.rr.com) wrote on MMMDCLXXXIII September
MCMXCIII in <URL:news:BB9F9EA1.17A8%dasquith@austin.rr.com>:
||  
||  I should not have to do the pack/unpack.  It is possible that the argument
||  is really "0.1" (note double quotes) and not 0.1 deep in the program logic.
||  Would this be the source of the problem?  Unfortunately, when I create a
||  tiny test program I can not reproduce the problem.  The only thing changed
||  in years of multiple users of the program is use of Perl5.8.
||  
||  Could someone comment on how a value that looks like 0.1 would test as <=
||  0--could Perl somehow consider 0.1 as int(0.1) internally?


Without an actual test case, all we can do is guessing.

My guess is that there's a bug.



Abigail
-- 
use   lib sub {($\) = split /\./ => pop; print $"};
eval "use Just" || eval "use another" || eval "use Perl" || eval "use Hacker";


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

Date: 1 Oct 2003 09:25:00 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Numbers not acting like numbers
Message-Id: <ble6hc$g2b$1@mamenchi.zrz.TU-Berlin.DE>

D'Anne Asquith  <dasquith@austin.rr.com> wrote in comp.lang.perl.misc:
> I have subroutine for computing base-10 log.  With a recent upgrade from
> Perl5.6 to Perl5.8 on both Linux and Solaris systems, a very large program
> with a proven track record is not behaving right.  The subroutine snippet is
> as follows.
> 
> use constant logof10 => scalar log(10);
> use constant ZERO    => scalar 0;

"scalar" isn't needed here.  "log()" and "0" don't depend on context.

> sub log10 {
>    my $n = shift;
>    #my $n = &repackit(shift);  # HACK HERE
>    ($n <= ZERO) ? undef : log($n)/logof10;
> }


Your code isn't wrong, but the use of constants is of no advantage here.
You use named constants if the value you are using could conceivably
change in another version, or if the expression is particularly
complicated.  Neither apply to "ZERO" or "logof10".

    sub log10 {
        my $n = shift;
        return unless $n > 0;
        log($n)/log(10);
    }

> On apparently random occurrences the argument (say 0.1) is testing as <= 0
> and the subroutine returns undef.  Surprize.  However, the subroutine might
> work for a thousand calls before return undef.  I have carefully tracked the
> argument upto the subroutine call and inside the subroutine (code not shown)
> here and $n is 0.1.  The ZERO instead of 0 does not seem to affect the
> behavior--still occurs.
> 
> If I uncomment the HACK HERE line and comment out the first line, the
> subroutine works everytime!
> 
> sub repackit {
>    my $n = shift;
>    return unpack("d",pack("d",$n));
> }
> 
> I should not have to do the pack/unpack.  It is possible that the argument
> is really "0.1" (note double quotes) and not 0.1 deep in the program logic.
> Would this be the source of the problem?  Unfortunately, when I create a
> tiny test program I can not reproduce the problem.  The only thing changed
> in years of multiple users of the program is use of Perl5.8.
> 
> Could someone comment on how a value that looks like 0.1 would test as <=
> 0--could Perl somehow consider 0.1 as int(0.1) internally?

There is a theoretical possibility for a variable to have independent
string and numeric content ($! is an example).  In that case, yes, it
could print as "0.1" and compare negative.  But Perl doesn't create such
variables out of the blue, it takes some doing [1].

Anno

[1] use Scalar::Util 'dualvar';
    my $foo = dualvar(-1, "0.1");
    print "$foo is negative\n" if $foo < 0;



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

Date: 01 Oct 2003 09:02:14 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Oops, 5.8.1 broke my program
Message-Id: <slrnbnl60m.dr.abigail@alexandra.abigail.nl>

Xaonon (xaonon@hotpop.com) wrote on MMMDCLXXXII September MCMXCIII in
<URL:news:slrnbnkat7.vjm.xaonon@xaonon.local>:
{}  Or, more likely, it was broken before in some way that wasn't apparent until
{}  I installed 5.8.1.  The program in question is a signature generator, which
{}  runs as a daemon and produces random quips via a named pipe.  The main loop
{}  looks like this:
{}  
{}      while( 1 )
{}      {
{}          -p $options{outfile}
{}              or die "$0: `$options{outfile}' disappeared\n";
{}          sysopen FIFO, $options{outfile}, O_WRONLY
{}              or die "$0: $options{outfile}: $!\n";
{}          
{}          print FIFO randsig();
{}          close FIFO or die "$0: $options{outfile}: $!\n";
{}          
{}          # Sleep briefly to let the reader see EOF.
{}          select undef, undef, undef, 0.1;
{}      }
{}  
{}  Now, though, it seems that the reader doesn't ever see an EOF.  For example,
{}  running "cat sig.fifo" spits out signature after signature until I kill the
{}  process, as opposed to just printing one and finishing.  I note that running
{}  the program with 5.6.1 still works, but I want a more rigorous solution.
{}  Can anyone identify the problem?


What does your program do with 5.8.0? 


Abigail
-- 
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
          q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'


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

Date: 1 Oct 2003 05:22:03 -0700
From: deals@slip-12-64-108-121.mis.prserv.net (Great Deals)
Subject: open (F, "$fname") vs open $F, $fname;
Message-Id: <cafe07c7.0310010422.782401fc@posting.google.com>

what is the difference here? I can add my to open my $F, $fname, but
not open (my F, "$fname").

Can I use $F the same as F?


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

Date: 01 Oct 2003 12:32:50 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: open (F, "$fname") vs open $F, $fname;
Message-Id: <slrnbnlibi.soa.abigail@alexandra.abigail.nl>

Great Deals (deals@slip-12-64-108-121.mis.prserv.net) wrote on
MMMDCLXXXIII September MCMXCIII in <URL:news:cafe07c7.0310010422.782401fc@posting.google.com>:
[]  what is the difference here? I can add my to open my $F, $fname, but
[]  not open (my F, "$fname").
[]  
[]  Can I use $F the same as F?


No. While $F is a first class citizen, F is not. $F is a scalar, and in
the case of open my $F, $fname, it will be autovivified as a refernce
to a filehandle. F is a filehandle. Filehandles cannot be lexical,
so you can't my() them.


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


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

Date: 1 Oct 2003 08:50:48 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl script crashing at lockfile ?
Message-Id: <ble4h8$efa$1@mamenchi.zrz.TU-Berlin.DE>

Peter Richards  <jehoshua@my-deja.com> wrote in comp.lang.perl.misc:
> Hi,
> 
> I've recently moved a website and one Perl script will not work. The
> previous site had a Unix box with Perl 5.006 , and the new site has a
> Linux box with Perl 5.006001

Well, Linux is one kind of Unix.  What you're saying is like, "I used
to have a car, but now I have a Chevy".

> After inserting "print" statements all over the place, finally this
> piece of code is where the script is stopping:
> 
> ----------------------------------------------------------------------
> system ("lockfile -2 -r 5 $base_dir/.lock" ) == 0 or diehtml("Lock
> error: ", $? >> 8, "\n" ); # TODO stop stderr of system
> --------------------------------------------------------------------
> 
> There is no msg appearing (what happened to the "diehtml" ?), the
> script just stops. I have checked all the path and file permissions,
> and they are exactly the same s the previous website. The variable
> $base_dir has a value of '/home/username/public_html/.orders' 

The "lockfile" command you are using is not a standard Unix command.
Some systems have it, some don't.  With those that have it, the
behavior could differ.  See the documentation for "lockfile" on
both systems.

[...]

Anno


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

Date: Wed, 01 Oct 2003 20:48:51 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Problem in Set/Get Cookie
Message-Id: <6744828.tSp6l4JUbH@gregs-web-hosting-and-pickle-farming>

It was a dark and stormy night, and Sucpraran managed to scribble:

> Hello:
> 
> Below is the Perl/JavaScript code to set and get a cookie in our
> applicaion. The problem we are facing is, it works 90% but rest of the
> 10% we get nothing in getCookie. The browser is set up to accept
> cookies(we are 100% that the browser settings are OK). We have users
> across the country and we could not find a pattern with browser
> type/versions or OS type/versions.

The 10% of users that dont send a cookie probably have cookies turned off in their browser.

Cookies are a very unreliable way of keeping state information.

gtoomey


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

Date: Wed, 01 Oct 2003 10:23:05 GMT
From: James Willmore <jwillmore@cyberia.com>
Subject: Re: Prog. testing.
Message-Id: <20031001062235.4962a293.jwillmore@cyberia.com>

On Wed, 01 Oct 2003 01:14:54 GMT
"J=FCrgen Exner" <jurgenex@hotmail.com> wrote:

> Dr. Pastor wrote:
> > I want to test a program running on Windows 2K pro. Would be Perl
> > suitable to manipulate the user interface and examine the results
> > produced by this program?
>=20
> Sure.
> You may want to check out the Expect module. It will make your work
> much easier.

And, depending on what you're testing on your Win2k box, you could
look over some of the Win32 modules.  For example, if you're testing a
macro or some other user created function in Excel, Win32::OLE may fit
the bill.

Just another suggestion :-)

--=20
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt=20
for more information.

a fortune quote ...
Dave Mack: "Your stupidity, Allen, is simply not up to par."
Allen Gwinn: "Yours is."=20


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

Date: 1 Oct 2003 05:00:28 -0700
From: deals@slip-12-64-108-121.mis.prserv.net (Great Deals)
Subject: Read limited size of HTTP content
Message-Id: <cafe07c7.0310010400.1404b220@posting.google.com>

I am trying to stream a real-time stock quote from a none stream http
html page. The real-time stock quote info is at the some part of the
page. I only want to download this part not other content. I am very
sure that http protocal can do this, because such programs as
net-transport, net-ant, flash-get.. all can resume download broken
files. I checked their http header from those download manager.
Besically they just telling the server it is a partial download and
tells the server the starting point of the download, and it can ends
at certain point.

I can not find any PERL module doing this. I think the most low level
http is Net::Http, but I still could not find anything there that
meets my need. Here is the code copied from Net::HTTP

use Net::HTTP;
 my $s = Net::HTTP->new(Host => "www.perl.com) || die $@;
 $s->write_request(GET => "/", 'User-Agent' => "Mozilla/5.0");
 my($code, $mess, %h) = $s->read_response_headers; 
 while (1) {
    my $buf;
    my $n = $s->read_entity_body($buf, 1024);
    die "read failed: $!" unless defined $n;
    last unless $n;
    print $buf;
 }

It looks like $s->read_entity_body($buf, 1024); is close, but it does
not specify the starting point and ending point. Another question how
do I exit from the while loop if the maxsize is read. They use die,
will die quit the whole perl program? Should I use exit instead here?


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

Date: Wed, 01 Oct 2003 11:53:49 +0000
From: Helgi Briem <HelgiBriem_1@hotmail.com>
Subject: Re: Regexp - optimisation
Message-Id: <q0glnvoil81hi02d7foqvamrisndrv7t86@4ax.com>

On Tue, 30 Sep 2003 22:24:44 +0100, "Stephen Adam"
<stephen.adam@ntlworld.com> wrote:

>It seems to recognise all the e-mail addresses i've tested it 
>with though I know its pretty limited.

Read perldoc -q "valid mail"

E-mail addresses are far too complicated to be
validated by a single regex.


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

Date: Wed, 01 Oct 2003 10:34:35 GMT
From: James Willmore <jwillmore@cyberia.com>
Subject: Re: script help to update member profiles
Message-Id: <20031001063433.23ab83af.jwillmore@cyberia.com>

On Tue, 30 Sep 2003 23:41:52 GMT
"BG" <NOT@home.net> wrote:

> First, I apologize if this is not the right group to be asking this
> question, but I am EXTREMELY new to perl and MySql both and am at a
> loss for where to go.

perldoc perl at the command line is a good start :-)
If you're using ActiveState Perl on a Windows system, they have all
the documentation in HTML format -and- a little shortcut on ye old
"Start" menu.

<snip>
> Could anyone please offer some assistance in how I can create a form
> that will take the current username/password along with the
> requested change password and/or email and update the appropriate
> record/table in the MySql database.

Read the documentation.  Start writing some code.  If you get stuck,
post a specific question here.

One thing I can tell you - you'll also need to read over the DBI
documentation, as well as the DBD::mysql documentation.  These are
Perl modules and can be found at http://search.cpan.org.  You should
also look over the CGI module documentation - although our local troll
will try to convince you otherwise.  However, if you are concerned
more about security versus speed, use the CGI module.

<snip>

> Problem is while this is probably a simple task to those familiar
> with perl, I am clueless to how to achieve this. While I am trying
> to learn as time permits, this is still way beyond me.

Start with the documentation.  Always a safe bet.  Tell your boss (if
this is for work) to relax -or- to cough up some cash to send you to a
class :-)  If it's just for you, relax, take your time, read the
documentation, "Google" this newsgroup, and try writing some code.

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
A professor is one who talks in someone else's sleep. 



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

Date: 01 Oct 2003 09:09:08 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Testeo de News
Message-Id: <slrnbnl6dk.dr.abigail@alexandra.abigail.nl>

elvira@onairos.es (elvira@onairos.es) wrote on MMMDCLXXXII September
MCMXCIII in <URL:news:blcqe0$c6s$1@localhost.localdomain>:
;;  testeo de news server
;;  Escuse me


Your test message succeeded! You're now a permanent resident 
of my killfile.



Abigail
-- 
CHECK {print "another "}
END   {print "Hacker\n"}
INIT  {print "Perl "   }
BEGIN {print "Just "   }


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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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


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