[25033] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7283 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 21 18:07:13 2004

Date: Thu, 21 Oct 2004 15: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           Thu, 21 Oct 2004     Volume: 10 Number: 7283

Today's topics:
    Re: backup utility for remote hosts <usenet@morrow.me.uk>
    Re: case INsensitive regular expressions <tadmc@augustmail.com>
    Re: case INsensitive regular expressions <ioneabu@yahoo.com>
        fatalsToBrowser <nospam@nospam.com>
    Re: fatalsToBrowser <noreply@gunnar.cc>
    Re: fatalsToBrowser <1usa@llenroc.ude.invalid>
    Re: fatalsToBrowser <sbryce@scottbryce.com>
        Help on Perl Split Function (Vishal)
    Re: Help on Perl Split Function <1usa@llenroc.ude.invalid>
    Re: How do I check a valid mail address? <comdog@panix.com>
    Re: How do I print http 404 not found header? <tadmc@augustmail.com>
    Re: How to checking a file that writing is complete? <bik.mido@tiscalinet.it>
    Re: How to redefine warnings on recursion level <thundergnat@hotmail.com>
    Re: How to redefine warnings on recursion level <tadmc@augustmail.com>
    Re: is it possible? <usenet@morrow.me.uk>
    Re: Mail::Sender - Attaching output from pipe <postmaster@localhost.localdomain>
    Re: Mail::Sender - Attaching output from pipe <tadmc@augustmail.com>
    Re: Mail::Sender - Attaching output from pipe <postmaster@localhost.localdomain>
    Re: options to shrink-wrap a perl script <1usa@llenroc.ude.invalid>
    Re: options to shrink-wrap a perl script <flavell@ph.gla.ac.uk>
        Perl "Split" Function help (Vishal)
    Re: Perl "Split" Function help <1usa@llenroc.ude.invalid>
    Re: Perl "Split" Function help <noreply@gunnar.cc>
    Re: Perl "Split" Function help <1usa@llenroc.ude.invalid>
    Re: perl to english (buildmorelines)
    Re: perl to english <tassilo.von.parseval@rwth-aachen.de>
    Re: Perl XML Parser DOM Tag Handler sample code .... <usenet@morrow.me.uk>
        printing to web browser <nospam@nospam.com>
    Re: printing to web browser <noreply@gunnar.cc>
    Re: printing to web browser <flavell@ph.gla.ac.uk>
    Re: regex to clean path <parv_@yahooWhereElse.com>
    Re: regex to clean path <uguttman@athenahealth.com>
    Re: regex to clean path <bik.mido@tiscalinet.it>
    Re: Regular Expression for HTML Tags and Special Charac <bart.lateur@pandora.be>
    Re: Remote Permissions Problem <Jon.Ericson@jpl.nasa.gov>
        Trouble understanding data structure (Page)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 21 Oct 2004 01:34:37 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: backup utility for remote hosts
Message-Id: <tpcj42-la7.ln1@osiris.mauzo.dyndns.org>


