[24094] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6288 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 22 06:05:55 2004

Date: Mon, 22 Mar 2004 03:05:08 -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           Mon, 22 Mar 2004     Volume: 10 Number: 6288

Today's topics:
    Re: Deleting a folder recursively <Joe.Smith@inwap.com>
    Re: FIFO problem - yet another .sig rot script... (Anno Siegel)
        Getting exit code when reading from a pipe (Ittay Dror)
    Re: Getting exit code when reading from a pipe (Anno Siegel)
    Re: graph smoothing... <bill@gites.org.uk>
        How to determine the path of a module? <Guru03@despammed.com>
        perl module for file downloading? <die@spammers.die>
    Re: perl module for file downloading? <nospam@bigpond.com>
    Re: perl module for file downloading? <jwillmore@remove.adelphia.net>
    Re: perl module for file downloading? <die@spammers.die>
    Re: Perl script to transfer file via https (Bryan Castillo)
    Re: Redirect problem <gnari@simnet.is>
    Re: scope again <mail@annuna.com>
    Re: scope again <mail@annuna.com>
    Re: scope again <mail@annuna.com>
    Re: scope again <tassilo.parseval@rwth-aachen.de>
    Re: scope again <mail@annuna.com>
        simple text matching problem <gned@telsmonopolytradotcom.remove.monopoly)>
    Re: simple text matching problem (Sam Holden)
    Re: simple text matching problem <depesz@depesz.pl>
    Re: simple text matching problem <gned@telsmonopolytradotcom.remove.monopoly)>
        using a variable as STDIN for an external program <gned@telsmonopolytradotcom.remove.monopoly)>
    Re: using a variable as STDIN for an external program (Anno Siegel)
    Re: using a variable as STDIN for an external program <gned@telsmonopolytradotcom.remove.monopoly)>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 22 Mar 2004 09:53:25 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Deleting a folder recursively
Message-Id: <pIy7c.57354$_w.909854@attbi_s53>

Darin McBride wrote:

>     if ( -f $d or -l $d )
>     {
>         unlink $d;
>         return;
>     }

That does not cover all the possibilities.

    if ( -f $d or -l _ or -b _ or -c _ or -p _ or -S _) { ... }
or
    unless (-d $_) { ...}

>         if ( -l $sd ) { push(@sfiles, $sd);}
>         elsif ( -d $sd ) { push(@sdirs, $sd); }
>         else { push(@sfiles, $sd); }

    if ( -d $sd ) { push @sdirs,$sd  }
    else          { push @sfiles,$sd }

>     # process subdirectories via fork

Yuck.  The rate of file deletion and directory deletion is
limited by disk I/O.  Using more processes won't make it
faster.  What sort of benchmarks did you do?

	-Joe


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

Date: 22 Mar 2004 09:49:18 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: FIFO problem - yet another .sig rot script...
Message-Id: <c3mcqu$an7$1@mamenchi.zrz.TU-Berlin.DE>

Michele Dondi  <bik.mido@tiscalinet.it> wrote in comp.lang.perl.misc:
> On Thu, 18 Mar 2004 23:17:29 +0100, Michele Dondi
> <bik.mido@tiscalinet.it> wrote:

[...]

> BTW: any ideas on my actual problem?!? I googled around for 'pine
> signature fifo' and it seems to return a bunch of relevant hits, but
> at home I both have a limited bandwidth and I still pay a hourly rate
> for my Internet connection, so I'll defer a more extensive search to
> next week...

I believe your error is that you recreate the fifo each time around
the loop.  That may irritate pine more than the fact it is a fifo.

The following skeleton script works with my pine as intended:

    my $pipe = "$ENV{ HOME}/.signature";
    system( '/usr/bin/mkfifo', $pipe) unless -p $pipe;
    die "no pipe '$pipe': $!" unless -p $pipe;

    my @quotes = <DATA>;
    while ( 1 ) {
        open my $p, '>', $pipe or die "Can't open '$pipe': $!";
        my $quote = $quotes[ rand @quotes];
        print $p $quote;
        close $p;
        select( undef, undef, undef, 0.2); # give client time to close
    }

    __DATA__
    spruch 1
    spruch 2
    spruch 3

