[23694] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5901 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Dec 6 00:05:49 2003

Date: Fri, 5 Dec 2003 21:05: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           Fri, 5 Dec 2003     Volume: 10 Number: 5901

Today's topics:
        Am I right on Mod_Perl? <Temp@NoSuchDomain.Info>
    Re: any idea how to optimize this regex? <abigail@abigail.nl>
    Re: any idea how to optimize this regex? <abigail@abigail.nl>
    Re: any idea how to optimize this regex? <matthew.garrish@sympatico.ca>
    Re: any idea how to optimize this regex? <usenet@morrow.me.uk>
    Re: appending to file appends twice!? (Tad McClellan)
    Re: appending to file appends twice!? <waltman@pobox.com>
        Can you explain LOCAL, MY and OUR with examples? <Temp@NoSuchDomain.Info>
    Re: Can you explain LOCAL, MY and OUR with examples? <usenet@morrow.me.uk>
    Re: Can you explain LOCAL, MY and OUR with examples? <kuujinbo@hotmail.com>
    Re: Can you explain LOCAL, MY and OUR with examples? (Tad McClellan)
    Re: Can you explain LOCAL, MY and OUR with examples? <Temp@NoSuchDomain.Info>
    Re: Don't Read - Testing <flavell@ph.gla.ac.uk>
    Re: Executing a command on a remote Windows 2000 machin <jwillmore@remove.adelphia.net>
    Re: gui in perl <usenet@morrow.me.uk>
    Re: gui in perl <matthew.garrish@sympatico.ca>
    Re: gui in perl <ramen@lackingtalent.com>
    Re: Help with POST request using LWP? <invalid-email@rochester.rr.com>
    Re: Help with POST request using LWP? <usenet@morrow.me.uk>
        How do we Call an external routine in Perl <Admin@goMonitor.com>
    Re: How do we Call an external routine in Perl <nospam@bigpond.com>
    Re: How do we Call an external routine in Perl (Tad McClellan)
        How to write to drive A:\ from CGI Perl (Cle)
        Ignoring quoted strings in regular expressions (nick)
    Re: Ignoring quoted strings in regular expressions <usenet@morrow.me.uk>
        Parsing command line options with ranges or sets <asdf@asdf.com>
    Re: Parsing command line options with ranges or sets <usenet@morrow.me.uk>
    Re: Parsing command line options with ranges or sets (Jay Tilton)
    Re: SGML/HTML syntax trivia (was Re: any idea how to op <abigail@abigail.nl>
    Re: subroutine parameter with regex (Jay Tilton)
    Re: Syntax problem <jurgenex@hotmail.com>
    Re: Syntax problem (Tad McClellan)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 06 Dec 2003 04:48:32 GMT
From: "Picker Leon" <Temp@NoSuchDomain.Info>
Subject: Am I right on Mod_Perl?
Message-Id: <AcdAb.399345$0v4.19907890@bgtnsc04-news.ops.worldnet.att.net>

After reading the links on perl.apache.org, I have concluded this:
If I have take care of the globle varible by either make no globle varibles,
or by clean them each time before I use them and after I use them, I can
pretty much use the same code of my perl in mod_perl enviroment.

Please correct me if I am wrong.




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

Date: 06 Dec 2003 01:40:26 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: any idea how to optimize this regex?
Message-Id: <slrnbt2csa.eu.abigail@alexandra.abigail.nl>

Malcolm Dew-Jones (yf110@vtn1.victoria.tc.ca) wrote on MMMDCCXLVIII
September MCMXCIII in <URL:news:3fcfd01e@news.victoria.tc.ca>:
@@  
@@  First off, a comment does not end with >, it ends with --> (and starts
@@  with <!-- so why not test for that correctly also)?
@@  
@@   <!--.*?-->

That fails on:

     <!-- Comment -- --> Also a comment <!-- -- -- >



Abigail
-- 
perl -wle\$_=\<\<EOT\;y/\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT


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

Date: 06 Dec 2003 01:43:03 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: any idea how to optimize this regex?
Message-Id: <slrnbt2d16.eu.abigail@alexandra.abigail.nl>

Ben Morrow (usenet@morrow.me.uk) wrote on MMMDCCXLVIII September MCMXCIII
in <URL:news:bqol7f$bmo$2@wisteria.csv.warwick.ac.uk>:
**  
**  yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) wrote:
** > First off, a comment does not end with >, it ends with --> (and starts
** > with <!-- so why not test for that correctly also)?
** > 
** >   <!--.*?-->
** > 
** > If you know the comments can't have > in them, then a character class 
** > would be quicker than .*?
** > 
** >   <!--[^>]*>
** > 
** <snip>
** >
** > Also, the .*? is a potential bug, because it does not _prevent_ the re
** > from matching two (or more) comments at the place you intend to match a
** > single comment, it simply says "match no more than is necessary to get a 
** > match", so the regex engine could be trying combinations of multiple 
** > comments in an attempt to get a {5} /g match to work.
**  
**  I'm somewhat thinking aloud here, but would
**  
**  / (?: <!-- (?: [^-] (?!->) )* --> ){5} /x
**  
**  perform the correct match here? The generalisation of [^>]: ie. 'match
**  anything up to this multi-character string' is something one quite
**  often wants.


