[21738] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3942 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 9 18:11:13 2002

Date: Wed, 9 Oct 2002 15:10:18 -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           Wed, 9 Oct 2002     Volume: 10 Number: 3942

Today's topics:
    Re: Not so simple RE problem... <dd@4pro.net>
        parsing mount output. <dmehler@siscom.net>
    Re: Question about scope. (Tad McClellan)
        Re-entrant parser <dd@4pro.net>
        Run perl script on web server from command line <ignore@nobody.com>
    Re: Run perl script on web server from command line <wsegrave@mindspring.com>
    Re: Run perl script on web server from command line <camerond@mail.uca.edu>
    Re: Run perl script on web server from command line <ignore@nobody.com>
    Re: Run perl script on web server from command line <wsegrave@mindspring.com>
    Re: XML::RSS bug <swen@news.com>
    Re: XML::RSS bug <swen@news.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 9 Oct 2002 15:24:55 -0400
From: "Domizio Demichelis" <dd@4pro.net>
Subject: Re: Not so simple RE problem...
Message-Id: <ao1vr1$icq0j$1@ID-159100.news.dfncis.de>

Thank you a lot for your advice. I like the Parser-like approach that you
suggest, and I found your explanations very useful.

Your codes raised another question about parsing that I have just posted as
a new more general topic.

thank you

--
-.. --- -- .. --.. .. ---
-.. . -- .. -.-. .... . .-.. .. ...


"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:ao16pu$fk3$1@mamenchi.zrz.TU-Berlin.DE...
> According to Domizio Demichelis <dd@4pro.net>:
> > I have a problem that I thought was simple to solve, until I tried :-)
> >
> > I have this string:
> >
> > $string = << '__EOS__';
> > aaa {a} bbb {a} ccc {a} XXX {b} XXX {/a} ddd
> > aaa {b} bbb {b} ccc {a} XXX {/a} ddd
> > aaa {a}{/a} bbb {a} ccc {a} ddd
> > __EOS__
> >
> > I need to replace the  "{a}.*?{/a}" and the "{a}" (without the end {/a})
> > with a "#", so - after the search and replace operation - the $string
should
> > contain this:
> >
> > "aaa # bbb # ccc # ddd
> > aaa {b} bbb {b} ccc # ddd
> > aaa # bbb # ccc # ddd"
> >
> > Note: $string could contain everything (.+) (and not just the \w that I
put
> > in the example to make it simpler to understand), the lines are not well
> > organized as they appear in the example, and... I should use the content
> > between {a} and {/a}. ( as in qr|{a}(.*?){/a}| )
>
> A single regex is certainly not the right approach here.  Even if
> it can be done, it is nothing you want to maintain.
>
> Eric(?) has already advised you to use a parser if there is one
> for the language you're working on.
>
> If there isn't, use a parser-like approach.  Scan the string forward
> for each opening delimiter "{a}".  If found, look ahead for the next
> opening or closing delimiter "{a}" or "{/a}".  If it is another opening
> delimiter, the original one is a singleton and must be replaced by
> itself.  If it is a closing delimiter "{\a}", extend the match to
> include it and the intervening text and replace that.  Resume scanning
> after the replaced text.
>
> The following code assumes the string in $_.  It uses the interplay of
> global matching and the pos() function.  See "perldoc -f pos" for that.
> It also uses the @- and @+ arrays, described in perlvar.  As is common
> in Perl, pos() keeps track of the parser's progress.
>
>     while ( /\{a\}/g ) {
>         my ( $from, $to) = ( $-[ 0], $+[ 0]);
>         $to = $+[ 0] if m!\{(/?)a\}!g and $1 eq '/';
>         substr( $_, $from, $to - $from) = '#';
>         pos = $from + length '#'; # resume after replacement
>     }
>
> Anno








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

Date: Wed, 9 Oct 2002 17:38:55 -0400
From: "dave" <dmehler@siscom.net>
Subject: parsing mount output.
Message-Id: <3da4a3d2$0$38599$9a6e19ea@news.newshosting.com>

Hello,
    I feel like i'm reinventing the wheel with this. I've got mount output
that i need to parse. I'm looking for a specific pattern which i have found,
then i need to get where the mount point is. If anyone has a script that
comes close to doing this please could you send it my way?
Thanks.
Dave.





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

Date: Wed, 9 Oct 2002 13:05:16 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Question about scope.
Message-Id: <slrnaq8rus.303.tadmc@magna.augustmail.com>

Rubber Duck <rubberducky703@hotmail.com> wrote:
> 
> I have a couple of sub procedures which i would like to keep as localised as
> i can.

> The problem i'm having is that Start declares some variables which are used
> by either/or Work and/or Main.  I'd rather not just declare these variables
> as global cause i like my code nice and tidy.  Is their any trick i can do
> to declare a variable in start and then to be able to use the value in that
> variable in another procedure - say work??