Anno
-- 
spruch 1


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

Date: 21 Mar 2004 22:34:08 -0800
From: notreal@mailinator.com (Ittay Dror)
Subject: Getting exit code when reading from a pipe
Message-Id: <10ac1b34.0403212234.2280078c@posting.google.com>

Hi,

I'm reading a command output via a pipe like:

open (LS, "ls|") or die "ls could not be run";

while (<LS>) {
   ...
}

close (LS);

now, what happens if 'ls' (or any other command of course) runs but
fails? How can I check its exit code in my perl program?

Thank you,
Ittay


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

Date: 22 Mar 2004 08:13:17 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Getting exit code when reading from a pipe
Message-Id: <c3m76t$70t$1@mamenchi.zrz.TU-Berlin.DE>

Ittay Dror <notreal@mailinator.com> wrote in comp.lang.perl.misc:
> Hi,
> 
> I'm reading a command output via a pipe like:
> 
> open (LS, "ls|") or die "ls could not be run";
> 
> while (<LS>) {
>    ...
> }
> 
> close (LS);
> 
> now, what happens if 'ls' (or any other command of course) runs but
> fails? How can I check its exit code in my perl program?

perldoc -f close

Anno


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

Date: Mon, 22 Mar 2004 09:18:54 +0100
From: "Bill Parker" <bill@gites.org.uk>
Subject: Re: graph smoothing...
Message-Id: <c3m7hg$9m7$1@news-reader4.wanadoo.fr>

It sounds like "Moving Average" gives me the best representation for want I

want.

Many thanks for refreshing my oh-so-rusty memory (and for pointing me to a

package)

Cheers

Bill

"




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

Date: Mon, 22 Mar 2004 10:56:02 +0000 (UTC)
From: Guru03 <Guru03@despammed.com>
Subject: How to determine the path of a module?
Message-Id: <Xns94B4798987435Guru03despammedcom@193.43.96.1>

Hi, I need to know the path of a PERL module inside a Perl program.
i.e. I want to know the location of 'date.pm'.

What's the easiest way to do it?

Thanks


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

Date: Mon, 22 Mar 2004 17:58:26 +0900
From: "Stijn De Saeger" <die@spammers.die>
Subject: perl module for file downloading?
Message-Id: <c3maq6$4po$1@jaist-news.jaist.ac.jp>

hi all,

a quick question, is there some generic way (module ?) to do simple file
downloads to disk from within a perl script?
something that behaves like '$download_mgr->download($remote_file,
$location_on_disk);' or the like. Just curious whether there is such a
thing, or if not what would be the way to go ?
thank you.
s.




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

Date: Mon, 22 Mar 2004 19:41:13 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: perl module for file downloading?
Message-Id: <8643030.fnPffPink3@GMT-hosting-and-pickle-farming>

Stijn De Saeger wrote:

> hi all,
> 
> a quick question, is there some generic way (module ?) to do simple file
> downloads to disk from within a perl script?
> something that behaves like '$download_mgr->download($remote_file,
> $location_on_disk);' or the like. Just curious whether there is such a
> thing, or if not what would be the way to go ?
> thank you.
> s.

You could try wget (available on most linux/unix systems)
http://www.gnu.org/software/wget/wget.html

It works with http/ftp & is trivial to use.

gtoomey


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

Date: Mon, 22 Mar 2004 04:54:28 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: perl module for file downloading?
Message-Id: <pan.2004.03.22.09.54.24.991833@remove.adelphia.net>

On Mon, 22 Mar 2004 17:58:26 +0900, Stijn De Saeger wrote:

> hi all,
> 
> a quick question, is there some generic way (module ?) to do simple file
> downloads to disk from within a perl script?
> something that behaves like '$download_mgr->download($remote_file,
> $location_on_disk);' or the like. Just curious whether there is such a
> thing, or if not what would be the way to go ?
> thank you.
> s.

Yes.  The LWP module.

`perldoc lwpcook` for ways to do this.

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 ...
"The more data I punch in this card, the lighter it becomes, and 
the lower the mailing cost."   -- Stan Kelly-Bootle, "The Devil's
DP Dictionary" 


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