Quoth "John W. Krahn" <krahnj@telus.net>:
> Brian McCauley wrote:
> > 
> > dan baker wrote:
> >>
> >>     # check type
> >>     # -----
> >>     if ( $File =~ m/.*\.(.+)$/ ) {
> > 
> > The leading .* is redundant.
> 
> No it is not, but the $ is.
> 
> $ perl -le'
> for ( qw/ one.two.three.four  five  six.seven  eight.nine.ten / ) {
>      print "A: $1" if m/.*\.(.+)$/;
>      print "B: $1" if m/\.(.+)$/;
>      print "C: $1" if m/.*\.(.+)/;
>      }
> '

I would prefer to write it as

/\.(.+?)$/

to make it clear we are matching something at the end of the string.

Ben

-- 
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else ** ben@morrow.me.uk


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

Date: Thu, 21 Oct 2004 13:40:14 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: case INsensitive regular expressions
Message-Id: <slrncng0ke.82a.tadmc@magna.augustmail.com>


[ Followups set ]


sabinosa <maurof78@aol.com> wrote:

>   I am working with a RegularExpressionValidator in Visual Studio.NET.

> Any idea what I am doing wrong?


Posting a question that is not related to Perl into the Perl newsgroup.


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


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

Date: Thu, 21 Oct 2004 17:00:30 -0400
From: wana <ioneabu@yahoo.com>
Subject: Re: case INsensitive regular expressions
Message-Id: <10ng91m7ivcqt8c@news.supernews.com>

sabinosa wrote:

> (^(CSV|ZIP|TXT)$/i does not work)
> 
> Any idea what I am doing wrong?  Thanks in advance for your responses!

maybe /^(CSV|ZIP|TXT)$/i will work.

Try this out:

#! /usr/bin/perl

print "usage: $0 filename\n" if not $test = @ARGV[0];
$match = ($test =~ /^(CSV|ZIP|TXT)$/i);
$match = $match ? "matched":"did not match";
$test = $test ? print "$test $match\n" : exit 1;



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

Date: Thu, 21 Oct 2004 17:10:25 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: fatalsToBrowser
Message-Id: <1098393046.69531@nntp.acecape.com>

use CGI::Carp qw(fatalsToBrowser);

i still JUST get the Internal 500 error, am i suing the above line wrong?  i
wanted so that all errors go to web browser, for debugging, thanks




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

Date: Thu, 21 Oct 2004 23:25:20 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: fatalsToBrowser
Message-Id: <2tqnpeF22pk64U1@uni-berlin.de>

daniel kaplan wrote:
> use CGI::Carp qw(fatalsToBrowser);
> 
> i still JUST get the Internal 500 error, am i suing the above line wrong?

No, but the error message is probably triggered before that line is 
compiled. Things like:

- Wrong file format (for instance, if you upload files from a Windows 
computer to a *nix server, did you use "ASCII transfer mode"?

- Wrong file permissions

- Wrong path to the Perl interpreter.

- Possible other incorrect lines before use CGI::Carp...

For further tips, see

     perldoc -q 500

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 21 Oct 2004 21:27:18 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: fatalsToBrowser
Message-Id: <Xns9589B18FD612Easu1cornelledu@132.236.56.8>

"daniel kaplan" <nospam@nospam.com> wrote in
news:1098393046.69531@nntp.acecape.com: 

> use CGI::Carp qw(fatalsToBrowser);
> 
> i still JUST get the Internal 500 error, am i suing the above line
> wrong?

Yeah, we don't like frivilous lawsuits.

All joking aside, I have no idea what's going on for the simple reason that 
you have provided no information.

What happens when you run the following script:

use CGI::Carp qw(fatalsToBrowser);
die "Fatal error messages are now sent to browser";

Sinan.


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

Date: Thu, 21 Oct 2004 15:29:28 -0600
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: fatalsToBrowser
Message-Id: <10ngahm7bpskpbf@corp.supernews.com>

daniel kaplan wrote:

> use CGI::Carp qw(fatalsToBrowser);
> 
> i still JUST get the Internal 500 error, am i suing the above line wrong?  i
> wanted so that all errors go to web browser, for debugging, thanks

The 500 error is not a Perl error. It is being sent from the web server. 
Something is preventing your script from running at all.



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

Date: 21 Oct 2004 14:12:51 -0700
From: vishalanand20@gmail.com (Vishal)
Subject: Help on Perl Split Function
Message-Id: <e3b96026.0410211312.556efd1b@posting.google.com>

Her is a simple PERL file: spl.pl

$arg=shift ;
@in_arr= split /,/, $arg ;
print("\n in_arr 0 is $in_arr[0]");
print("\n in_arr 1 is $in_arr[1]");
print("\n in_arr 2 is $in_arr[2]");
print("\n in_arr 3 is $in_arr[3]");
print("\n in_arr 4 is $in_arr[4] \n");

When I execute the above perl file; it's give the following output :

perl spl.pl a,abc,"def,ijhk",lmn

 in_arr 0 is a
 in_arr 1 is abc
 in_arr 2 is def
 in_arr 3 is ijhk
 in_arr 4 is lmn

 

But I want the output as:

in_arr 0 is a
in_arr 1 is abc
in_arr 2 is def,ijhk
in_arr 3 is lmn
in_arr 4 is

That is: the split function should not search in the Pattern which are
present in the quotes ("").

If any of your friends knows well about this "PERL/split"; pl pass on
this junk code to him for immediate help. Or if you know any Perl guy
then pass me his/her mail ID.


Please reply ASAP.

Thanks & Regards,
Vishal Anand


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

Date: 21 Oct 2004 21:22:08 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Help on Perl Split Function
Message-Id: <Xns9589B0AFA284Casu1cornelledu@132.236.56.8>

vishalanand20@gmail.com (Vishal) wrote in 
news:e3b96026.0410211312.556efd1b@posting.google.com:

> Her is a simple PERL file: spl.pl

use strict;
use warnings;

> $arg=shift ;

my $arg = shift;

> @in_arr= split /,/, $arg ;

my @in_arr= split /,/, $arg ;

> print("\n in_arr 0 is $in_arr[0]");
> print("\n in_arr 1 is $in_arr[1]");
> print("\n in_arr 2 is $in_arr[2]");
> print("\n in_arr 3 is $in_arr[3]");
> print("\n in_arr 4 is $in_arr[4] \n");

OK. Looking at this just hurts. There _is_ a better way to do this:

my @in = split /,/, shift;
print qq{\$in[$_] = $in[$_]\n} for (0 .. $#in);

> When I execute the above perl file; it's give the following output :

 ...

> But I want the output as:

perldoc -q inside

> If any of your friends knows well about this "PERL/split"; pl pass on
> this junk code to him for immediate help. Or if you know any Perl guy
> then pass me his/her mail ID.

WTF?
 
> Please reply ASAP.

Yessir ... immediately sir. I guess it's a good thing for you that I only 
read the first few lines of a message before deciding to reply.

Sinan.


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

Date: Thu, 21 Oct 2004 13:26:39 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: How do I check a valid mail address?
Message-Id: <211020041326395150%comdog@panix.com>

In article <0vOdd.54689$JG5.807133@news20.bellglobal.com>, Matt Garrish
<matthew.garrish@sympatico.ca> wrote:

> "PerlFAQ Server" <comdog@panix.com> wrote in message 
> news:cl81ua$5p7$1@reader1.panix.com...

> > 9.17: How do I check a valid mail address?


> >    Without sending mail to the address and seeing whether there's a human
> >    on the other hand to answer you, you cannot determine whether a mail

> On the other "hand"? Shouldn't that be "end"?

yes, it should.

-- 
brian d foy, comdog@panix.com


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

Date: Thu, 21 Oct 2004 13:36:25 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How do I print http 404 not found header?
Message-Id: <slrncng0d9.82a.tadmc@magna.augustmail.com>

lesley_b_linux@yahoo.co.yuk <lesley_b_linux@yahoo.co.yuk> wrote:
> Tad McClellan <tadmc@augustmail.com> writes:
>> lesley_b_linux@yahoo.co.yuk <lesley_b_linux@yahoo.co.yuk> wrote:
>> > "Alan J. Flavell" <flavell@ph.gla.ac.uk> writes:
>> 
>> >> With respect, one -is- supposed to familiarise oneself with the 
>> >> relevant Perl FAQs before posting here (see the regular "posting 
                                              ^^^^^^^^^^^^^^^^^^^^^^^^
>> >> guidelines" which appear here). 
      ^^^^^^^^^^
>> > Fair comment about familiarising oneself with the FAQ's.
>> > 
>> > I would like a pointer being published in this NG, 
>> 
>> 
>> Have you see the Posting Guidelines that Alan referred you to?
> 
> With respect the URL Alan posted me to was one about CGI in FAQ 9 which itself
> contains further CGI URLs one of which Alan also referred me to.


Read what Alan said in the parenthesis, that is why I quoted it.


>> The guidelines are posted here twice each week.
> I must have missed it then.  


Yep.


> Under what subject line?  


   Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.5 $) 


> I can see the stats posting
> with subject line "Statistics for comp.lang.perl.misc".  Via google I've been
> able to go through the subject headers of the previous week's posts. (14th Oct
> to 21st Oct) .  I haven't found anything yet that mentions Posting Guidelines
> in the subject line yet or anything other text that makes me think the message
> contains a posting guideline for this NG.


I find one posted October 19th at groups.google.com...

   Message-ID: <4174c0ab$0$6877$8b463f8a@news.nationwide.net>

   
> Just to make sure we are clear on this and not talking about different things,
> can we differentiate between the Perl FAQ (which, imho, is a FAQ or set of FAQs
> about the language) and Posting guidelines for comp.lang.perl.misc ?


Yes, they are totally separate things.

One of them is about Perl while one of them is about the Perl newsgroup.


> Putting comp.lang.perl.misc into google gives some URLs which give posting
> guidelines the URL of which was previously posted this week in this NG by
> myself elsewhere.  In fact it's a document I am sure you are well aware of.
> (http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.text)


That's the one.


> When I have found the ones that are posted *here* bi-weekly I'll read them.


We'll just wait for that then.


> At the moment the only posting guidelines I have are the ones you wrote,
> URL already quoted, and which I hope are the same.


They are.


> P.S.  Just in case, posting the guidelines twice after reading this post or
> just after having posted the post I am replying to, just won't do. ;-)

   crontab -l
   ...
   22 2 * * 2,5 /home/tadmc/perl/guide_clpmisc/autopost_guidelines


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


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

Date: Thu, 21 Oct 2004 23:58:30 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: How to checking a file that writing is complete?
Message-Id: <s20gn0lghd71ia5do88u9tr290m7666u7h@4ax.com>

On Thu, 21 Oct 2004 09:10:47 +0200, Michele Dondi
<bik.mido@tiscalinet.it> wrote:

>I know (2.6.8.1 here). Funny thing is that in 2.6 devfs is deemed
>deprecated and udev experimental!

Did I write 2.6.8.1? It's 2.6.9, since a few minutes...


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 21 Oct 2004 14:21:07 -0400
From: thundergnat <thundergnat@hotmail.com>
Subject: Re: How to redefine warnings on recursion level
Message-Id: <jeqdnUU0I8SPY-rcRVn-sg@rcn.net>

Gerhard M wrote:
> first of all an simple program:
> 
>   use Math::BigInt;
>   use warnings;
> 
>   my $v = new Math::BigInt;
>   sub faculty ($);
> 
>   $v= faculty($ARGV[0]);
>   print $v,"\n";
> 
>   sub faculty ($) {
>         my $v=shift;
>         return ( $v>1 ? $v*faculty($v -1) : 1 );
>   }
> 
> If executing with argument 99 there's no problem, but if using 100 as
> argument i'll get the warning:
> Deep recursion on subroutine "main::faculty" at recursive.pl line 13.
> 
> 1) How can i redefine the recursion level to keep down this warning?

see below

> 2) Is it possible to add a level of recursion to die the program
> (instead to warn)?