That fails on:

    <!--> Comment one <!----> Comment two <!-->


Abigail
-- 
$_ = "\x3C\x3C\x45\x4F\x54" and s/<<EOT/<<EOT/e and print;
Just another Perl Hacker
EOT


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

Date: Fri, 5 Dec 2003 21:26:01 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: any idea how to optimize this regex?
Message-Id: <d7bAb.15622$yd.2303140@news20.bellglobal.com>


"Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote in message
news:Pine.LNX.4.53.0312051616320.25622@ppepc56.ph.gla.ac.uk...
> On Fri, 5 Dec 2003, Matt Garrish wrote:
>
> > Then again, what standards do any browsers adhere to? : )
>
> That's another matter entirely.  And just don't start me on Appendix C
> to XHTML/1.0
>

Oh come on, at least they recognize that xhtml is never going to fly! The
whole popularity of the web lies in the ability of Joe Blow web designer
wannabe to toss whatever tags and styles he wants on a page and see a nice
pretty page pop up in his favourite M$ browser (okay a bit of an
exaggeration). Much as I'd prefer to see sgml-like tagging requirements
enforced in html, xhtml is a pipe-dream. XML will obviously survive, but
getting the riff-raff to adhere to coding standards I just can't see
happening (unless the wysiwyg editors get onboard). Which is sad in the end,
because it means there will always be new people asking how to parse html
with a regular expression...

Matt




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

Date: Sat, 6 Dec 2003 03:32:43 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: any idea how to optimize this regex?
Message-Id: <bqrikr$dqs$1@wisteria.csv.warwick.ac.uk>


abigail@abigail.nl wrote:
> Ben Morrow (usenet@morrow.me.uk) wrote on MMMDCCXLVIII September MCMXCIII
> in <URL:news:bqol7f$bmo$2@wisteria.csv.warwick.ac.uk>:
> **
> **  I'm somewhat thinking aloud here, but would
> **  
> **  / (?: <!-- (?: [^-] (?!->) )* --> ){5} /x
> **  
> **  perform the correct match here? The generalisation of [^>]: ie. 'match
> **  anything up to this multi-character string' is something one quite
> **  often wants.
> 
> That fails on:
> 
>     <!--> Comment one <!----> Comment two <!-->

Ouch! I had to think *quite* hard to convince myself that '<!-->
Comment one <!---->' isn't a valid comment... it's obvious once you
see the symmetry of it, of course.

OK, making a small modification and applying the grammar fragment Tad
gave:

my $com = qr/-- (?: (?!--) . )* --/x;
/<! (?: $com (?: \s* | $com )* )? >/x;

or in Perl6, just to show how much nicer it is when you get rid of all
those bleedin' question-marks:

my $com = rx/-- [ <!before --> . ]* --/;
m{<'<!'> [ <$com> [ \s* | <$com> ]* ]? <'>'>};

:).

This problem has been solved before, of course, so this is purely an
exercise in (not-so) Tricky Regexes on my part. Apologies if I've
bored anyone.

Ben

-- 
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
   From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes,        [ Heracles shoots Vulture with arrow. Vulture bursts into ]
 /Alcestis/)        [ flame, and falls out of sight. ]         ben@morrow.me.uk


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

Date: Fri, 5 Dec 2003 20:19:40 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: appending to file appends twice!?
Message-Id: <slrnbt2f5s.8uk.tadmc@magna.augustmail.com>

Guy <someone@somewhere.nb.ca> wrote:

>   if($chk==0)


Space characters are not a scarce resource.

Feel free to use as many as you like to make your code
easier to read and understand:

   if ( $chk == 0 )


>       @qafield=();
>       push(@qafield,split(/\t/,$qaline));
>       $number=$qafield[0];


You can replace those 3 lines with one line that uses a "list slice":

   my $number = (split(/\t/,$qaline))[0];  # untested


>     if(-d "$fd")
            ^   ^
            ^   ^
A useless use of double quotes:

   perldoc -q quot

       What's wrong with always quoting "$vars"?


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


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

