[27757] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9138 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 10 00:05:51 2006

Date: Sun, 9 Apr 2006 21:05:06 -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           Sun, 9 Apr 2006     Volume: 10 Number: 9138

Today's topics:
    Re: A problem with precedence <tadmc@augustmail.com>
    Re: A problem with precedence <rwxr-xr-x@gmx.de>
    Re: Catching Apache Errors in Perl <joe@inwap.com>
    Re: Extract range of lines from a text file <softouch@softouch.on.ca>
    Re: taint mode and require using "." <joe@inwap.com>
        utf8 filenames <cjk32@cam.ac.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 9 Apr 2006 18:47:21 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: A problem with precedence
Message-Id: <slrne3j789.jn0.tadmc@magna.augustmail.com>

Mark Hobley <markhobley@hotpop.deletethisbit.com> wrote:
> The following statement gives a result of 10, which is what I expect, because 
> multiplication has a higher precedence than addition:
> 
> print 4 + 2 * 3;   # 10
> 
> I now add brackets to change the precedence:
> 
> print (4 + 2) * 3; # This unexpectedly gives 6


You should always enable warnings when developing Perl code you know.

(especially when the Perl code's behavior does not meet your expectations.)


Anyway,

   perldoc -f print

       Also be
       careful not to follow the print keyword with a left parenthesis
       unless you want the corresponding right parenthesis to termi-
       nate the arguments to the print ...


So use parenthesis around the function arguments for at least
this one statement, even if you don't like to use parenthesis
around function arguments:

   print((4 + 2) * 3); 


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


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

Date: Mon, 10 Apr 2006 04:06:08 +0200
From: "Lukas Mai" <rwxr-xr-x@gmx.de>
Subject: Re: A problem with precedence
Message-Id: <e1ceif$qv6$03$2@news.t-online.com>

Abigail <abigail@abigail.nl> schrob:
> Lukas Mai (rwxr-xr-x@gmx.de) wrote on MMMMDCIV September MCMXCIII in
> <URL:news:e1b1nt$98g$00$1@news.t-online.com>:
> <>  Mark Hobley <markhobley@hotpop.deletethisbit.com> schrob:
> <>  
> <> > I now add brackets to change the precedence:
> <> > 
> <> > print (4 + 2) * 3; # This unexpectedly gives 6
> <>  
> <>  Use warnings.
> 
> Actually, the fact this gives a warning is a damn good reason to NOT
> use warnings. 

[detailed explanation why "print (...) interpreted as function" is
broken]

> <>  $ perl -wle 'print  (4 + 2) * 3;'
> <>  Useless use of multiplication (*) in void context at -e line 1.
> <>  6
> <>  
> 
> Don't use warnings. Unless you rip out this stupid warning from your
> copy of Perl. And I'm not joking.

Heh, I even wondered why I didn't get another warning for my code. On
second reading I see the two spaces. And yeah, I forgot to disable that
warning when I installed 5.8.8; I used to have a patch for 5.8.6
somewhere.

Lukas


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

Date: Sun, 09 Apr 2006 17:58:01 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Catching Apache Errors in Perl
Message-Id: <HKydnTxfW60CMKTZnZ2dnUVZ_sOdnZ2d@comcast.com>

Daniel Kaplan wrote:
> Hello All,
> 
> I wanted to replace on my server the standard 500 Server error page with my 
> own via a Perl script.
> 
> What I was curious about was does Perl have a way of accessing those errors? 

Remember that "500 Server Error" can mean "Unable to execute any perl
programs due to an error in the Apache configuration file".  You can't
expect Perl to handle error that occur prior to its execution.
	-Joe


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

Date: Sun, 09 Apr 2006 20:28:49 -0400
From: Amer Neely <softouch@softouch.on.ca>
Subject: Re: Extract range of lines from a text file
Message-Id: <7Eh_f.64593$fd.18690@read2.cgocable.net>

Tad McClellan wrote:
> Amer Neely <softouch@softouch.on.ca> wrote:
> 
>> The problem seems to be that $CustData holds all 5 lines. I need to 
>> break out each of the lines into a separate string variable
> 
> 
>    my @separate_strings = split /\n/, $CustData;

I think I ended up using something like that after munging around with 
the code. I realized that I still had some 'splitting' to do. Now have a 
working version. It walks through my mailbox file and pulls out the data 
I was having trouble with. Now I can pull out the easy stuff. Thanks for 
taking some time with this.
-- 
Amer Neely
Home of Spam Catcher
W: www.softouch.on.ca
E: trudge@softouch.on.ca
Perl | MySQL | CGI programming for all data entry forms.
"We make web sites work!"


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

Date: Sun, 09 Apr 2006 17:50:44 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: taint mode and require using "."
Message-Id: <k46dnQwoSst3NqTZRVn-qg@comcast.com>

robic0 wrote:

>> How to write this require line with taint mode ?
> Whats a taint mode? I hope this is not a word from Perl.
> If it is, then Perl really does suck rancid wet dogshit.

And you've never watched a courtroom drama where the
judge disallows the use of "tainted evidence", right?

Taint: place under suspicion or cast doubt upon, as
        in unreliable testimony.

Anyone who does not accept 'taint' as a valid word
really does suck rancid wet robicshit.


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

Date: Mon, 10 Apr 2006 01:39:25 +0100
From: "Christopher Key" <cjk32@cam.ac.uk>
Subject: utf8 filenames
Message-Id: <4439a8dd$0$33921$ed2619ec@ptn-nntp-reader03.plus.net>

Hello,

I'm trying to understand the correct way to handle the following.  Say I 
have a file containing non ascii characters, e.g. as 8 bit values 66 69 6C 
E9, or 'f' 'i' 'l' 'e_acute', and I want to establish whether that file 
exists.

If I execute:

    ex("c:\\fil\x{e9}.txt");
    ex("c:\\fil" . pack("U", 0xe9 ) . ".txt");

    sub ex {
        my $f = shift;
        print $f;
        print ((-e $f) ? " exists" : " doesn't exist");
        print "\n";
    }

Then I get the following:

    c:\filé.txt exists
    c:\filé.txt doesn't exist

The filename is displayed in exactly the same format to the screen in both 
cases, but it isn't found when the filename is passed as a utf8 string.  Is 
there any way to tell perl that the operand being passed to -e is utf8?

One workaround would be to simply convert everything from utf8 to an single 
byte representation, but I've no idea whether this will work in environments 
other than mine (Win32, EN_GB, perl v5.8.8).  It's also not going to handle 
unicode characters that won't fit into a single byte either.

What is the correct way to handle this to ensure portability?

Chris Key 




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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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