yes

> 
> regards
> gerhard


   use Math::BigInt;
   use warnings;

   my $v = new Math::BigInt;
   my $limit = 150;
   my $level;
   sub faculty ($);

   $v= faculty($ARGV[0]);
   print $v,"\n";

   sub faculty ($) {
         no warnings qw/recursion/;
         my $v=shift;
         if($v>1){
               $level++;
               die 'Deep recrusion' if $level > $limit;
               return $v*faculty($v -1);
         }else{
               return 1;
         }
   }


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

Date: Thu, 21 Oct 2004 13:44:32 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How to redefine warnings on recursion level
Message-Id: <slrncng0sg.82a.tadmc@magna.augustmail.com>

Gerhard M <notruf_1102003@yahoo.de> wrote:

>   sub faculty ($) {
>         my $v=shift;
>         return ( $v>1 ? $v*faculty($v -1) : 1 );
>   }


> Deep recursion on subroutine "main::faculty" at recursive.pl line 13.
> 
> 1) How can i redefine the recursion level to keep down this warning?


You do not need to redefine the recursion level to suppress the
warning, simply disable the warning:

  sub faculty ($) {
        my $v=shift;
        { no warnings 'recursion';
          return ( $v>1 ? $v*faculty($v -1) : 1 );
        }
  }


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


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