Date: Fri, 5 Dec 2003 22:04:13 -0500
From: Walt Mankowski <waltman@pobox.com>
Subject: Re: appending to file appends twice!?
Message-Id: <slrnbt2hpd.bp9.waltman@waltman.dnsalias.org>

On 2003-12-05, Guy <someone@somewhere.nb.ca> wrote:
> Hi all, :-)
>
> I wrote a Perl script to append Questions and Answers to a text data file.
> The file would look like this and would grow when Q&As are added.
> 1          Q         This is a question
> 1          A         This is an answer
> 2          Q         This is another question
> 2          A         This is another answer
>
> All I do is open the file for append, print 2 lines (Q line and A line) and
> then close the file.  What's happening however is that my data is appended
> twice, like this: This is an actual cut & Paste of the entire file.
>
> 1 Q Here is my question
> 1 A Hee is my answer
> 2 Q Here is my question
> 2 A Hee is my answer
> 3 Q here is another question
> 3 A this is another answer
> 4 Q here is another question
> 4 A this is another answer
> 5 Q qqqqq
> 5 A zaaaaaa
> 6 Q qqqqq
> 6 A zaaaaaa
> 7 Q sdfkhj asdlfh fih asdfh ;alsdfh
> 7 A asdkfj; alsdfh ausf iaufh jkahf kawhef awef
> 8 Q sdfkhj asdlfh fih asdfh ;alsdfh
> 8 A asdkfj; alsdfh ausf iaufh jkahf kawhef awef
>
> What's worst is that you notice on the above file that the count does
> increment as if my routine is called twice. So what I've done was added a
> few check-point print commands inside the routine and these only print once,
> as if my routine is only called once.
>
> Any ideas,

The code looks OK, so chances are it is being called twice somehow.

This looks like CGI code.  Is it possible the script itself is being
called twice?  What do your weblogs say?

Walt


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

Date: Sat, 06 Dec 2003 01:55:25 GMT
From: "Picker Leon" <Temp@NoSuchDomain.Info>
Subject: Can you explain LOCAL, MY and OUR with examples?
Message-Id: <hGaAb.398436$0v4.19889492@bgtnsc04-news.ops.worldnet.att.net>

I read the perldoc -f local, my our, but would like to know what exactly is
"eval", because without knowing "eval" I can not understand LOCAL, MY, OUR
clearly. I got some ideas what those are, but very confused what difference
they have.

Anyone can give me an example script which will act differently with MY,
LOCAL and OUR?

Thank you.




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

Date: Sat, 6 Dec 2003 03:45:49 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Can you explain LOCAL, MY and OUR with examples?
Message-Id: <bqrjdd$dqs$2@wisteria.csv.warwick.ac.uk>


"Picker Leon" <Temp@NoSuchDomain.Info> wrote:
> I read the perldoc -f local, my our, but would like to know what exactly is
> "eval", 

Have you read perldoc -f eval? If so, what in the first two paragraphs
do you not understand (this is not (just) sarcasm: if it is unclear to
a beginner, then it would be good to know so someone can fix the docs)?

> because without knowing "eval" I can not understand LOCAL, MY, OUR
> clearly.

I don't know where you got that idea from... the concepts are not
really related. This may be why you are confused... :)

> I got some ideas what those are, but very confused what difference
> they have.

That's likely because it's confusing :).

> Anyone can give me an example script which will act differently with MY,
> LOCAL and OUR?

For my/local, read the last entry in perldoc -q local. See also
<http://perl.plover.com/FAQs/Namespaces.html>, which also deals with
our(), and with 'use vars' which it replaces.

Ben

-- 
   If you put all the prophets,   |   You'd have so much more reason
   Mystics and saints             |   Than ever was born
   In one room together,          |   Out of all of the conflicts of time.
ben@morrow.me.uk |----------------+---------------| The Levellers, 'Believers'


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

Date: Sat, 06 Dec 2003 12:45:59 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: Can you explain LOCAL, MY and OUR with examples?
Message-Id: <bqrjkp$nm8$1@pin3.tky.plala.or.jp>

Picker Leon wrote:
> I read the perldoc -f local, my our, but would like to know what exactly is
> "eval", because without knowing "eval" I can not understand LOCAL, MY, OUR
> clearly. I got some ideas what those are, but very confused what difference
> they have.
> 
> Anyone can give me an example script which will act differently with MY,
> LOCAL and OUR?
> 
> Thank you.
> 
> 

perldoc -f local directs you to read perlsub. So do a:

pelrdoc perlsub

from your shell. The examples/explanations are *very* good and include 
code snippets. In particular, read the sections:

1. Private Variables via my()
2. Temporary Values via local()
3. When to Still Use local()