Date: Mon, 22 Mar 2004 19:13:39 +0900
From: "Stijn De Saeger" <die@spammers.die>
Subject: Re: perl module for file downloading?
Message-Id: <c3mf77$6pa$1@jaist-news.jaist.ac.jp>

thanks a lot... I thought the LWP module only did html processing.
cheers,
s.

"James Willmore" <jwillmore@remove.adelphia.net> wrote in message
news:pan.2004.03.22.09.54.24.991833@remove.adelphia.net...
> On Mon, 22 Mar 2004 17:58:26 +0900, Stijn De Saeger wrote:
>
> > hi all,
> >
> > a quick question, is there some generic way (module ?) to do simple file
> > downloads to disk from within a perl script?
> > something that behaves like '$download_mgr->download($remote_file,
> > $location_on_disk);' or the like. Just curious whether there is such a
> > thing, or if not what would be the way to go ?
> > thank you.
> > s.
>
> Yes.  The LWP module.
>
> `perldoc lwpcook` for ways to do this.
>
> 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 ...
> "The more data I punch in this card, the lighter it becomes, and
> the lower the mailing cost."   -- Stan Kelly-Bootle, "The Devil's
> DP Dictionary"




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

Date: 21 Mar 2004 22:36:18 -0800
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Perl script to transfer file via https
Message-Id: <1bff1830.0403212236.3cec0333@posting.google.com>

James Willmore <jwillmore@remove.adelphia.net> wrote in message news:<pan.2004.03.18.15.17.47.606774@remove.adelphia.net>...
> On Wed, 17 Mar 2004 23:47:58 -0800, c0rum_z wrote:
> 
> > I'm just very new to perl and I would like to transfer file from a
> > unix machine to a web server with a servlet that could accept file
> > 
> > Is there any available script that I could use?
> 
> Probably.  Did you exhaust your searches yet ... there's a lot of places
> to look :-)  Or, you could write your own :-)
> 

If you do want to write your own, check out the modules LWP and
HTTP::Request::Common.  In the 2nd module you will find a section in
the documentation about multipart/form-data; read that.

I don't think it should be to hard to write a script to upload a file,
using these modules.  (never tried it though......)

> 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 ...
> Ask five economists and you'll get five different explanations
> (six if one went to Harvard).   -- Edgar R. Fiedler


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

Date: Mon, 22 Mar 2004 08:22:13 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Redirect problem
Message-Id: <c3m7lc$l9a$1@news.simnet.is>

"Tigerhillside" <Tigerhillsideremove@removenetscape.net> wrote in message
news:sres50l63vavrlgop5lj7v3qmq2ugqmec7@4ax.com...
> In comp.lang.perl.misc, "gnari" <gnari@simnet.is>, I read and
> responded
>
> >"Tigerhillside" <Tigerhillsideremove@removenetscape.net> wrote in message
> >news:u17r50lmhcbp7s99l65rn6rnnhif885r7s@4ax.com...
> >
> >[problem with redirect]
>
> I meant https rather than http.
>
> > but your
> >  'But I am redirecting inside the server'
> >comment suggests to me that you do not realize what  the redirect
> >does. it send back instructions to the browser with a new url to
> >try, so there is no such thing as redirecting inside the server
> >with this method.
> >
>
> I am directing the use from page A to page B. I think that is a
> reasonable use of redirect. I could explain the whole system, but
> it is irrelevant to the problem. It is quite a bit easier for me
> if I can do this than if not.

my point is that if the 'secure' server does not accept plain http
requests to to destination url, then the redirect will not work
either, as the redirect is external

gnari





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

Date: Mon, 22 Mar 2004 06:48:53 GMT
From: Joe <mail@annuna.com>
Subject: Re: scope again
Message-Id: <p%v7c.33065$%06.26851@newsread2.news.pas.earthlink.net>