Date: Thu, 21 Oct 2004 01:24:44 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: is it possible?
Message-Id: <c7cj42-la7.ln1@osiris.mauzo.dyndns.org>


Quoth Matthew Braid <mb@uq.net.au.invalid>:
> 
> Backticks:
> 
> $output = `$program $ID`;
> 
> Note that this only gets you STDOUT - stderr will not be caught. Backticks also 
> do not have the more secure forms like system's multiple-argument form.

 ...but grep perlipc for 'safe backtick' for how emulate them safely.

Ben

-- 
   Razors pain you / Rivers are damp
   Acids stain you / And drugs cause cramp.                    [Dorothy Parker]
Guns aren't lawful / Nooses give
  Gas smells awful / You might as well live.                   ben@morrow.me.uk


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

Date: Thu, 21 Oct 2004 20:03:55 +0100
From: bengee <postmaster@localhost.localdomain>
Subject: Re: Mail::Sender - Attaching output from pipe
Message-Id: <41780800$0$3253$ed2619ec@ptn-nntp-reader02.plus.net>

Paul Lalli wrote:
> If so, how about a pointer to the rest, something that might explain
> your seemingly uncalled for vulgarity?

http://groups.google.co.uk/groups?hl=en&lr=&threadm=akldof%24cee%241%40news0.ifb.net&rnum=1&prev=/groups%3Fq%3Dakldmc%2524cea%25241%2540news0.ifb.net%26hl%3Den%26lr%3D%26selm%3Dakldof%2524cee%25241%2540news0.ifb.net%26rnum%3D1

This is a topic of 20 message. Read msg number 20 right at the end.

bengee


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

Date: Thu, 21 Oct 2004 16:14:34 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Mail::Sender - Attaching output from pipe
Message-Id: <slrncng9lq.88m.tadmc@magna.augustmail.com>

bengee <postmaster@localhost.localdomain> wrote:
> Paul Lalli wrote:
>> If so, how about a pointer to the rest, something that might explain
>> your seemingly uncalled for vulgarity?
> 
> http://groups.google.co.uk/groups?hl=en&lr=&threadm=akldof%24cee%241%40news0.ifb.net&rnum=1&prev=/groups%3Fq%3Dakldmc%2524cea%25241%2540news0.ifb.net%26hl%3Den%26lr%3D%26selm%3Dakldof%2524cee%25241%2540news0.ifb.net%26rnum%3D1
> 
> This is a topic of 20 message. Read msg number 20 right at the end.


OK

 ... time passes ...

Sure enough looks like uncalled for vulgarity to me, you are
still on your own!

(even called-for vulgarity gets a killfile entry when posted
 where the whole world can read it. Usenet is not email.
)


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


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

Date: Thu, 21 Oct 2004 22:49:43 +0100
From: bengee <postmaster@localhost.localdomain>
Subject: Re: Mail::Sender - Attaching output from pipe
Message-Id: <41782edc$0$48017$ed2e19e4@ptn-nntp-reader04.plus.net>

Tad McClellan wrote:
> OK
> 
> ... time passes ...
> 
> Sure enough looks like uncalled for vulgarity to me, you are
> still on your own!
> 
> (even called-for vulgarity gets a killfile entry when posted
>  where the whole world can read it. Usenet is not email.

I got the answer i was looking for anyway :-)

bengee


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

Date: 21 Oct 2004 21:39:43 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: options to shrink-wrap a perl script
Message-Id: <Xns9589B3AAF30B3asu1cornelledu@132.236.56.8>

botfood@yahoo.com (dan baker) wrote in news:13685ef8.0410200629.47e94ab7
@posting.google.com:

> Thank you J. Romano. 
> 
> You have renewed my faith that there are people in this group capable
> of demonstrating not only knowledge, but are interested in giving
> complete and thoughtful answers.