Then do a 'perldoc -f our' for an explanation of our.

If you don't understand a particular section of perlsub, please ask. 
Someone will help.

HTH - keith



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

Date: Fri, 5 Dec 2003 21:42:17 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Can you explain LOCAL, MY and OUR with examples?
Message-Id: <slrnbt2k0p.93f.tadmc@magna.augustmail.com>

Picker Leon <Temp@NoSuchDomain.Info> wrote:

> I read the perldoc -f local, 


Have you tried

   perldoc -q local

as well?

       What's the difference between dynamic and lexical (static)
       scoping?  Between local() and my()?


> my our, but would like to know what exactly is
> "eval", because without knowing "eval" I can not understand LOCAL, MY, OUR
> clearly. 


Lexical (my) vs dynamic (local) scoping can be understood *without* 
knowing about eval().

Why do you think you need to know eval() to understand scoping?

Just about every programming language has scoping, only a few
of them have eval()...


> I got some ideas what those are, but very confused what difference
> they have.


If you don't tell us your ideas, then we cannot confirm that you have
it right, nor can we help correct them if they are not.  (hint)


See also:

   "Coping with Scoping":

      http://perl.plover.com/FAQs/Namespaces.html


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


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

Date: Sat, 06 Dec 2003 04:54:15 GMT
From: "Picker Leon" <Temp@NoSuchDomain.Info>
Subject: Re: Can you explain LOCAL, MY and OUR with examples?
Message-Id: <XhdAb.399372$0v4.19909705@bgtnsc04-news.ops.worldnet.att.net>

I read perldoc -f eval. My understanding is that

1
{
print 'hi';
}

is no difference from

2
eval
{
print 'hi';
}

because both 1 and 2 act as what in {} as a small perl program and returns
back to the main block.




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

Date: Sat, 6 Dec 2003 01:54:39 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Don't Read - Testing
Message-Id: <Pine.LNX.4.53.0312060144420.26191@ppepc56.ph.gla.ac.uk>

On Fri, 5 Dec 2003, Daniel R. Tobias wrote:

> "Matt Garrish" <matthew.garrish@sympatico.ca> wrote in message news:<75xzb.10435$zf2.1295016@news20.bellglobal.com>...
> > Emailers hate it when others intersperse comments in their messages
> > because it makes following the train of logic more difficult (i.e., it's
> > usually a conversation between two people, so you know what you're both
> > talking about).

I can't agree.  I have several colleagues whose routine email style
consists of a brief comment plonked on top of 500 lines of the
previous fortnight's discussion which, one can immediately sense from
the comment, they haven't bothered to read in any detail, let alone
actually comprehend.  I parse that as a double discourtesy.

> I, for one, have always used the same interleaved reply style for
> e-mail as I have for newsgroups;

I try to adapt to the prevailing custom of the forum, even when I
think it's senseless^W suboptimal.  But in the case of Usenet, the
traditional snipping for context with interleaved responses is
self-evidently the right one, and I'd extend that to mailing lists of
any size, also.

I'm not sure why every Usenet group has to regularly descend into a
discussion on usenet-wide netiquette, but there you have it.


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

Date: Sat, 06 Dec 2003 04:53:40 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Executing a command on a remote Windows 2000 machine
Message-Id: <20031205235340.31fd9e0d.jwillmore@remove.adelphia.net>

On Fri, 05 Dec 2003 11:26:49 -0800
Noname <asdf@asdf.com> wrote:

> Is there a perl module that will allow me to execute a command on a
> remote Win2K machine?  Basically, I would like to make a cluster
> administration script that uses the Win32API rather than resorting
> to system calls and hackish programs like psexec.

Depends.  If you want to use telnet, then you could use the
Net::Telnet module.  If you want to use ssh, then you could use the
Net::SSH module.  If you want to trap an SNMP packet and then have the
box do something, then you could use the Net::SNMP module.

You *could* install Perl on the box in question and then set up a
client/server situation.

HTH
-- 
Jim

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

a fortune quote ...
Birth, n.:  The first and direst of all disasters.   -- Ambrose
Bierce, "The Devil's Dictionary" 


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

Date: Fri, 5 Dec 2003 23:43:26 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: gui in perl
Message-Id: <bqr56u$44k$1@wisteria.csv.warwick.ac.uk>


