[26223] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8408 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 12 14:05:30 2005

Date: Mon, 12 Sep 2005 11: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           Mon, 12 Sep 2005     Volume: 10 Number: 8408

Today's topics:
    Re: Can a Perl Programmer Pick up PHP quickly? <john@castleamber.com>
    Re: Can a Perl Programmer Pick up PHP quickly? <john@castleamber.com>
    Re: Can a Perl Programmer Pick up PHP quickly? axel@white-eagle.invalid.uk
    Re: converting a hash where the value is a list of list (Anno Siegel)
        File::NCopy question <ataru@nospam.cyberspace.org>
        How to redirect stderr to C lang function <luki@NOSPAMsdf-eu.org>
    Re: How to redirect stderr to C lang function <perl@my-header.org>
        Perldoc security issues <spam-block-@-SEE-MY-SIG.com>
    Re: Perldoc security issues <john@castleamber.com>
        Regular Expression help, please <stanb@panix.com>
    Re: Regular Expression help, please <no@email.com>
    Re: Space (\s) count problem <"h.v.niekerk at hccnet.nl">
    Re: Space (\s) count problem <1usa@llenroc.ude.invalid>
        Trouble with passing quotes to perl program <jules1@optonline.net>
    Re: Trouble with passing quotes to perl program (Anno Siegel)
    Re: Trouble with passing quotes to perl program <1usa@llenroc.ude.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 12 Sep 2005 13:26:40 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Can a Perl Programmer Pick up PHP quickly?
Message-Id: <Xns96CF55E75A896castleamber@130.133.1.4>

Mladen Gogala <gogala@sbcglobal.net> wrote:

> On Sun, 11 Sep 2005 10:35:16 +0000, John Bokma wrote:
> 
>> Nonsense. Another Perl hater.
> 
> Actually, I love Perl and I use it quite frequently.
> I also happen to love PHP.

But your Perl knowledge and PHP knowledge are severly limited.

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: 12 Sep 2005 13:38:28 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Can a Perl Programmer Pick up PHP quickly?
Message-Id: <Xns96CF57E75B6AFcastleamber@130.133.1.4>

nospam@geniegate.com wrote:
 
> Used to be you'd call a sub like this &subroutine() which is how I
> learned it. 

Then you didn't learn enough. You still set register globals to on?

> The whole 'more than one way to do it' is nice, but it does make perl
> harder to learn. 

Nonsense. PHP is not easier compared to Perl. If you do serious things 
in PHP you have to learn a lot. The thing is, most people use PHP for 
small toy thingies.

> For a Perl coder, PHP is simply a matter of sitting down and writing.
> (and probably hating it because of the way it hampers ones sense of
> creativity)

It's not. I am an experienced Perl coder, and it's not a simple matter 
to do PHP. To process a form and put a few things in a database, yes. To 
write a serious big application no.
 
> PHP has something-to-the-effect-of classes. No real name spaces
> though. 

One of the major flaws, yes.

> Seems to me, PHP5 is looking up toward 'java'. Has interfaces and all
> that jazz. (still no inner classes though) 

It's not even close to Java of 1995.

> While perl has had 'die' for years, PHP only recently picked up
> exceptions.

Yup, PHP has been designed by people with a severe lack of computer 
science skills.

> Naturally, a language with fewer features is going to be easier to
> learn. (and probably parse much faster too)

If there was an easy to learn programming language it would have been in 
use for over 50 years by now. So why isn't there such a language? 
Remember Java? Easier and "smarter" then C++. No more memory leaks 
(sure), write once, run everywhere (sure). And have a peek at Java now.

Languages that start out as easier then X, better, faster to learn, etc. 
often miss out a lot of features which are added in, sometimes extremely 
clumsy. PHP already started out clumsy, so imagine.

>>> PHP functions are, on the other hand, well documented,
>>
>>*sniggers*, sure. Maybe you misunderstand the word well.
> 
> PHP is pretty well documented.

It isn't.

> I don't think it's as documented as
> perl though.

Exactly. You can't call documentation guessed after the source not good 
documentation. Add the so called User Notes (a large part has little or 
no programming skills) and you are in for a wild ride.

> Problem with perl is it's *too well* documented. 

No it isn't. It's very well, and *formal* documented. I don't have any 
doubt if I look up something in the Perl documentation. I do have doubts 
when I read the PHP "documentation". And I have guess the rest based on 
experimentation. Which means that when I upgrade to a new version my 
program might break (been there, done that).

>>What is bizarre about tie? Which part do you not understand? It's 
>>nothing more then being able to override some methods on a type of 
>>variable.
> 
> tie is rather hackish,