If a routine needs read-only access to the values, then you
can pass them as arguments.

If a routine needs to modify the values, then you can return
the modified values.


I would probably go with a single global hash that each routine
can access instead.


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


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

Date: Wed, 9 Oct 2002 15:24:47 -0400
From: "Domizio Demichelis" <dd@4pro.net>
Subject: Re-entrant parser
Message-Id: <ao1vqp$i1abv$1@ID-159100.news.dfncis.de>

I have to parse and change a string containing simple start and end labels
of the form {a} and {/a}.

The "process" sub should extract the content between a {a} and {/a} block
(labels excluded) and pass it to a sub that will return a modified copy of
the block content itself. Outer blocks should be processed first, and inner
last.
If any {a} without the end {/a} is encountered, the sub should be called
anyway and it should receive a undef content. (See below the sequences of
values that the "return_changed_content" sub should receive.)

I know that there are several modules that help in parsing, but since
the syntax is very simple, I would like to avoid the use of a parser module.

I wrote a pseudo-code to better explain the structure of the process I need
to implement.

I have no clue about how to extract the block content to pass to the sub.
Please help me. Thank you.


=========== pseudo code ===========

$string='aaa {a} bbb {a} xxx {a} yyy {/a} xxx {/a} ccc {a} ddd {a} eee
{/a}';

sub process
{
    my $string = shift;
    my $extracted_content = ??? see sequence below
    # replace the extracted content in place with the following result
    return_changed_content($extracted_content);
    return $replaced_string;
}

sub return_changed_content
{
    my $content = shift;
    $content = process($content) if $content;
   # does interesting thing with content
   '<'. ++$i . $content . $i . '>';
}

print process($string);

# should print:
# 'aaa <11> bbb <2 xxx <3 yyy 3> xxx 2> ccc <44> ddd <5 eee 5>'

========== end pseudo code ==========


SEQUENCE that should be passed to "return_changed_content" sub

1: undef                    # no block defined
2: ' xxx {a} yyy {/a} xxx ' # outer block first
3: ' yyy '                  # inner block last
4: undef                    # no block defined
5: ' eee '                  # just one block

     1       2<------3<----->3------->2        4       5<----->5
aaa {a} bbb {a} xxx {a} yyy {/a} xxx {/a} ccc {a} ddd {a} eee {/a}


--
-.. --- -- .. --.. .. ---
-.. . -- .. -.-. .... . .-.. .. ...












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

Date: Wed, 9 Oct 2002 14:29:48 -0400
From: "Me" <ignore@nobody.com>
Subject: Run perl script on web server from command line
Message-Id: <ao1sis$tfr$1@moonstone.imsb.nrc.ca>

I have a perl script on a web server which can of course be executed from a
web browser.

i.e. http://www.my.server/scripts/myperl.pl

Is there any way I can execute this script from a Windows 2000 command line
instead of going through the browser ?

Thanks






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

Date: Wed, 9 Oct 2002 14:25:58 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Run perl script on web server from command line
Message-Id: <ao1vtr$21a$1@slb6.atl.mindspring.net>

"Me" <ignore@nobody.com> wrote in message
news:ao1sis$tfr$1@moonstone.imsb.nrc.ca...
> I have a perl script on a web server which can of course be executed from
a
> web browser.
>
> i.e. http://www.my.server/scripts/myperl.pl
>
> Is there any way I can execute this script from a Windows 2000 command
line
> instead of going through the browser ?

1. Download and install IndigoPerl, available free from www.indigostar.com

or

2. Download and install Activeperl, available from www.activestate.com

download link:
http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl

Bill Segraves






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

Date: Wed, 09 Oct 2002 14:49:45 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Run perl script on web server from command line
Message-Id: <3DA48859.2010408@mail.uca.edu>

Me wrote:

> I have a perl script on a web server which can of course be executed from a
> web browser.
> 
> i.e. http://www.my.server/scripts/myperl.pl
> 
> Is there any way I can execute this script from a Windows 2000 command line
> instead of going through the browser ?


If you are using CGI.pm (and you should be), you can execute it from teh 
command line simply:

C:> myperl.pl

See the CGI.pm docs for details on entering form data.

Cameron

-- 
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu



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

Date: Wed, 9 Oct 2002 15:51:44 -0400
From: "Me" <ignore@nobody.com>
Subject: Re: Run perl script on web server from command line
Message-Id: <ao21cg$bk0$1@moonstone.imsb.nrc.ca>

I already have Active Perl.  I know that I can execute a script that is
running on the local computer (i.e. perl c:\myperl.pl).  What I want to do
is execute a script that is on a remote web server.  I would normally do it
from the web browser but I want to be able to do it from a command line.

thanks