"Ala Qumsieh" <xxala_qumsiehxx@xxyahooxx.com> wrote:
> No. Tk uses the Motif look on X by default, which I agree is horrible. But,
> this can be very easily changed, although not too many people know about it.
> Check out this thread on comp.lang.perl.tk for more details (let's hope my
> newsreader doesn't screw it up):
> 
> http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&c2coff=1&frame=r
> ight&th=7123d87e82847225&seekm=TSpwb.483254%246C4.125757%40pd7tw1no#link9

Thank you... I'll take a look. I agree that the API is nicer than the
alternatives.

Ben

-- 
"If a book is worth reading when you are six,                * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis


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

Date: Fri, 5 Dec 2003 20:59:05 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: gui in perl
Message-Id: <ZJaAb.15572$yd.2291873@news20.bellglobal.com>


"Helgi Briem" <HelgiBriem_1@hotmail.com> wrote in message
news:u141tvsp87amc1ftcekkqi23asotslbe32@4ax.com...
> On Fri, 5 Dec 2003 08:40:02 -0500, "Matt Garrish"
> <matthew.garrish@sympatico.ca> wrote:
>
> >But is it worth the pain? I've given up on Tk and just use vc++ to build
gui
> >wrappers to my perl scripts (when I'm too lazy to rewrite all my code in
> >vc++ but have to make a program "user-friendly").
>
> You find VC++ easier than Tk?!?!
>
> You've been doing something wrong, that's for sure.
>

It's not about complexity, but the speed at which you can toss a gui
together. Much as I enjoy sitting for hours positioning buttons and playing
with colours and alignment just to get a half-fugly Tk gui, I'll stick to
the simplicity of creating one in VC++. As noted above, I avoid trying to
code in the half-baked language as much as possible (it's not quite C and
not quite C++, but damn if doesn't make a nice mess of both), but passing a
few user-variables on to a perl script doesn't require much of a brain, to
which I can well attest... : )

Matt




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

Date: Sat, 06 Dec 2003 03:17:20 -0000
From: Dave Benjamin <ramen@lackingtalent.com>
Subject: Re: gui in perl
Message-Id: <slrnbt2j09.i6a.ramen@lackingtalent.com>

In article <bqqah6$ig7$1@news.dtag.de>, Malte Ubl wrote:
> Helgi Briem wrote:
>>>>As others have said, there is also the Tk stuff - certainly pretty easy to
>>>>use and get up and running, but from my experience it produces horrible
>>>>looking apps - but that may not be of concern to you, and I know the Tk
>>>>guys are working on it.
>>>
>>>While this is certainly true under Unix, the win32 port of Tk produces
>>>apps which look just like any other windows app; no more and no less
>>>offensive :).
>> 
>> 
>> It looks just as good (or bad) as the underlying windowing
>> system, X, Apple Mac or whatever.  It certainly always 
>> looks better than anything produced by Java and it's far,
>> far easier to program.   My god, Java produces horrible looking 
>> guis.
> 
> Thats Swing, not Java. AWD (right acronym?) used by e.g. Eclipse is 
> really beautiful.

SWT. And Eclipse's commercial rival, IntelliJ IDEA, has a Swing-based
interface that I think is really beautiful as well. And this is a lot coming
from someone who usually considers Java GUIs to be slow, bloated, and ugly.

The shortest path from zero to GUI for me is still Tk, though, and with a
little configuration and attention to detail, it can produce rather nice
GUIs as well. They are working on improving the Look and Feel these days, BTW:

http://tcl.projectforum.com/tk/Home

(thanks to Cameron Laird for pointing this out awhile back...)

-- 
 .:[ dave benjamin (ramenboy) -:- www.ramenfest.com -:- www.3dex.com ]:.
: d r i n k i n g   l i f e   o u t   o f   t h e   c o n t a i n e r :


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

Date: Sat, 06 Dec 2003 02:22:53 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Help with POST request using LWP?
Message-Id: <3FD13A55.600@rochester.rr.com>

at Bob Mariotti wrote:

 ...


Just a guess...


> $REQ->content('NETCONNECT_TRANSACTION=$DATA');

"---------------^----------------------------^
Note that $DATA is not interpolated using '...' quotation.

 ...
> Bob

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Sat, 6 Dec 2003 03:56:37 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Help with POST request using LWP?
Message-Id: <bqrk1l$dqs$3@wisteria.csv.warwick.ac.uk>


R.Mariotti(at)FinancialDataCorp.com (Bob Mariotti) wrote:
> $REQ= POST $URL2;
> $REQ->content_type('application/x-www-form-urlencoded');
> $REQ->content_length(length($DATA));
> $REQ->content('NETCONNECT_TRANSACTION=$DATA');

You should be creating your request with:

my $REQ = POST $URL2, [ NETCONNECT_TRANSACTION => $DATA ];

or indeed simply using

my $RSP = post $UA $URL2, 
                   [ NETCONNECT_TRANSACTION => $DATA ],
                   ':content_file' => "CX7RSP";

, either of which will properly deal with URLencoding the XML.