Thank you for providing me with an opportunity to plonk someone.

Sinan.


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

Date: Thu, 21 Oct 2004 22:53:49 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: options to shrink-wrap a perl script
Message-Id: <Pine.LNX.4.61.0410212252140.3299@ppepc56.ph.gla.ac.uk>

On Thu, 21 Oct 2004, A. Sinan Unur wrote:

> botfood@yahoo.com (dan baker) apparently wrote something in 
news:13685ef8.0410200629.47e94ab7
> @posting.google.com:
> 
> Thank you for providing me with an opportunity to plonk someone.

It already worked for me.  Maybe you should try it more often  ;-)


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

Date: 21 Oct 2004 14:15:39 -0700
From: vishalanand20@gmail.com (Vishal)
Subject: Perl "Split" Function help
Message-Id: <e3b96026.0410211315.5abd7812@posting.google.com>

Her is a simple PERL file: spl.pl

$arg=shift ;
@in_arr= split /,/, $arg ;
print("\n in_arr 0 is $in_arr[0]");
print("\n in_arr 1 is $in_arr[1]");
print("\n in_arr 2 is $in_arr[2]");
print("\n in_arr 3 is $in_arr[3]");
print("\n in_arr 4 is $in_arr[4] \n");

When I execute the above perl file; it's give the following output :

perl spl.pl a,abc,"def,ijhk",lmn
 in_arr 0 is a
 in_arr 1 is abc
 in_arr 2 is def
 in_arr 3 is ijhk
 in_arr 4 is lmn

But I want the output as:

in_arr 0 is a
in_arr 1 is abc
in_arr 2 is def,ijhk
in_arr 3 is lmn
in_arr 4 is

That is: the split function should not search in the Pattern which are
present in the quotes ("").

If any of your friends knows well about this "PERL/split"; pl pass on
this junk code to him for immediate help. Or if you know any Perl guy
then pass me his/her mail ID.

Please reply ASAP.

Thanks & Regards,
Vishal Anand


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

Date: 21 Oct 2004 21:23:24 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Perl "Split" Function help
Message-Id: <Xns9589B0E652994asu1cornelledu@132.236.56.8>

vishalanand20@gmail.com (Vishal) wrote in news:e3b96026.0410211315.5abd7812
@posting.google.com:

> Her is a simple PERL file: spl.pl

Don't repeatedly post the same message (with variations in the subject line 
no less). 

Sinan.


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

Date: Thu, 21 Oct 2004 23:30:22 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Perl "Split" Function help
Message-Id: <2tqo2uF22pk64U2@uni-berlin.de>

A. Sinan Unur wrote:
> vishalanand20@gmail.com (Vishal) wrote in
> news:e3b96026.0410211315.5abd7812 @posting.google.com:
>> 
>> Her is a simple PERL file: spl.pl
> 
> Don't repeatedly post the same message (with variations in the
> subject line no less).

You probably weren't fast enough, Sinan. :)

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 21 Oct 2004 21:33:52 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Perl "Split" Function help
Message-Id: <Xns9589B2AC914CBasu1cornelledu@132.236.56.8>

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in news:2tqo2uF22pk64U2@uni-
berlin.de:

> A. Sinan Unur wrote:
>> vishalanand20@gmail.com (Vishal) wrote in
>> news:e3b96026.0410211315.5abd7812 @posting.google.com:
>>> 
>>> Her is a simple PERL file: spl.pl
>> 
>> Don't repeatedly post the same message (with variations in the
>> subject line no less).
> 
> You probably weren't fast enough, Sinan. :)

If I had just waited a few more seconds before responding to the original 
post, I would have seen his repeat. Patience is a virtue apparently :)

Sinan.


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

Date: 21 Oct 2004 12:43:52 -0700
From: bulk88@hotmail.com (buildmorelines)
Subject: Re: perl to english
Message-Id: <ee659c69.0410211143.42fe2adf@posting.google.com>

Peter Hickman <peter@semantico.com> wrote in message news:<41762496$0$17802$afc38c87@news.easynet.co.uk>...
> buildmorelines wrote:
> > Is there any script or pragma or something that will translate perl
> > code to pure english, like that perl latin module, just in english. I
> > want to show a person who cant read perl code or any computer
> > language, some perl code, so they have remotly a clue what the code
> > does or how it flows. It doesnt need to perfectly make sense or be
> > proper english sentences. Just soemthing that will translate perl code
> > and/or syntax to english.
> 
> Anybody who understands the sentence "dereference and iterate over a list of 
> anonymous hashes" is probably not far off being able to read perl anyway. To 
> understand that is probably more than most suits are capable of. Stick to good 
> documentation and tests.


> Anybody who understands the sentence "dereference and iterate over a list of 
> anonymous hashes" is probably not far off being able to read perl anyway.

Is exactly what I want. I dont really want to explain $, @, {}, (), &,
%, /, //, \, \n, ? :, ;, , , =>, [], =, !, ==, =~, !~, =+, >, <, "",
'', ``, @ARGV, @_, $^O, ->, #, ||, &&, regexp markup, and so on. The
only programming experiance this person ever had was a tiny bit of
playing with Flash 4 Action Script, so they slightly get the idea of
programming, but dont know any syntax.


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