It isn't. It's just like being able to override methods on a basic type 
in Perl, nothing more, nothing less.

> you can admit it, I won't say anything.
> (hackish and quite useful at times.) 
> 
> BTW, speaking of 'tie' and undocumented.. PHP also has stuff like
> 'tie' but they don't call it as such. It's the kind of thing that is
> very hard to learn about compared to perl because it isn't as well
> documented as perl is. (they call it 'spl' or some-such, the idea
> being to implement a standard interface) Trying to learn about it is
> rather tough because you have to know what to look for. I suspect perl
> is easier to learn in that regard at least.

Again, there are no easy languages. PHP seems to have it origins in a 
programmer who had little to no Perl skills, thought he could make an 
easier "Perl" and ended up with a bigger mess. Sadly there are still 
people adding to this mess instead of weeding out all the garbage that 
has been crept into PHP.

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: Mon, 12 Sep 2005 14:18:43 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: Can a Perl Programmer Pick up PHP quickly?
Message-Id: <77gVe.23511$k22.15069@fe2.news.blueyonder.co.uk>

John Bokma <john@castleamber.com> wrote:
> Again, there are no easy languages. PHP seems to have it origins in a 
> programmer who had little to no Perl skills, thought he could make an 
> easier "Perl" and ended up with a bigger mess. Sadly there are still 
> people adding to this mess instead of weeding out all the garbage that 
> has been crept into PHP.

I remember using one of the earliest versions of PHP years ago...
it was basically only a means of adding a counter and similar
things to web pages. Obviously it has grown since then but
with no overall plan except adding new features.

Axel



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

Date: 12 Sep 2005 13:34:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: converting a hash where the value is a list of lists to just a list
Message-Id: <dg404k$a3u$2@mamenchi.zrz.TU-Berlin.DE>

Lynn <lynn.watts@ugs.com> wrote in comp.lang.perl.misc:
> Hi John,
> 
> John W. Krahn wrote:
> > Lynn wrote:
> >>
> (my stuff snipped)
> 
> >
> > $ perl -e'
> > use Data::Dumper;
> > my %people = (
> >    hillrich => [ [5308125], [2053628], [5312468], [5312492] ],
> >    hsieh    => [ [5312182], [5312613], [5312517] ],
> >    prakash  => [],
> >    florencb => [ [1420688], [1420596], [5312242], [5306884],
> > [5305217], [5248521], ],
> >    x_shukl  => [],
> >    );
> > my %new_format_people = %people;
> > $_ = [ map ref() ? @$_ : $_, @$_ ] for values %new_format_people;
> > print Dumper \%new_format_people;
> 
> Wow, I need to study this! Thanks a lot :-)

Here is a way to do it in place:

    for ( values %people ) { 
        $_ = $_->[ 0] for @$_;
    }

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Mon, 12 Sep 2005 13:27:58 +0000 (UTC)
From: Christopher Benson-Manica <ataru@nospam.cyberspace.org>
Subject: File::NCopy question
Message-Id: <dg3vou$kp6$1@chessie.cirr.com>

I'm trying to use File::NCopy::copy to preserve the modification time
of a file, but I can't seem to get it to work.  I've got, basically,

use File::NCopy qw(copy);
$fobj=File::NCopy->new(
  'force_write'    => 1,
  'preserve'       => 1,
);
$fobj->copy( "file1", "file2" );

file2, however, is not keeping file1's modification time.  I'm using
ActiveState Perl version 5.8.7 on WinXP.  Do I need to change
'set_times'?  Is there some other WinDoze quirk I need to be aware of
to get this to work?

-- 
Christopher Benson-Manica  | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org    | don't, I need to know.  Flames welcome.


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

Date: Mon, 12 Sep 2005 15:59:34 +0000 (UTC)
From: Lukas Petrlik <luki@NOSPAMsdf-eu.org>
Subject: How to redirect stderr to C lang function
Message-Id: <dg48l6$ldu$1@chessie.cirr.com>
Keywords: stderr


I was considering the following possibilities:

1) To include logging in the Perl's internal function
   util.c:Perl_write_to_stderr().

   This possibility is quite simple, but I would have to modify Perl
   sources.

2) To use binmode (STDERR, ":via(myModule)") and call back the logging
   function; the disadvantage of this solution is that it would not log most
   syntactic errors.

3) To call PerlIO_stdstreams() and assign to PL_perlio[3], before we call
   perl_parse().

   This third solution is probably the best one, but I will have to fill my
   own PerlIO structure and ensure that it will get free()d once and only
   once.

Is there a better possibility?

Lukas


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