Ben

-- 
It will be seen that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher convinces them that their institutions are not based 
on the strictest morality.  [Samuel Butler, paraphrased]       ben@morrow.me.uk


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

Date: Fri, 5 Dec 2003 18:02:22 -0500
From: "Bazil" <Admin@goMonitor.com>
Subject: How do we Call an external routine in Perl
Message-Id: <u78Ab.14556$yd.2209999@news20.bellglobal.com>

Is there a way to call/ launch an external command in perl
I mean for example call a Java script or a shortcut of some sort.

Thanks for any suggestion




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

Date: Sat, 06 Dec 2003 09:31:15 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: How do we Call an external routine in Perl
Message-Id: <1108047.6Cv1RKhYse@gregs-web-hosting-and-pickle-farming>

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

> Is there a way to call/ launch an external command in perl
> I mean for example call a Java script or a shortcut of some sort.
> 
> Thanks for any suggestion

Browsers call javascript, not Perl.

In linux/unix, the system() command calls an external program, either a shell script or an executable.

gtoomey


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

Date: Fri, 5 Dec 2003 20:20:56 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How do we Call an external routine in Perl
Message-Id: <slrnbt2f88.8uk.tadmc@magna.augustmail.com>

Bazil <Admin@goMonitor.com> wrote:

> Is there a way to call/ launch an external command in perl
                                    ^^^^^^^^

   perldoc -q external


You are expected to check the Perl FAQ *before* posting to
the Perl newsgroup.


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


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

Date: 5 Dec 2003 20:34:14 -0800
From: canle@lecan.com (Cle)
Subject: How to write to drive A:\ from CGI Perl
Message-Id: <8a21e493.0312052034.4fc49519@posting.google.com>

Hi!

Please show me how to write an output.txt file from CGI perl sript to
drive A or C?
I could access drive A by HTML codes, and I know how to write to a
file from CGI Perl script. However, a Perl book shown the same thing
for CGI Perl script that doesn't work.

The path from my website:

http://www.mywebsite.com/cgi-bin/cgiwrap/myName/MyFile.pl

Thank you


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

Date: 5 Dec 2003 19:07:41 -0800
From: nickgieschen@hotmail.com (nick)
Subject: Ignoring quoted strings in regular expressions
Message-Id: <305cab98.0312051907.3ee12781@posting.google.com>

I couldn't find a usenet group on regular expressions, so I'm posing
here. Sorry if this is the wrong place to post.

Anyway, I'm wondering if there's some way to specify in a regular
expression a way to ignore quoted strings. For example:

1. blah whatever blah
2. blah "whatever" blah
3. blah " whatever " blah

I want to match 1, but not 2 or 3. Essentially, I want to match if
whatever is anywhere in the string and unquoted.

At http://www.cs.sfu.ca/~cameron/REX.html I found the following:

([^]"'><]+|"[^"]*"|'[^']*')*>

"This expression scans through arbitrary content searching for the
closing ">" delimiter. Quoted strings are skipped and the scan may
terminate with failure if an erroneous "]" or "<" delimiter is
encountered."

I don't see where in the above RE the actual quoted string skipping is
being done.

Any help would be appreciated.

Thanks,

Nick


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

Date: Sat, 6 Dec 2003 04:09:47 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Ignoring quoted strings in regular expressions
Message-Id: <bqrkqb$evu$1@wisteria.csv.warwick.ac.uk>

nickgieschen@hotmail.com (nick) wrote:
> I couldn't find a usenet group on regular expressions, so I'm posing
> here. Sorry if this is the wrong place to post.

Which language/regex package are you using? You would be best off in a
group specific to that. Unless, of course, this is a homework problem.

> Anyway, I'm wondering if there's some way to specify in a regular
> expression a way to ignore quoted strings. For example:
> 
<snip>
> At http://www.cs.sfu.ca/~cameron/REX.html I found the following:
> 
> ([^]"'><]+|"[^"]*"|'[^']*')*>

Bleech. Talk about line-noise :).

Let's break it up. Stuff from # to end-of-line is my commentary.

(            # start group
  [^]"'><]+  # match as much stuff as possible that doesn't include
             # ] " ' > or <.
  |          # or
  " [^"]* "  # a double-quoted string (" followed by as much not-" as
             # you can followed by another ")
  |          # or
  ' [^']* '  # a single-quoted string (as above)
)*           # keep doing all of the above as much as you can
>            # end by matching a >.

Ben

-- 
  The cosmos, at best, is like a rubbish heap scattered at random.
                                                         - Heraclitus
  ben@morrow.me.uk


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