Date: Thu, 21 Oct 2004 21:44:48 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: perl to english
Message-Id: <slrncng4dg.rj.tassilo.von.parseval@localhost.localdomain>

Also sprach Paul Lalli:

> "Uri Guttman" <uri@stemsystems.com> wrote in message
> news:x7mzyg15oq.fsf@mail.sysarch.com...
>> >>>>> "w" == wana  <ioneabu@yahoo.com> writes:
>>
>>   w> use strict;
>>   w> use Exporter;
>>
>> use base 'Exporter' ;
>>
>>   w> use vars qw /$VERSION @ISA @EXPORT @EXPORT_OK/;
>>
>> no need for @ISA with use base.
>> no need for @EXPORT_OK as you don't use it.
>>
>>   w> @ISA       = qw /Exporter/;
>>
>> handled by use base
>
> I have to admit I didn't know about this.  (I knew about base, it just
> didn't occur to me to use it here, in contrast to Exporter's docs).  I
> wonder if it might be worth suggesting the documentation for Exporter.pm
> be updated to reflect this method?

I made this suggestion once in the past and had to learn about some
urban legends according to which 'use base qw/Exporter/' might not
always work as one would expect. Of course, no one was able to come with
an example, let alone explanation, for this alleged dysfunctionality. 

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: Thu, 21 Oct 2004 01:13:51 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Perl XML Parser DOM Tag Handler sample code ....
Message-Id: <vibj42-la7.ln1@osiris.mauzo.dyndns.org>


Quoth dankolito@yahoo.com (Sherbo):
> 
> I'm trying to use the latest Xerces XML Perl module for XML file
> parsing, but the  documentation is rather limited. Does anyone
> recommend a Perl XML parser with well-documented DOM tag handlers?

A well-documented XML DOM parser I have had success with in the past is
XML::LibXML.

> I want to create a handler for three different XML tags: <a>, <b>, and
> <c>. Can someone please provide me some sample code to demonstrate how
> to :

What do you mean by a 'handler'? Do you want the parser to call back
each time it hits a tag? If so, then you want a SAX parser rather than a
DOM one.

> 1.) Write a Perl DOM XML tag handler (in Xerces or other
> well-supported Perl XML mod)?
> 2.) Use multiple tag handlers while reading in an XML file?

No. Try something for yourself, show us what you've tried, and we'll
help you fix it.

Ben

-- 
   Although few may originate a policy, we are all able to judge it.
                                             - Pericles of Athens, c.430 B.C.
  ben@morrow.me.uk


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

Date: Thu, 21 Oct 2004 17:43:39 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: printing to web browser
Message-Id: <1098395030.248283@nntp.acecape.com>

still new to PERL, anyway  write now i do all OUTPUTTING to the web browser
with:

print $q->header();
print $out;

but what i would really likee to do is print everything out in TEXT only
format...for debuggin purposes....

is there a way to do this, so the browser does NOT print using HTML
formating, and just prints everything in plain text?

thanks!




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

Date: Thu, 21 Oct 2004 23:55:03 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: printing to web browser
Message-Id: <2tqpheF23640kU1@uni-berlin.de>

daniel kaplan wrote:
> still new to PERL, anyway  write now i do all OUTPUTTING to the web
> browser with:
> 
> print $q->header();
> print $out;
> 
> but what i would really likee to do is print everything out in TEXT
> only format...for debuggin purposes....

If you are using a standards compliant browser, you can just do:

     print "Content-type: text/plain\n\n";

However, I see that you are posting from Outlook, and if that means that
you are browsing the web with MSIE, using the <pre> tag may be an
alternative. But then you also need to

     s/</&lt;/g;
     s/>/&gt;/g;

before printing to STDOUT.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Thu, 21 Oct 2004 22:58:51 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: printing to web browser
Message-Id: <Pine.LNX.4.61.0410212254060.3299@ppepc56.ph.gla.ac.uk>

On Thu, 21 Oct 2004, daniel kaplan wrote:

> but what i would really likee to do is print everything out in TEXT only
> format...for debuggin purposes....

The Perl language doesn't care in the least whether you print
a content-type header of text/html or text/plain 

> is there a way to do this,

Sure

> so the browser 

That depends a bit on what you mean by "the browser".  There are 
browsers which are compatible with the applicable IETF and W3C 
specifications in this regard, and then there's a disreputable 
operating system component that occasionally gives an impression of 
being a WWW browser, but (it seems) more by accident that by design.  
None of this is Perl-specific, though.  Have you considered using the 
newsgroup recommended in perlfaq9?  (but beware the automoderation 
bot).


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

Date: Thu, 21 Oct 2004 14:14:17 -0500
From: parv <parv_@yahooWhereElse.com>
Subject: Re: regex to clean path
Message-Id: <slrncng2p1.l9.parv_@localhost.holy.cow>

in message <61oen0pb0c029kgk8rsfo5opu593mbbam2@4ax.com>,
wrote Michele Dondi ...