Date: Mon, 12 Sep 2005 19:19:32 +0200
From: Matija Papec <perl@my-header.org>
Subject: Re: How to redirect stderr to C lang function
Message-Id: <urdbi1dum8t4pdm7drd545en06e8sikdo7@4ax.com>

X-Ftn-To: Lukas Petrlik 

Lukas Petrlik <luki@NOSPAMsdf-eu.org> wrote:
>3) To call PerlIO_stdstreams() and assign to PL_perlio[3], before we call
>   perl_parse().
>
>   This third solution is probably the best one, but I will have to fill my
>   own PerlIO structure and ensure that it will get free()d once and only
>   once.
>
>Is there a better possibility?

You can tie STDERR to your custom class which will capture all STDERR
output. There are also some modules that can do such things for you,
http://search.cpan.org/search?query=stderr&mode=all



-- 
Matija


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

Date: Mon, 12 Sep 2005 14:16:41 +0100
From: James Taylor <spam-block-@-SEE-MY-SIG.com>
Subject: Perldoc security issues
Message-Id: <ant121341313fNdQ@riscpc.jtnet>

I've created a very simple web-based perldoc interface that
simply passes the options and arguments the user enters to
perldoc via the shell, but before I release it I'd like to ask
if anyone is aware of any security issues with perldoc that I
should defend against. I know little about perldoc's many
options or whether they are abusable and would really appreciate
some pointers. For instance, it's not clear to me whether it
would be possible to use some of perldoc's more esoteric options
to write to another file, or execute another file even.

Of course, there are shell related security issues too. Those
that come to mind are semicolons, pipes, and i/o redirectors.
I therefore remove most punctuation characters from the user
input before passing it to the shell with a tr:

    $query =~ tr/- _A-Za-z0-9:"'//cd;

I have left colons so people can look up modules, and quote marks
so people can quote phrases to look up in the FAQ. This should
allow most of the common perldoc references given in this group
to be looked up, but would exclude interesting regexes. However,
if I can be a little less paranoid and allow more without
sacrificing security that would be good too.

Can anyone offer me general guidance?

I can post source code if that would be useful. It's only 78 lines.

Thanks.

-- 
James Taylor, London, UK                              PGP key: 3FBE1BF9
To protect against spam, the address in the "From:" header is not valid.
In any case, you should reply to the group so that everyone can benefit.
If you must send me a private email, use james at oakseed demon co uk.



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

Date: 12 Sep 2005 13:41:10 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Perldoc security issues
Message-Id: <Xns96CF585C89187castleamber@130.133.1.4>

James Taylor <spam-block-@-SEE-MY-SIG.com> wrote:

> Of course, there are shell related security issues too. Those
> that come to mind are semicolons, pipes, and i/o redirectors.
> I therefore remove most punctuation characters from the user
> input before passing it to the shell with a tr:
> 
>     $query =~ tr/- _A-Za-z0-9:"'//cd;

Technically you should write down each and every thing you are 100% sure 
that is allowed and reject everything that doesn't fall into this set. With 
general regexps and friends you either overlook things or break things.

Never fix input, like you do above.

> I have left colons so people can look up modules, and quote marks
> so people can quote phrases to look up in the FAQ.

But don't do that with a regexp. Use a parser.

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: Mon, 12 Sep 2005 15:03:53 +0000 (UTC)
From: Stan Brown <stanb@panix.com>
Subject: Regular Expression help, please
Message-Id: <dg45cp$m13$1@reader1.panix.com>

I'm trying to parse some tcpdump output (converted to text) to put it into
a database. 

The records of interest look like this: 

170.85.113.61.34203

Which is, of course an IP address with the port number prepended. I can't
seem to manage to come up with a regex that will match this. I tried
something like:

/(\d{1,5}\.?){5}/

But it does not seem to work.

Cab some kind guru enlighten me on this mystery?

-- 
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
						-- Benjamin Franklin


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

Date: Mon, 12 Sep 2005 16:19:40 +0100
From: Brian Wakem <no@email.com>
Subject: Re: Regular Expression help, please
Message-Id: <3olkkcF664onU1@individual.net>

Stan Brown wrote:

> I'm trying to parse some tcpdump output (converted to text) to put it into
> a database.
> 
> The records of interest look like this:
> 
> 170.85.113.61.34203
> 
> Which is, of course an IP address with the port number prepended. I can't
> seem to manage to come up with a regex that will match this. I tried
> something like:
> 
> /(\d{1,5}\.?){5}/
> 
> But it does not seem to work.
> 
> Cab some kind guru enlighten me on this mystery?
> 


Looks OK to me.


#!/usr/bin/perl

use strict;
use warnings;

my $str = "somestuffhere170.85.113.61.34203somestuffhere";

