[23978] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6179 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 22 18:10:32 2004

Date: Sun, 22 Feb 2004 15:10: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           Sun, 22 Feb 2004     Volume: 10 Number: 6179

Today's topics:
    Re: Questions on PAR <tadmc@augustmail.com>
    Re: Questions on PAR <chatiman@free.fr>
    Re: Questions on PAR <matthew.garrish@sympatico.ca>
    Re: Questions on PAR <matthew.garrish@sympatico.ca>
    Re: replace unicode characters by &#number; representat <flavell@ph.gla.ac.uk>
    Re: replace unicode characters by &#number; representat <flavell@ph.gla.ac.uk>
    Re: Simple code runs on linux, but not on windows -- wh <tadmc@augustmail.com>
    Re: Simple code runs on linux, but not on windows -- wh <rwxr-xr-x@gmx.de>
    Re: Simple code runs on linux, but not on windows -- wh (Anno Siegel)
    Re: trapping file i/o error (Anno Siegel)
    Re: trapping file i/o error <uri@stemsystems.com>
    Re: trapping file i/o error <uri@stemsystems.com>
    Re: trapping file i/o error <tassilo.parseval@rwth-aachen.de>
    Re: UNIX Find on Windows (Angel)
    Re: why do i get this error? <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 22 Feb 2004 07:49:53 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Questions on PAR
Message-Id: <slrnc3hcs1.j2i.tadmc@magna.augustmail.com>

chatiman <chatiman@free.fr> wrote:

> I'm interested in using PAR for my CGI scripts.


What to you hope to gain by using PAR for your CGI scripts?


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


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

Date: Sun, 22 Feb 2004 16:38:55 +0100
From: "chatiman" <chatiman@free.fr>
Subject: Re: Questions on PAR
Message-Id: <4038cd1e$0$2469$626a14ce@news.free.fr>


"Tad McClellan" <tadmc@augustmail.com> a écrit dans le message de news:
slrnc3hcs1.j2i.tadmc@magna.augustmail.com...
> chatiman <chatiman@free.fr> wrote:
>
> > I'm interested in using PAR for my CGI scripts.
>
>
> What to you hope to gain by using PAR for your CGI scripts?
>
source code obfuscation has I saw it mentioned on :
http://search.cpan.org/~autrijus/PAR-0.79/lib/PAR/Tutorial.pod#Code_Obfuscat
ion

but this is not (well) documented or I can't understand what it is said with
my poor english skills
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas




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

Date: Sun, 22 Feb 2004 12:21:36 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Questions on PAR
Message-Id: <wy5_b.295$Mo4.42843@news20.bellglobal.com>


"chatiman" <chatiman@free.fr> wrote in message
news:4038cd1e$0$2469$626a14ce@news.free.fr...
>
> "Tad McClellan" <tadmc@augustmail.com> a écrit dans le message de news:
> slrnc3hcs1.j2i.tadmc@magna.augustmail.com...
> > chatiman <chatiman@free.fr> wrote:
> >
> > > I'm interested in using PAR for my CGI scripts.
> >
> >
> > What to you hope to gain by using PAR for your CGI scripts?
> >
> source code obfuscation has I saw it mentioned on :
>
http://search.cpan.org/~autrijus/PAR-0.79/lib/PAR/Tutorial.pod#Code_Obfuscat
> ion
>

But the question remains, why for your CGI scripts? Are they located on an
insecure server? Web surfers shouldn't have read access to your source code
unless you've misconfigured your server, so you shouldn't need to compile
them into executables.

Matt




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

Date: Sun, 22 Feb 2004 12:24:13 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Questions on PAR
Message-Id: <ZA5_b.297$Mo4.43302@news20.bellglobal.com>


"chatiman" <chatiman@free.fr> wrote in message
news:4038cd1e$0$2469$626a14ce@news.free.fr...
>
> "Tad McClellan" <tadmc@augustmail.com> a écrit dans le message de news:
> slrnc3hcs1.j2i.tadmc@magna.augustmail.com...
> > chatiman <chatiman@free.fr> wrote:
> >
> > > I'm interested in using PAR for my CGI scripts.
> >
> >
> > What to you hope to gain by using PAR for your CGI scripts?
> >
> source code obfuscation has I saw it mentioned on :
>
http://search.cpan.org/~autrijus/PAR-0.79/lib/PAR/Tutorial.pod#Code_Obfuscat
> ion
>
> but this is not (well) documented or I can't understand what it is said
with
> my poor english skills
> >