> On Wed, 20 Oct 2004 15:03:45 -0500, parv <parv_@yahooWhereElse.com>
> wrote:
>
>>>>  printf "Unordered: %s\n\nOrdered: %s\n"
>>>>  , ${ make_path( @paths ) }
>>>>  , ${ make_path_ordered( @paths ) }
>>>>  ;
>>>
>>> Hmmm, I couldn't help giving a peek at least into the first few
>>> lines... however this makes me think I should be moderately glad
>>> I'm refusing to read it all!
>>
>>Hey, whatever suits you, fine w/ me.
>
> the overall impression is that you have the tendency to abuse
> printf() and referencing-dereferencing

I do not agree about printf() at all, but do agree in some limited
ways about references.


  - parv

-- 
As nice it is to receive personal mail, too much sweetness causes
tooth decay.  Unless you have burning desire to contact me, do not do
away w/ WhereElse in the address for private communication.



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

Date: Thu, 21 Oct 2004 16:08:11 -0400
From: Uri Guttman <uguttman@athenahealth.com>
Subject: Re: regex to clean path
Message-Id: <m37jpjkf6c.fsf@linux.local>

>>>>> "p" == parv  <parv_@yahooWhereElse.com> writes:

  >> the overall impression is that you have the tendency to abuse
  >> printf() and referencing-dereferencing

  p> I do not agree about printf() at all, but do agree in some limited
  p> ways about references.

printf is so rarely needed in perl. you can usually use interpolation,
sprintf, or formats (which i have never used in 11 years of perl
hacking). and i would prefer sprintf as then you can easily control
where the output goes rather than always going to a single handle. think
about the cases where you want output to be returned instead of printed,
or sent to two places like stdout and a log, etc. my rule for this is:

	print rarely, print late.

print rarely means don't call print so often as it is slow. use .= to
build strings as that is fast.

print late means don't print until you have all the text you want in one
string. that way you can easily decide to print to multiple places and
control the printing. my dump, status and other text generating routines
always build strings and return them. their caller can decide to print
or add other text to them and return to a higher caller, etc. if you
print in a low level sub, you can't prepend text or mung it or control
its output.

so printf falls under that rule but since sprintf does the same work but
returns the string, i never use printf.

uri


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

Date: Thu, 21 Oct 2004 23:58:31 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: regex to clean path
Message-Id: <snbgn0hm6goa7b21184e0eshq2p5l6frle@4ax.com>

On Mon, 18 Oct 2004 16:45:22 -0500, parv <parv_@yahooWhereElse.com>
wrote:

>  #!/usr/local/bin/perl

OK, eventually I looked at your script more carefully. Here you have
my IMHO constructive cmts...

>  use warnings;
>  use strict;
>
>  my @paths = @ARGV;

As a side note, this may be a good thing for clarity, but in this
particular case I'd use @ARGV directly. And as a side note to the side
note I'd check that args are actually supplied.

>  printf "Unordered: %s\n\nOrdered: %s\n"
>  , ${ make_path( @paths ) }
>  , ${ make_path_ordered( @paths ) }
>  ;

Slightly awkward formatting/indenting apart, as I hinted in my other
post, (since 'Perl' neq 'C') while [s]printf() at times comes very
handy, in most cases a simple print() will do, with additional
advantage of its bells and whistles (say, stuff related to C<$\>,
C<$,>, etc.)

In this case you may have had

  print 'Unordered: ', ${ make_path( @paths ) }, "\n\n";
  print 'Ordered: ', ${ make_path_ordered ( @paths ) }, "\n";

instead.

But then, I would have avoided all that playing with "ref/unref", so I
would have had

  print 'Unordered: ', make_path(@paths), "\n\n";
  print 'Ordered: ', make_path_ordered(@paths), "\n";

(rewriting those subs suitably of course.)

As a general rule it is *my impression* that you're abusing the
"ref/unref" trick/technique in all of your script.

>  #  Make path string from given list of array references or strings
                                          ^^^^^^^^^^^^^^^^
                                          ^^^^^^^^^^^^^^^^

Why, if they're all coming from @ARGV by means of split()ting? But I
didn't check really any single statement of your program because as an
overall judgement I found it very difficult to read. So if you *did*
take references, then you shouldn't have, for it wouldn't have been
necessary...