Bob Walton wrote:
> Joe wrote:
> 
>> This class still will not work.  I have stripped the class down to the 
>> basics.  I know about the style issue so this is basically bare bones.
>> package Space;
>>
>>
>> #spaces of the grid
>>
>> sub new{
>> my $space = {
>>     loc  =>   $_[0],
>>     char =>   0
>>         };
>>
>> bless $space, 'Space';
>>
>> print $space->{loc};    <-- prints here.
>> return $space;
>> }
>>
>> sub fchsym{ #returns the symbol for map printing.
>>
>> print "k";               <-prints this so I know that it gets accessed.
>> print "$space->{loc}";  < -won't print these data mbembers.  Dosn't print anything.
> 
> 
> --------^-------------^
> Inside quotes, the variable $space will be interpolated.  If $space 
> contains the string "Pluto", you would get:
> 
>     Pluto->{loc}
> 
> printed.  Interpolation does not evaluate operators.  This is different 
> than the code in your first post, which did not contain this particular 
> error.  Have you been copy/pasting your code, or retyping it in your 
> posts?  Please *please* copy/paste it.
> 

I don't get an error, I get no outout.  Once I can get some output, I 
can print the output in the GUI.  I have tried warnings and get nothing. 
  I will
> 
>> print "$space->{char}";
> 
> 
> --------^--------------^
> same thing
> 
> 
>> return $space->{loc};
>> }
>>
> ...
> 
> 
> Well, other than the above, I'll bet it's something in the way you're 
> calling your module.  Here is a complete example that should work if 
> copy/paste/executed (and note:  please pay attention to what the various 
> replys in your previous thread said about OO-programming in Perl -- they 
> were right on -- this code is your code almost verbatim, and is *not* 
> necessarily How It Should Be Done [all one file]:
> 
> use warnings;
> use strict;
> my $s=new Space('location');
> print "main program...\n";
> print Space::fchsym();
> 
> package Space;
> 
> my $space;
> 
> #spaces of the grid
> 
> sub new{
>  $space = {
>     loc  =>   $_[1],
>     char =>   0
> 
>     };
> 
> print $space->{loc};
> bless $space, 'Space';
> return $space;
> }
> 
> sub fchsym{ #returns the symbol for map printing.
> 
> print $space->{loc};
> return $space->{loc};
> }
> 1;
> 
> 
> When run, that should print:
> 
> D:\junk>perl junk440.pl
> locationmain program...
> locationlocation
> D:\junk>
> 
> The first 'location' was from the new method; the second was from sub 
> fchsym, and the third was from the print in package main.
> 
> Does this give you these same results when copy/paste/executed?  If so, 
> you have a starting point for figuring out what is going wrong.

I realy don't care about it printing.  Most of what I am posting is 
debugging flags.  All I want to know is why a variable in a pacahge 
won't transfer from one sub to another in the sam package there is what 
the C++ code looks like and what I am trying to do is return a character 
for a map.


  This Object is the spaces of the
  map.  This holds all the things
  on the map.  */

  class space{
  int mony;       /* Hold money */
  char loc;       /* The Map char */
  char monchr;    /* Symbol for money */
  char psym;      /* The symbol for the player. */
  bool sflag;     /* Has the space been mapped?
                     Used for drawing the map */
  vector<prize> przs; /* Holds Prizes on the map */


char space::rchr(){
    sflag = true;
    if (psym != '/'){return psym;}
    if (przs.size() > 0){return przs[0].gsymbol(); }
    if (mony > 0){return monchr;}
    return loc;
    }





$space->{loc} is a simple character. containing a H or . I have tried it 
with and without quotes.

I will try your advice.  I am pretty good with perl and have been 
working with C++.  I have a working version of my game it is a simple 
role playing game.  I am currently trying to do an update using my 
spaces as objects instead of a grid of characters.  I am working in perl 
becuase I can understand TK I have no clue on how to do GUIs with C++. 
I have seen GUI pages with C++ but I can't find any good books on doing 
GUIs with C++.  I don't have my game that I am working on posted because 
I can't get this simple object to work.

my programs are posted at www.annuna.com/perl5

I can do the grid of objects in C++ and the GUI in perl.  I realy 
thought this would be pretty easy, perl is much esaier than C++ but 
programming is programming.



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

Date: Mon, 22 Mar 2004 07:00:25 GMT
From: Joe <mail@annuna.com>
Subject: Re: scope again
Message-Id: <daw7c.33073$%06.21244@newsread2.news.pas.earthlink.net>



John W. Krahn wrote:
> Bob Walton wrote:
> 
>>Joe wrote:
>>
>>>This class still will not work.  I have stripped the class down to the
>>>basics.  I know about the style issue so this is basically bare bones.
>>>package Space;
>>>
>>>#spaces of the grid
>>>
>>>sub new{
>>>my $space = {
>>>    loc  =>   $_[0],
>>>    char =>   0
>>>
>>>    };
>>>
>>>bless $space, 'Space';
>>>
>>>print $space->{loc};    <-- prints here.
>>>return $space;
>>>}
>>>
>>>sub fchsym{ #returns the symbol for map printing.
>>>
>>>print "k";               <-prints this so I know that it gets accessed.
>>>print "$space->{loc}";  < -won't print these data mbembers.
>>
>>--------^-------------^
>>Inside quotes, the variable $space will be interpolated.  If $space
>>contains the string "Pluto", you would get:
>>
>>     Pluto->{loc}
>>
>>printed.  Interpolation does not evaluate operators.
> 
> 
> Are you sure about that Bob?  It's very easy to test:
> 
> $ perl -le'my $space = q(Pluto); print "$space->{loc}";'
> 
> $ perl -le'my $space = { loc => 888 }; print "$space->{loc}";'
> 888
> 
> 
> 
> John

All I want to know is why $space dosn't act global in the Space package. 
   It seems like this object sould be simple.  This glitch is holding up 
my whole program.  See ny other responce, This will work easily in C++ 
but perl dosn't want to cooperate with me.  I wish I had a masters in 
computer programming or at least a degree.  I get so hung up on the 
simple tequiques of programming.

You can see my work at www.annuna.com/perl5

I have a working version of this program in perl and C++.  C++ pennis 
and prizes source, space.  I am trying to replicate my C++ code in perl.

I realy want to resolve this issue to get to my program.

I do apoligise for my terceness but I am having a few beers making this 
responce.  I do intend to wait another day to take any advice I read.

Thank you.
Joe Creaney
wannabe programmer. :)



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

Date: Mon, 22 Mar 2004 07:26:03 GMT
From: Joe <mail@annuna.com>
Subject: Re: scope again
Message-Id: <fyw7c.33090$%06.13275@newsread2.news.pas.earthlink.net>



Bob Walton wrote:
> Joe wrote:
> 
>> This class still will not work.  I have stripped the class down to the 
>> basics.  I know about the style issue so this is basically bare bones.
>> package Space;
>>
>>
>> #spaces of the grid
>>
>> sub new{
>> my $space = {
>>     loc  =>   $_[0],
>>     char =>   0
>>         };
>>
>> bless $space, 'Space';
>>
>> print $space->{loc};    <-- prints here.
>> return $space;
>> }
>>
>> sub fchsym{ #returns the symbol for map printing.
>>
>> print "k";               <-prints this so I know that it gets accessed.
>> print "$space->{loc}";  < -won't print these data mbembers.
> 
> 
> --------^-------------^
> Inside quotes, the variable $space will be interpolated.  If $space 
> contains the string "Pluto", you would get:
> 
>     Pluto->{loc}
> 
> printed.  Interpolation does not evaluate operators.  This is different 
> than the code in your first post, which did not contain this particular 
> error.  Have you been copy/pasting your code, or retyping it in your 
> posts?  Please *please* copy/paste it.
> 
> 
>> print "$space->{char}";
> 
> 
> --------^--------------^
> same thing
> 
> 
>> return $space->{loc};
>> }
>>
> ...
> 
> 
> Well, other than the above, I'll bet it's something in the way you're 
> calling your module.  Here is a complete example that should work if 
> copy/paste/executed (and note:  please pay attention to what the various 
> replys in your previous thread said about OO-programming in Perl -- they 
> were right on -- this code is your code almost verbatim, and is *not* 
> necessarily How It Should Be Done [all one file]:
> 
> use warnings;
> use strict;
> my $s=new Space('location');
> print "main program...\n";
> print Space::fchsym();
> 
> package Space;
> 
> my $space;
> 
> #spaces of the grid
> 
> sub new{
>  $space = {
>     loc  =>   $_[1],
>     char =>   0
> 
>     };
> 
> print $space->{loc};
> bless $space, 'Space';
> return $space;
> }
> 
> sub fchsym{ #returns the symbol for map printing.
> 
> print $space->{loc};
> return $space->{loc};
> }
> 1;
> 
> 
> When run, that should print:
> 
> D:\junk>perl junk440.pl
> locationmain program...
> locationlocation
> D:\junk>
> 
> The first 'location' was from the new method; the second was from sub 
> fchsym, and the third was from the print in package main.
> 
> Does this give you these same results when copy/paste/executed?  If so, 
> you have a starting point for figuring out what is going wrong.

I have been playing with other parts of my program and I can't seem to 
ger golbal variables in my functions.  Is it my version of perl?



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

Date: 22 Mar 2004 07:33:05 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: scope again
Message-Id: <c3m4rh$ftm$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Joe:

> This class still will not work.  I have stripped the class down to the 
> basics.  I know about the style issue so this is basically bare bones.
> package Space;
> 
> 
> #spaces of the grid
> 
> sub new{
> my $space = {
> 	loc  =>   $_[0],
> 	char =>   0
> 	
> 	};
> 
> bless $space, 'Space';
> 
> print $space->{loc};    <-- prints here.
> return $space;
> }

Here you have a variable '$space' that is lexical to the surrounding
method 'new'. That means, you cannot access it from outside this
function (a function has its own scope).

How do you call 'new' anyway? If 'new' is to serve as a constructor, it
is probably wrong as constructors are usually called as class-methods,
as in:

    my $obj = Space->new(@args);

In this case, $_[0] inside 'new' holds the package name 'Space'. The
actual arguments you passed to it are to be found in @_[1..$#_].

> sub fchsym{ #returns the symbol for map printing.
> 
> print "k";               <-prints this so I know that it gets accessed.
> print "$space->{loc}";  < -won't print these data mbembers.
> print "$space->{char}";
> return $space->{loc};
> }

What is '$space'? It is definitely not the same variable as above.
Provided that 'fchsym' is an instance method, the object is in $_[0].

> These are very basic object oriented concepts.  I am getting very 
> fustrated.  I am using this version of per with suzi lynx.

Maybe you'd like to read through perlboot.pod and/or perltoot.pod again
to get a few things straight.

What I think you meant to write is this:

    package Space;

    use strict;
    use warnings;

    sub new {
	my ($class, $loc) = @_;
	return bless {
	    loc	 => $loc,
	    char => 0,
	} => $class;
    }

    sub fchsym {
	my $self = shift;
	print $self->{loc};
	print $self->{char};
    }

    package main;

    my $obj = Space->new(1);
    $obj->fchsym;

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: Mon, 22 Mar 2004 08:32:42 GMT
From: Joe <mail@annuna.com>
Subject: Re: scope again
Message-Id: <Kwx7c.33116$%06.3706@newsread2.news.pas.earthlink.net>


I think I found the problem, my object if fine but I have a scope 
problem in another part of my program.

my $player = Player::generate();

$dirf->Button(-text=>"NW",-command => \&gonw);

MainLoop;

sub gonw{$mapp->move('nw', $player)};  <- $player out of scope?


Seems to be a TK problem.  Have posted tot he approate group.  Still any 
suggestions?



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

Date: Mon, 22 Mar 2004 17:07:52 +1100
From: "C3" <gned@telsmonopolytradotcom.remove.monopoly)>
Subject: simple text matching problem
Message-Id: <405e8257$0$3952$afc38c87@news.optusnet.com.au>

Assume I have the following variable:

my $text = 'blah blah (asdfasdf):
<br>
<code>
dfgasdfghsfdg<br>
sadfgsdfgsdfgsdfg<br>
sdfgsdfgsfdgsdfg<br>
</code>
</p>
<p align=center>
<b>';

I want to extract everything between the code tags except for the <br> tags.
I have no problem removing the newlines and <br> tags, but I can't work out
how to select only the text between the code tags. Here is what I've tried:

my $text =~ m!<code>(.*)</code>!;

This doesn't seem to do anything. Can anyone give me a hand with this?

cheers,

C3




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

Date: 22 Mar 2004 06:15:39 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: simple text matching problem
Message-Id: <slrnc5t14b.g5n.sholden@flexal.cs.usyd.edu.au>

On Mon, 22 Mar 2004 17:07:52 +1100, C3 <> wrote:
> Assume I have the following variable:
> 
> my $text = 'blah blah (asdfasdf):
><br>
><code>
> dfgasdfghsfdg<br>
> sadfgsdfgsdfgsdfg<br>
> sdfgsdfgsfdgsdfg<br>
></code>
></p>
><p align=center>
><b>';
> 
> I want to extract everything between the code tags except for the <br> tags.
> I have no problem removing the newlines and <br> tags, but I can't work out
> how to select only the text between the code tags. Here is what I've tried:
> 
> my $text =~ m!<code>(.*)</code>!;

Read the documentation that comes with perl on regular expressions.

perldoc perlre

See what it says . matches. Notice that the character that . does not match
is in your example, and hence it doesn't match.

See also the modifiers that can be applied to a regular expression,
particularly the one that modifies what . matches.

If your input has multiple <code>...</code> elements then you will need
to do some more work to match the correct ones. If they can not nest
then you might get away with just doing a non-greedy *. Again, see the
documentation for how to do that.

Have you thought of seeing if one of the HTML parsers on CPAN will
handle the data (the closing </p> tag with no matching opening <p>
might cause problems - but HTML in practice is almost always ill formed
so some of the parsers might DWIM)?

-- 
Sam Holden


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

Date: Mon, 22 Mar 2004 07:31:06 +0100
From: hubert depesz lubaczewski <depesz@depesz.pl>
Subject: Re: simple text matching problem
Message-Id: <slrn.pl.c5t219.rp7.depesz@master.hq.eo.pl>

C3 wyrze¼bi³(a):
> my $text = 'blah blah (asdfasdf):
<snip>
> <b>';
> my $text =~ m!<code>(.*)</code>!;

1st. omit second "my".
2nd. after regexp, do:
	my $code = $1;

and then print $code;

depesz

-- 
*-----------------------------------------------------------------*
 czaderskie dywaniki do ³azienki lub przed ³ó¿ko:
           http://www.allegro.pl/show_user_auctions.php?uid=118670


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

Date: Mon, 22 Mar 2004 18:12:33 +1100
From: "C3" <gned@telsmonopolytradotcom.remove.monopoly)>
Subject: Re: simple text matching problem
Message-Id: <405e9180$0$3954$afc38c87@news.optusnet.com.au>

I also had to put an 's' after the regexp. Now it works.

cheers,

C3




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

Date: Mon, 22 Mar 2004 21:28:20 +1100
From: "C3" <gned@telsmonopolytradotcom.remove.monopoly)>
Subject: using a variable as STDIN for an external program
Message-Id: <405ebf62$0$8359$afc38c87@news.optusnet.com.au>

I'd like to call an external program through perl, but I need to redirect a
variable in my perl program, to STDIN of the external program. I also need
to read the output of the external program (one line only).

Can someone please point me in the right direction? I've been googling for a
while now, and I'm still not sure whether I can do a simple redirection
(with interpolation) or whether I have to set up a pipe.

cheers,

C3





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

Date: 22 Mar 2004 10:41:44 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: using a variable as STDIN for an external program
Message-Id: <c3mft8$csk$1@mamenchi.zrz.TU-Berlin.DE>

C3 <gned@telsmonopolytradotcom.remove.monopoly)> wrote in comp.lang.perl.misc:
> I'd like to call an external program through perl, but I need to redirect a
> variable in my perl program, to STDIN of the external program. I also need
> to read the output of the external program (one line only).

The one-off solution (assuming Unix) is

    my $ans = `echo $var | /path/to/external/prog`;

A portable full-fledged solution is in IPC::Open2.

Anno
-- 
spruch 1


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

Date: Mon, 22 Mar 2004 22:02:36 +1100
From: "C3" <gned@telsmonopolytradotcom.remove.monopoly)>
Subject: Re: using a variable as STDIN for an external program
Message-Id: <405ec76a$0$8359$afc38c87@news.optusnet.com.au>

Yup, I'm using perl under Unix, but what you mentioned doesn't work.

Just for the record, when I try the same command (with some valid data) in a
shell, it works fine.

Is there anything else I could try? Or do I have to take the plunge and
learn how to use open2/3?

cheers,

C3




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

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


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