Date: Fri, 05 Dec 2003 16:25:48 -0800
From: Tyaan <asdf@asdf.com>
Subject: Parsing command line options with ranges or sets
Message-Id: <eq72tvg66535610hb15oi5dd8res40o2ss@4ax.com>

I'm trying to parse command line arguments to a script and put them
into a a scalar for the command and an array containing just the
numbers specified by the ranges or sets.  (I'm forcing the dbbm prefix
to remind the user these are node numbers and not IP's).  This code
works but I'm really thinking that there must be a much better way to
do it.  Thanks

This is an example usage:
myperlprog.pl mycmd dbbm100
myperlprog.pl mycmd dbbm100-120
myperlprog.pl mycmd dbbm100,120,130

I want $cmd=mycmd and @nodes={100,101,102,etc...}.

would it be easy to also add something like:
myperlprog.pl mycmd dbbm100-120,125,156?

sub ParseArgs()
{
	my ($temp, $low, $high);
	
	# Get command
	$cmd = $ARGV[0];
	
	if($ARGV[1]=~/-/) # Read a range
	{	
		$ARGV[1]=~/(dbbm)(\d+)(-)(\d+)/;
	  	$low  = $2;
  	  	$high = $4;
	  	for($temp=$low;$temp<=$high;$temp++)
	  	{  $nodes[$temp-$low]=$temp; }
	}
	
	elsif($ARGV[1]=~/,/) # Read a set
	{ 	$temp=0;
		$_=$ARGV[1];
		while(/(\d+)(,)/s)
		{		
			$nodes[$temp]=$1;
			$_=$';
			$temp++;
		};
		$_=$ARGV[1];
		/(.*,)(\d*)/;
		$nodes[$temp]=$2;
	}

	else # Read a single host
	{ 	$ARGV[1]=~/(dbbm)(\d+)/;
		$nodes[0]=$2;
	}
};



 ................................................................
       Posted via TITANnews - Uncensored Newsgroups Access
             >>>> at http://www.TitanNews.com <<<<
-=Every Newsgroup - Anonymous, UNCENSORED, BROADBAND Downloads=-



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

Date: Sat, 6 Dec 2003 01:00:03 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Parsing command line options with ranges or sets
Message-Id: <bqr9mj$7uf$1@wisteria.csv.warwick.ac.uk>


Tyaan <asdf@asdf.com> wrote:
> This is an example usage:
> myperlprog.pl mycmd dbbm100
> myperlprog.pl mycmd dbbm100-120
> myperlprog.pl mycmd dbbm100,120,130
> 
> I want $cmd=mycmd and @nodes={100,101,102,etc...}.
> 
> would it be easy to also add something like:
> myperlprog.pl mycmd dbbm100-120,125,156?

my $cmd = shift;  # this must be in the main program, not a sub.
my @nodes = parse_ranges(@ARGV);

sub parse_ranges {
    my (@nodes, %nodes);

    for (@_) { # this allows many 'nodes' arguments
        /^dbbm ((?: \d+ (?:-\d+)? , )* (?: \d+ (?:-\d+)? )) $/x
            or die "invalid argument: $_";
        my @ranges = split /,/, $1;
        for (@ranges) {
            if (/(\d+)-(\d+)/) {
                die "invalid range: $1-$2" unless $2 > $1;
                push @nodes, $1..$2;
            } else {
                push @nodes, $_;
            }
        }
    }

    @nodes{@nodes} = ();   # this makes sure we have only one of each
    return sort keys %nodes;
}

Ben

-- 
       .  |  .
    \           /           The clueometer is reading zero.
  .               .
 __ <-----@       __                                           ben@morrow.me.uk


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

Date: Sat, 06 Dec 2003 01:30:51 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Parsing command line options with ranges or sets
Message-Id: <3fd130c6.119299379@news.erols.com>

Tyaan <asdf@asdf.com> wrote:

: I'm trying to parse command line arguments to a script and put them
: into a a scalar for the command and an array containing just the
: numbers specified by the ranges or sets.  (I'm forcing the dbbm prefix
: to remind the user these are node numbers and not IP's).  This code
: works but I'm really thinking that there must be a much better way to
: do it.  Thanks
: 
: This is an example usage:
: myperlprog.pl mycmd dbbm100
: myperlprog.pl mycmd dbbm100-120
: myperlprog.pl mycmd dbbm100,120,130
: 
: I want $cmd=mycmd and @nodes={100,101,102,etc...}.
: 
: would it be easy to also add something like:
: myperlprog.pl mycmd dbbm100-120,125,156?

[snip code]

Nothing to it, with a little help from a module on CPAN.

    use Set::IntSpan;
    my($set) = $ARGV[1]=~/dbbm(.*)/;
    @nodes = Set::IntSpan->new( $set )->elements;



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

Date: 06 Dec 2003 01:38:21 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: SGML/HTML syntax trivia (was Re: any idea how to optimize this regex?)
Message-Id: <slrnbt2cod.eu.abigail@alexandra.abigail.nl>

Alan J. Flavell (flavell@ph.gla.ac.uk) wrote on MMMDCCXLVIII September
MCMXCIII in <URL:news:Pine.LNX.4.53.0312051554390.25622@ppepc56.ph.gla.ac.uk>:
||  On Fri, 5 Dec 2003, Tad McClellan wrote:
||  
|| >    2. Use a module.

    use Regexp::Common;

    /$RE{comment}{HTML}/;

||  And hope the module author has read the book too  ;-)


The author did.


    $ perl -MRegexp::Common -wle 'print $RE{comment}{HTML}'
    (?:(?:<!)(?:(?:--(?:[^-]*(?:-[^-]+)*)--\s*)*)(?:>))
    $


Abigail
-- 
# Perl 5.6.0 broke this.
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


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

Date: Fri, 05 Dec 2003 23:36:07 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: subroutine parameter with regex
Message-Id: <3fd0ebe2.101660126@news.erols.com>

Tassos <chatasos@yahoo.com> wrote:

: Ben Morrow wrote:
: 
: > Tassos <chatasos@yahoo.com> wrote:
: > 
: >>$var1 = "Se2:5";
: >>if ( $var1 =~ /^Se\d/ ) {
: >>	$var1 =~ s/Se/Serial/;
: >>	&routine1($var1);
: >>	$var1 =~ s/Serial/Se/;
: >>}
: >>
: >>Is there a way i can call routine1 using the previous $var1 regex as
: >>its parameter, so i don't have to double regex?
: > 
: > Err... I understand your Perl better than your English. I think what
: > you are asking for is
: > 
: > if( $var1 =~ /^Se\d/ ) {
: >     (my $var2 = $var1) =~ s/Se/Serial/;
: >     routine1($var2);
: > }
: 
: That's what i'm trying to do, but i was hoping of a better way...ex. to 
: include the regex into the () of the sub call.
  ^^^^^^^^^^^^^^^^^
Calling s/// a regex is incorrect.  The s/// operator utilizes a regex, but
is not a regex itself.  

What you want is an s/// operator that returns the altered string, which
can then be used in a subroutine's argument list.  The s/// operator is not
going to cooperate with that idea.

You could fake it by creating a pseudo-subroutine that does return the
altered string.

    if ( $var1 =~ /^Se\d/ ) {
        routine1( do{(my $var2 = $var1) =~ s/Se/Serial/; $var2} );
    }

Or you could make the m// operation in the if() condition do part of the
work.

    if ( $var1 =~ /^Se(\d.*)/ ) {
        routine1( "Serial$1" );
    }

Or, since matching is a necessary part of substitution, you could move the
s/// into the if() condition.

    if(
        (my $var2 = $var1) =~ s/^Se(?=\d)/Serial/
    ) {
        routine1( $var2 );
    }



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

Date: Sat, 06 Dec 2003 02:20:59 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Syntax problem
Message-Id: <f2bAb.1717$dA1.129@nwrddc03.gnilink.net>

Glenn J. Rowe wrote:
> I need to read in a variable and make sure it is in the exact format
> of YYYY_MMM_DD_hh:mm:ss

A namesake of yours just posted exactly the same question to alt.perl.
You may want to check there for answers.

jue




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

Date: Fri, 5 Dec 2003 20:12:11 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Syntax problem
Message-Id: <slrnbt2enr.8uk.tadmc@magna.augustmail.com>

Glenn J. Rowe <undisclosed_sender@undisclosed_domain.com> wrote:

> Subject: Syntax problem


You do not have a syntax problem, your code compiles just fine.

It must be some other kind of problem.


> I need to read in a variable and make sure it is in the exact format of
> YYYY_MMM_DD_hh:mm:ss
> Example... 2003_DEC_05_14:05:26
> 
> 
> I tried the following code but it doesn't work...


What does "doesn't work" mean when you say it?


> if($variable=~m/(\d{4})(_)(\D{3})(_)(\d{2})(_)(\d{2})(:)(\d{2})(:)(\d{2})/)


We need two things (a string and a pattern) in order to evaluate the 
behavior of a pattern match, but we only have one of them.

What value is in $variable?

Your pattern looks fine to me (apart from a bunch of parenthesis
that are not needed).


> I am a self taught programmer so any help you can give me would be
> appreciated.


Read the Posting Guidelines that are posted here frequently.


-- 
    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.  

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


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