>  sub make_path
>  { my @paths = @_;
>
>    my %uniq;
>    map $uniq{$_} = undef , @{ split_path( [@paths] ) };
>    keep_usable(\%uniq);

Now I see! You have a make_path and a make_path_ordered because the
hash-based algorithm you're using to keep unique entries relies on
keys(). But then the algorithm that Tad posted (hash-based, too), and
that one could have well devised him/herself, and that IIRC is even in
the faq, would have taken care of preserving order in the first place.

>    return delimit_path( [ keys %uniq ] ) ;

Next-to-useless sub, had you avoided to take references everywhere!

>  #  Make ordered path -- as indicated by the first position of each unique
[snip]
>    my %uniq;
>    { my $i = 0;
>      map $uniq{$_} = !exists $uniq{$_} ? $i++ : $uniq{$_}
>        , @{ split_path( [ @paths ]) };
>    }

I must admit it took me a while, and the help of the cmt above, to
understand the logic of this sub. All I can say is that it is a
reasonably working but definitely clumsy workaround for not having
chosen the "correct" algorithm in the first place. Again, give a peek
into Tad's post (and possibly mine, and possibly the faq!)

>  #  Make ':' delimited string from given path array reference
                                           ^^^^^^^^^^^^^^^^^^^^
                                           ^^^^^^^^^^^^^^^^^^^^

>  sub delimit_path
>  { my ($paths) = @_;
>    return \join ':' , @{$paths};
>  }

Why?!?

>  #  Input is a list of paths, each element being an array reference or a
                                                      ^^^^^^^^^^^^^^^
                                                      ^^^^^^^^^^^^^^^

>  #  string
>  sub split_path
>  { my ($paths) = @_;
>    return
>      [ map split( /[:\s]/ , ref $_ ? @$_ : $_ ) , @{$paths} ];
>  }

Why?!?

>  #  Keep only read/execute-able directories from the keys of given hash
>  #  reference
>  sub keep_usable
>  { my ($hash) = @_;
>    foreach ( keys %{$hash} )
>    { delete $hash->{$_} unless -d $_ || -x $_;

This will keep non-readable directories as well as executable files.
You want

  delete $hash->{$_} unless -d $_ && -x $_;
  #                               ^^
  #                               ^^

instead. But then C<$_> is not necessary and can be omitted, and C<_>,
err well, you'll find it in the docs... so I'd do:

  delete $hash->{$_} unless -d && -x _;

>  __END__

All in all I'd rewrite your script like thus:


  #!/usr/bin/perl -l
  
  use strict;
  use warnings;
  
  die "Usage: $0 <path> [<paths>]\n" unless @ARGV;
  
  my %seen;
  print join ':', grep {
      !$seen{$_}++ and
        -d and -x _;
  } map { split /:/ } @ARGV;
    
  __END__


[14 lines! And certainly not golfing!!]

If I understood everything correctly, then it should yield the same
output your "Ordered" line does (apart from "Ordered: "). Or am I
missing something?

It doesn't do the "Unordered" thing, though, but I don't see why it
should, since *now* it wouldn't be portable even across different
runs!

Let me try it:

  # echo $PATH
  /sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/opt/bin:~/bin
  # ./parv.pl $PATH $PATH /usr/bin
  /sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/opt/bin

Seems to be OK, apart from a "missing" tilde expansion (-> faq!),
should we take care of that too?


HTH,
Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 21 Oct 2004 19:11:22 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Regular Expression for HTML Tags and Special Characters
Message-Id: <7e2gn0lbj8umrtnuf7lcdr0adjenatna5t@4ax.com>

Tad McClellan wrote:

>> I doubt if HTML actually is a context free grammar. There are no
>> recursive rules, AFAIK.
>
>
>tables can nest arbitrarily deep:

Ah yes, that way. But no-one who tries to use regexes to parse HTML,
tries to match particular tags. Instead, they try to recognize tags,
text, comments... that sort of stuff. The rules for those aren't
recursive.

-- 
	Bart.


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

Date: Thu, 21 Oct 2004 14:19:33 -0700
From: Jon Ericson <Jon.Ericson@jpl.nasa.gov>
Subject: Re: Remote Permissions Problem
Message-Id: <rcgbrev22hm.fsf@Jon-Ericson.sdsio.prv>

"David Gale" <dsgSPAMFILTER@alum.dartmouth.org> writes:

> PS: I'm sure someone's going to suggest setting up ssh keys for passwordless
> access, but our sysadmin doesn't want to do that, since that would give
> anyone who managed to crack one box passwordless access to the server.

This isn't really a perl question you know -- you're likely to get
better advice from an ssh or security group.  I would have suggested
using ssh keys (which is how I've solved this sort of problem).  Maybe
ssh-agent would help, though I haven't needed to use it myself.

Jon


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

Date: 21 Oct 2004 11:26:44 -0700
From: dummymb@hotmail.com (Page)
Subject: Trouble understanding data structure
Message-Id: <6742094.0410211026.c97901b@posting.google.com>

I have some XML that I read in and print out using Data::Dumper which
has helped me tremendously, but I'm struggling with some parts of it.

Here is the sample Dumper output:
$VAR1 = {
  'detail' => [
        {
      'table' => [
           {
         'tr' => [
           {
             'td' => [
               {
             'content' => '2316692',
             'form' => '$',
             'm' => '1',
             'type' => 'red'
               },
               ' ',
               ' ',
               ' '
             ]
           }
             ],
         'tt' => [
           'Daily'
             ],
etc...

The problem is when I try to loop through the table.  Sometimes the
child is a tt and sometimes the child is a tr and in other cases it is
a th.

How do I check to see which one it is?
for (@{$struct->{detail}->[0]->{table}}) {
   # I want to now loop through all the children but do different
stuff dependinging on whether the child is a tr, tt, or th.
}


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

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


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