"William Alexander Segraves" <wsegrave@mindspring.com> wrote in message
news:ao1vtr$21a$1@slb6.atl.mindspring.net...
> "Me" <ignore@nobody.com> wrote in message
> news:ao1sis$tfr$1@moonstone.imsb.nrc.ca...
> > I have a perl script on a web server which can of course be executed
from
> a
> > web browser.
> >
> > i.e. http://www.my.server/scripts/myperl.pl
> >
> > Is there any way I can execute this script from a Windows 2000 command
> line
> > instead of going through the browser ?
>
> 1. Download and install IndigoPerl, available free from www.indigostar.com
>
> or
>
> 2. Download and install Activeperl, available from www.activestate.com
>
> download link:
> http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl
>
> Bill Segraves
>
>
>
>




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

Date: Wed, 9 Oct 2002 15:27:08 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Run perl script on web server from command line
Message-Id: <ao23eq$vtv$1@nntp9.atl.mindspring.net>

"Me" <ignore@nobody.com> wrote in message
news:ao1sis$tfr$1@moonstone.imsb.nrc.ca...
> I have a perl script on a web server which can of course be executed from
a
> web browser.
>
> i.e. http://www.my.server/scripts/myperl.pl
>
> Is there any way I can execute this script from a Windows 2000 command
line
> instead of going through the browser ?

Clarification:

Your question is not really a perl programming question; so it is probably
off-topic for this newsgroup.

On re-reading your question, however, if I interpret your question
literally, I see you may be trying to execute the script on the computer
that is the host of the web server. Try the following:

1. Establish a telnet session on the computer that is hosting the web
server.

2. Navigate to the directory where your scripts are stored.

3. Type "perl myperl.pl" at the command prompt of the telnet session.

In my previous response, telnet is not required, as the contemplated action
applied to execution of the script on the client computer, which requires
Perl to be installed on the client computer.

Bill Segraves




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

Date: Wed, 09 Oct 2002 14:16:57 -0700
From: swen <swen@news.com>
Subject: Re: XML::RSS bug
Message-Id: <3DA49CC9.34F04572@news.com>

thanks for the response.

kellan wrote:

> This is a long known, and very annoying feature.  If you check the bug
> reports against XML::RSS on CPAN you'll see a similiar report from 11
> months ago.
>
> My understanding is that the module's authors aren't interested in
> fixing the problem because they want to do a clean re-write when they
> get some freetime. (mythical concept that that is)
>
> I was having a similiar problem so I threw together a hacked version
> that includes some code I borrowed from Matt Sergeant to do encoding.
>
> You can download it from:
> http://protest.net/~kellan/XML-RSS-patched.tar.gz
>
> kellan
>
> swen <swen@news.com> wrote in message news:<3DA39E4D.C0DED3D8@news.com>...
> > I notice that when I parse an rss file with XML::RSS, the parser
> > converts all entity references (e.g., '&amp;') into the enitities they
> > represent (e.g. '&')within the XML::RSS object. The problem is that, if
> > I then write this XML::RSS object back to disk (via 'save()') the entity
> > reference is not restored. Instead the entity it represents is written
> > back the file. For entities like '&', it then becomes an unparseable
> > file. Is it just me or is this a bug? Or is there a way to change this
> > behavior within the module.



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

Date: Wed, 09 Oct 2002 14:44:24 -0700
From: swen <swen@news.com>
Subject: Re: XML::RSS bug
Message-Id: <3DA4A338.90CE1A8@news.com>

and thanks for the patch! it works perfectly for me.

swen wrote:

> thanks for the response.
>
> kellan wrote:
>
> > This is a long known, and very annoying feature.  If you check the bug
> > reports against XML::RSS on CPAN you'll see a similiar report from 11
> > months ago.
> >
> > My understanding is that the module's authors aren't interested in
> > fixing the problem because they want to do a clean re-write when they
> > get some freetime. (mythical concept that that is)
> >
> > I was having a similiar problem so I threw together a hacked version
> > that includes some code I borrowed from Matt Sergeant to do encoding.
> >
> > You can download it from:
> > http://protest.net/~kellan/XML-RSS-patched.tar.gz
> >
> > kellan
> >
> > swen <swen@news.com> wrote in message news:<3DA39E4D.C0DED3D8@news.com>...
> > > I notice that when I parse an rss file with XML::RSS, the parser
> > > converts all entity references (e.g., '&amp;') into the enitities they
> > > represent (e.g. '&')within the XML::RSS object. The problem is that, if
> > > I then write this XML::RSS object back to disk (via 'save()') the entity
> > > reference is not restored. Instead the entity it represents is written
> > > back the file. For entities like '&', it then becomes an unparseable
> > > file. Is it just me or is this a bug? Or is there a way to change this
> > > behavior within the module.



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

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


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