You might also want to check out the following site:

http://par.perl.org/

Matt




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

Date: Sun, 22 Feb 2004 18:01:01 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: replace unicode characters by &#number; representation
Message-Id: <Pine.LNX.4.53.0402221754510.11881@ppepc56.ph.gla.ac.uk>

On Sat, 21 Feb 2004, Anno Siegel wrote:

> Alan J. Flavell <flavell@ph.gla.ac.uk> wrote in comp.lang.perl.misc:
> >
> >   s/([^\0-\177])/'&#'.ord($1).';'/eg;
>
[...]
>  Ben's suggestion about :ascii: is a good one,

You (both) have a point, though I was comfortable with having the
ability to switch the upper limit between \177 (ASCII) and \377 (for
iso-8859-1) in an obvious way.

Thanks for the other comments, too.

all the best


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

Date: Sun, 22 Feb 2004 18:12:18 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: replace unicode characters by &#number; representation
Message-Id: <Pine.LNX.4.53.0402221801410.11881@ppepc56.ph.gla.ac.uk>

On Sat, 21 Feb 2004, Ben Morrow wrote:

> I usually use
>
> use Encode qw/:fallbacks/;

Thanks for pointing that out.  I wasn't properly aware of the feature.

> $PerlIO::encoding::fallback = FB_HTMLCREF;
> binmode STDOUT, ':encoding(ascii)';  # or iso8859-1, or whatever
>
> which will leave the conversion until the data is output.

OK, it looks as if the relevant documentation is in e.g
http://www.perldoc.com/perl5.8.0/lib/Encode.html

Thanks.


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

Date: Sun, 22 Feb 2004 08:31:45 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Simple code runs on linux, but not on windows -- why?
Message-Id: <slrnc3hfah.j2i.tadmc@magna.augustmail.com>

Suresh Govindachar <sgovindachar@yahoo.com> wrote:


> $the_number =~ m/\d*(.*)/so;
> my $tail = $1;


You should not use the dollar-digit variables unless you have
first ensured that the match _succeeded_, else they will have
stale values in them from some previous match that _did_ succeed.

That pattern will match every string that exists! Try several strings.

Writing a pattern that will match the empty string is almost
never what you really want to do...

You should not use modifiers that you don't understand. m//o is
useless for your pattern.

   my $tail = $1 if $the_number =~ m/\d+(.*)/s;

If $the_number cannot contain newlines, then m//s is useless too.


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


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

Date: 22 Feb 2004 18:31:12 GMT
From: Lukas Mai <rwxr-xr-x@gmx.de>
Subject: Re: Simple code runs on linux, but not on windows -- why?
Message-Id: <c1ashg$m5p$1@wsc10.lrz-muenchen.de>

Tad McClellan schrob:
[...]

> You should not use modifiers that you don't understand. m//o is
> useless for your pattern.

>    my $tail = $1 if $the_number =~ m/\d+(.*)/s;