if ($str =~ m/((\d{1,5}\.?){5})/) {
        print "$1\n";
}
else {
        print "No match!\n";
}


$ perl tmp49.pl
170.85.113.61.34203


-- 
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png


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

Date: Mon, 12 Sep 2005 15:12:27 +0200
From: Huub <"h.v.niekerk at hccnet.nl">
Subject: Re: Space (\s) count problem
Message-Id: <43257e0d$0$764$3a628fcd@reader10.nntp.hccnet.nl>


>    perldoc -f tr
> 
>        tr///   The transliteration operator.  Same as "y///".  See perlop.
> 
>    perldoc perlop
> 

I have tried to get into the FAQ html, but get a timeout each time.

> 
> 
>>Apart from that, I want to actually read each 
>>character (into an array) until the white space is reached. 
> 
> 
> 
> Then you misled us with your poor choice of Subject header.
> 

Not really. This is merely a part of the problem. I still want to count 
white space.

> 
> 
>>So if the 
>>array is e.g. @woord1(1..$max1), 
> 
> 
> 
> Array indexes start at zero in Perl.
> 
> Arrays in Perl are indexed inside of [square] brackets, not (parenthesis).

I started out with [] but got an error. So I tried this an didn't get an 
error.

> 
> Please post Real Perl here.

I thought I did.

> 
> 
> 
>>does @woord1[1] = m/\w/g fill that 
>>element of the array with the read character?
> 
> 
> 
> What happened when you tried it?

Nothing: no error, no result.

> 
> 
>    @woord1 = m/\G\S/g;   # match & save the leading non-space characters
> 
> 

OK.


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

Date: Mon, 12 Sep 2005 14:56:39 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Space (\s) count problem
Message-Id: <Xns96CF6F54DA5BCasu1cornelledu@127.0.0.1>

Huub <"h.v.niekerk at hccnet.nl"> wrote in
news:43257e0d$0$764$3a628fcd@reader10.nntp.hccnet.nl: 

[ please provide a proper attribution when quoting others. ]

>>    perldoc -f tr
>> 
>>        tr///   The transliteration operator.  Same as "y///".  See
>>        perlop. 
>> 
>>    perldoc perlop
>> 
> 
> I have tried to get into the FAQ html, but get a timeout each time.

The documentation should be installed on your computer. If your *nix 
distro requires you to install a separate package to get Perl 
documentation, please do so.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


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

Date: Mon, 12 Sep 2005 16:36:32 GMT
From: "Julie" <jules1@optonline.net>
Subject: Trouble with passing quotes to perl program
Message-Id: <k8iVe.10791$_84.3381@newsread1.news.atl.earthlink.net>

I am trying to send to a perl program with parameters that have quotes in 
them:
my "special" day
shoe measures 3.5" in length
etc
etc

the program automatically takes parameters as quotes like
test.pl "arg1" "this is arg2" "this is arg3"
and it works fine for the items without quotes, but If I pass the above 
examples with the quotes, the args get messed up.

what can I do to preserve the quotes?

Thanks in advance




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

Date: 12 Sep 2005 16:42:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Trouble with passing quotes to perl program
Message-Id: <dg4b5d$iil$1@mamenchi.zrz.TU-Berlin.DE>

Julie <jules1@optonline.net> wrote in comp.lang.perl.misc:
> I am trying to send to a perl program with parameters that have quotes in 
> them:
> my "special" day
> shoe measures 3.5" in length
> etc
> etc
> 
> the program automatically takes parameters as quotes like
> test.pl "arg1" "this is arg2" "this is arg3"
> and it works fine for the items without quotes, but If I pass the above 
> examples with the quotes, the args get messed up.

It's not Perl but your OS, specifically your shell, that is messing things
up.  What are they?

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Mon, 12 Sep 2005 16:44:23 +0000 (UTC)
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Trouble with passing quotes to perl program
Message-Id: <Xns96CF81A967478asu1cornelledu@132.236.56.8>

"Julie" <jules1@optonline.net> wrote in
news:k8iVe.10791$_84.3381@newsread1.news.atl.earthlink.net: 

> I am trying to send to a perl program with parameters that have quotes
> in them:
> my "special" day
> shoe measures 3.5" in length
> etc
> etc
> 
> the program automatically takes parameters as quotes like
> test.pl "arg1" "this is arg2" "this is arg3"
> and it works fine for the items without quotes, but If I pass the
> above examples with the quotes, the args get messed up.
>
> what can I do to preserve the quotes?

This has nothing to do with Perl.

Look in your shell's documentation to see how quotation marks are escaped.

Sinan


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

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


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