Whoa! Don't do that! The behaviour of
`my $foo if bar;' is undefined (see perldoc perlsyn).

HTH
Lukas
-- 
use warnings;use strict;$/=$b;@_=map" bottle$_ of beer",s=>'';map/h/i?print
"Hello, World!\n":/../?bless[]:/9/?map{$a=$_[$_<2],print"$_$a on the wall,
$_$a,\ntake one down and pass it around,\n",$_-1,"$_[$_==2] on the wall.\n\n"}
reverse$...99:/q/i?print$b:/\+/?$^A++:2,($b=<>)=~/\+\+|./g#  H9Q++ in Perl


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

Date: 22 Feb 2004 19:00:22 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Simple code runs on linux, but not on windows -- why?
Message-Id: <c1au86$p7k$1@mamenchi.zrz.TU-Berlin.DE>

Tad McClellan  <tadmc@augustmail.com> wrote in comp.lang.perl.misc:
> Ben Morrow <usenet@morrow.me.uk> wrote:
> > 
> > tadmc@augustmail.com wrote:
> >>
> >> ( Using ?: for its side effects is a bad idea. You should use
> >>   it for the value that it returns instead.
> > 
> > Could you give some reasons for this? 
> 
> 
> It's just my personal style I guess.
> 
> I like if/else actions to look like it.
> 
> ?: for me is an if/else value rather than an if/else action.
> 
> 
> > if the
> > statement had been, say, 'x ? return y : die z', what would be wrong
> > with it?
> 
> 
> Too little typing for my tastes. :-)
> 
>    if ( x )
>       { return y }
>    else
>       { die z }
> 
> seems to communicate much more clearly what is going on in the flow.
> 
> I am generally willing to spend a little more effort upfront if I
> get a lot of debugging benefit later on. I drop bread crumbs to
> help me find my way if I should become lost.
> 
> I seem to get the "opportunity" to debug my code more often than
> I feel is strictly necessary. When I do have to debug, I want it
> to be over with as soon as possible.  :-)
> 
> If I can read and understand the code faster, I can fix the problem faster.

On the other hand, compactness has merits of its own when it comes to
organizing code.  Sources can become drawn out in the name of clarity
(not to mention overloaded with stimuli like a plane cockpit).

I tend to write fresh code in the most compact style that is comfortable.
Yes, it is a write-only style, but that very fact helps avoid bugs in
the first place.  When there's trouble, I don't hesitate to re-write the
critical part more explicitly.  Typically, that means "map" and "grep" may
be replaced by loops, statement modifiers may be replaced by the full
form and "?:" by "if/else".

The re-writing takes some time, but some of that you have saved while
coding.  It can also be seen as time spent understanding the code.
Finally, it's a skill, you become quite adept at it.

I rarely change it back, unless it really hurts the eye.  The change in
style, plus comments and commented-out debugging statements mean "bumpy
road ahead", even to a reader other than myself.

Anno


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

Date: 22 Feb 2004 21:17:17 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: trapping file i/o error
Message-Id: <c1b68t$77$2@mamenchi.zrz.TU-Berlin.DE>

Ben Morrow  <usenet@morrow.me.uk> wrote in comp.lang.perl.misc:
> 
> toylet <toylet_at_mail.hongkong.com> wrote:
> > hmm... how do you force a variable into a certain context (could I also 
> > call it "type casting")?
> 
> You almost never need to. About the time string/number matters is with
> magic values like $!; other than that, scalar context can be forced with
> scalar() or unary + and list context with parentheses ().

Parentheses only provide list context on the left side of an assignment
(anywhere else?).  Watch this:

    sub wanta { print wantarray ? "array\n" : "scalar\n" }

      $x  =   wanta;
    ( $x) =   wanta;
      $x  = ( wanta);
    ( $x) = ( wanta);

The parentheses on the right side don't seem to do anything.

I can't meaningfully say much about the difference between unary +
and scalar(), except that there is one.  Vaguely, "+" can change parsing,
scalar() can't.

[...]

> And if you wanna make sense / Whatcha looking at me for?        (Fiona Apple)

Can't say I understand that sig of your's, but I like it :)

Anno



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

Date: Sun, 22 Feb 2004 21:22:11 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: trapping file i/o error
Message-Id: <x7hdxihksd.fsf@mail.sysarch.com>


<comp.lang.perl removed since it is not a real group. only broken
newsfeeds still carry it. it was removed MANY years ago>

>>>>> "BM" == Ben Morrow <usenet@morrow.me.uk> writes:

  BM> magic values like $!; other than that, scalar context can be forced with
  BM> scalar() or unary + and list context with parentheses ().

list context is not forced with parens. parens in perl are pure
precedence grouping syntax and i believe have (almost) no semantic use
anywhere.

perl -wle '@a = 1, 2, 3 ; print "@a"'
Useless use of a constant in void context at -e line 1.
Useless use of a constant in void context at -e line 1.
1

that is parsed as (@a = 1), 2, 3 so the latter 2 ints are thrown away

perl -wle '@a = (1, 2, 3) ; print "@a"'
1 2 3

that works because the () groups the list so that = can assign the whole
thing. the @a provides the list context in both examples.

perl -wle '$a = (1, 2, 3) ; print $a'
Useless use of a constant in void context at -e line 1.
3

as has been stated many times, there is no such thing as a list in
scalar context. that is just the , operator and again warning (why only
one?) about throwing away data.

perl -wle '$a = 1, 2, 3 ; print $a'
Useless use of a constant in void context at -e line 1.
Useless use of a constant in void context at -e line 1.
1

this time we get 2 warnings.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Sun, 22 Feb 2004 21:27:27 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: trapping file i/o error
Message-Id: <x7eksmhkjk.fsf@mail.sysarch.com>

>>>>> "TM" == Tad McClellan <tadmc@augustmail.com> writes:

  TM> You can often force list context with (parenthesis).

aw, tad, you know better than that. see my other post and this rule:

list context is provided when a list is WANTED. you can never force a
list context. either the outer expression wants a list or it doesn't.

see this slide on list context and read the rest of the context section:

	http://stemsystems.com/slides/common_sense2/slides/slide-0203.html

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 22 Feb 2004 22:38:18 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: trapping file i/o error
Message-Id: <c1bb0q$ek0$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Uri Guttman:

><comp.lang.perl removed since it is not a real group. only broken
> newsfeeds still carry it. it was removed MANY years ago>
> 
>>>>>> "BM" == Ben Morrow <usenet@morrow.me.uk> writes:
> 
>  BM> magic values like $!; other than that, scalar context can be forced with
>  BM> scalar() or unary + and list context with parentheses ().
> 
> list context is not forced with parens. parens in perl are pure
> precedence grouping syntax and i believe have (almost) no semantic use
> anywhere.

Well, take this:

    ($a) = @a;

What do the parens group here?

Or this one:

    $a = () = /(.)/g;

This is the prototypical example for parens creating list context.

In both examples parens are not used to determine precedence but only to
enforce list context onto the expression on the right side.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: 22 Feb 2004 14:44:08 -0800
From: anichin@vip.bg (Angel)
Subject: Re: UNIX Find on Windows
Message-Id: <8732d910.0402221444.48e0de14@posting.google.com>

Brian <brian.getridofthis.bygland@boeingDELETEthis.com> wrote in message news:<402965A0.ECC43D08@boeingDELETEthis.com>...
> I'm fairly new to using Perl on Windows.  I need to find all of the
> files in a folder and its sub folders that match a pattern.  On UNIX I'd
> do:
> 
> $FOUND = `find $DIRROOT -name "$PATTERN" -print`;
> 
> Is there a way to do this on Windows using Perl and/or native Windows
> commands?
> 
> Brian

Hi Brian, 

If you want to find all of the files in a folder and its sub folders
that match
a pattern on Windows using Perl and/or native Windows commands I
cannot help.
I just do not have enough experience with Perl yet.

If the task is just to find all of the files in a folder and its sub
folders that
match a pattern no matter what kind of tool you will use, I would
suggest egrep.

egrep for Windows is a part of "GNU utilities for Win32". You can
download it from here:

http://unxutils.sourceforge.net/

You can use something like this:

egrep -lr PATTERN *.*

for example:

egrep -lr "^From|Subject|Date: " *.*


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

Date: Sun, 22 Feb 2004 07:56:14 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: why do i get this error?
Message-Id: <slrnc3hd7u.j2i.tadmc@magna.augustmail.com>

dana livni <dana_livni@hotmail.com> wrote:

> open(INPUT, 'params.txt');


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


   open(INPUT, 'params.txt') or die "could not open 'params.txt' $!";


> $dir =~ m/Dir to Save in\: (.+)/i;
> $dir = $1;


You should not use the dollar-digit variables unless you have
first ensured that the match _succeeded_, else they will have
stale values in them from some previous match that _did_ succeed.

The colon character is not special it does not need backslashing.

   if ( $dir =~ m/Dir to Save in: (.+)/i )
      { $dir = $1 }

You don't even need to use the dollar-digits. This will
accomplish the same thing (assuming no \n in the string):

   $dir =~ s/Dir to Save in: //i;


> my $d_file1 = "$dir\\$company_symbol 1.txt";


You don't really need to use silly slashes you know...

   my $d_file1 = "$dir/$company_symbol 1.txt";


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


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

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


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