[26653] in Perl-Users-Digest
Perl-Users Digest, Issue: 8760 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 13 14:05:46 2005
Date: Tue, 13 Dec 2005 11:05:05 -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 Tue, 13 Dec 2005 Volume: 10 Number: 8760
Today's topics:
calling External Perl Script Who calls another <ashish@hotmail.com>
Re: calling External Perl Script Who calls another <Ian.Stuart@ed.ac.uk>
Re: calling External Perl Script Who calls another <ashish@hotmail.com>
Re: calling External Perl Script Who calls another <jurgenex@hotmail.com>
Re: Compile-time variable declaration (was Re: FAQ 2.11 <sdn.girths00869@zoemail.net>
Re: Compile-time variable declaration (was Re: FAQ 2.11 (Anno Siegel)
Re: LWP-problems <ronnyma@math.uio.no>
Problem with body text extraction with HTML::Parser <oohay.liam@gmail.com>
Re: Problem with body text extraction with HTML::Parser <Ian.Stuart@ed.ac.uk>
use one line Perl command to add a line at the begin of <tiw@stuwsl15.s.orthogon.com>
Re: What is the reason for Perl? <since_humans_read_this_I_am_spammed_too_much@spamyourself.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 13 Dec 2005 12:34:45 GMT
From: "Ashish" <ashish@hotmail.com>
Subject: calling External Perl Script Who calls another
Message-Id: <Fdznf.16562$Nb2.293684@news1.nokia.com>
Hi,
I have three perl Scripts A,B and C, Scripts B and C offer Option/s to
execute them,
the execution is such a way the A calls B and B calls C,
with open2 I can offer required option to B to get executed,
my question is how do I pass option so that C gets Executed
------------------------------
Date: Tue, 13 Dec 2005 12:51:16 +0000
From: Ian Stuart <Ian.Stuart@ed.ac.uk>
Subject: Re: calling External Perl Script Who calls another
Message-Id: <dnmg44$n22$1@scotsman.ed.ac.uk>
Ashish wrote:
> Hi,
> I have three perl Scripts A,B and C, Scripts B and C offer Option/s to
> execute them,
> the execution is such a way the A calls B and B calls C,
> with open2 I can offer required option to B to get executed,
> my question is how do I pass option so that C gets Executed
What determines if C is called? Is it defined by A or B?
If it's defined by A, then A needs to pass into B some flag that B can
then use to determine if C is to be called..
------------------------------
Date: Tue, 13 Dec 2005 12:55:29 GMT
From: "Ashish" <ashish@hotmail.com>
Subject: Re: calling External Perl Script Who calls another
Message-Id: <5xznf.16568$Nb2.293654@news1.nokia.com>
"Ian Stuart" <Ian.Stuart@ed.ac.uk> wrote in message
news:dnmg44$n22$1@scotsman.ed.ac.uk...
> Ashish wrote:
>> Hi,
>> I have three perl Scripts A,B and C, Scripts B and C offer Option/s to
>> execute them,
>> the execution is such a way the A calls B and B calls C,
>> with open2 I can offer required option to B to get executed,
>> my question is how do I pass option so that C gets Executed
> What determines if C is called? Is it defined by A or B?
>
> If it's defined by A, then A needs to pass into B some flag that B can
> then use to determine if C is to be called..
I missed a crucial information , that I am on win32, so probably expact
module won't help.
further, B and C scripts are not maitained by me, they are copied from a
server to local machine and executed locally,
I thought of modifying them but they keep changing
------------------------------
Date: Tue, 13 Dec 2005 15:05:37 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: calling External Perl Script Who calls another
Message-Id: <5rBnf.40340$qF6.13416@trnddc01>
Ashish wrote:
> Hi,
> I have three perl Scripts A,B and C, Scripts B and C offer Option/s
> to execute them,
> the execution is such a way the A calls B and B calls C,
> with open2 I can offer required option to B to get executed,
> my question is how do I pass option so that C gets Executed
I'm not sure if I understand your problem.
For system() as well as for backticks or exec() you can pass as many
parameters to the new script as you like.
jue
------------------------------
Date: Tue, 13 Dec 2005 06:06:37 -0600
From: "Eric J. Roode" <sdn.girths00869@zoemail.net>
Subject: Re: Compile-time variable declaration (was Re: FAQ 2.11 Perl Books)
Message-Id: <Xns972B48BB7741Fsdn.comcast@216.196.97.136>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in
news:dnm0tm$16p$1@mamenchi.zrz.TU-Berlin.DE:
> Eric J. Roode <sdn.girths00869@zoemail.net> wrote in
> comp.lang.perl.misc:
>>
>> I made that change, and it works. But it does not work with the
>> following syntax:
>>
>> use Readonly \my @names => qw(Ida Otto Erich);
>>
>> and I can't figure out why. From inside Readonly's import(),
>> everything looks fine, but back at the main program, @names is
>> undefined.
>
> The "use" statement is effectively translated to
>
> BEGIN { require Module; import Module ...; }
>
> Declarations end up inside the invisible block. Pity, isn't it?
Truly. I always thought the above BEGIN{...} block wasa a figurative one,
not a literal one.
And because import() is effectively a class method call, I can't do my gee-
whiz tricks with prototypes there either. Oh well...
--
Eric
`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(
$!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++;
$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++
;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`
------------------------------
Date: 13 Dec 2005 13:49:29 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Compile-time variable declaration (was Re: FAQ 2.11 Perl Books)
Message-Id: <dnmjh9$cv4$2@mamenchi.zrz.TU-Berlin.DE>
Eric J. Roode <sdn.girths00869@zoemail.net> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in
> news:dnm0tm$16p$1@mamenchi.zrz.TU-Berlin.DE:
>
> > Eric J. Roode <sdn.girths00869@zoemail.net> wrote in
> > comp.lang.perl.misc:
> >>
> >> I made that change, and it works. But it does not work with the
> >> following syntax:
> >>
> >> use Readonly \my @names => qw(Ida Otto Erich);
> >>
> >> and I can't figure out why. From inside Readonly's import(),
> >> everything looks fine, but back at the main program, @names is
> >> undefined.
> >
> > The "use" statement is effectively translated to
> >
> > BEGIN { require Module; import Module ...; }
> >
> > Declarations end up inside the invisible block. Pity, isn't it?
>
> Truly. I always thought the above BEGIN{...} block wasa a figurative one,
> not a literal one.
>
> And because import() is effectively a class method call, I can't do my gee-
> whiz tricks with prototypes there either. Oh well...
Yes, unfortunately. I, too, was dreaming of
use Readonly my %hash => ...;
use Readonly my $scalar => ...;
...and so on, initially.
"You can't always get what you want" (Rolling Stones)
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
Date: Tue, 13 Dec 2005 14:08:28 +0100
From: Ronny Mandal <ronnyma@math.uio.no>
Subject: Re: LWP-problems
Message-Id: <4shtp19283tbpfa5pv08e1056ovvb7fm2n@4ax.com>
On Tue, 13 Dec 2005 12:49:31 +1100, "Sisyphus"
<sisyphus1@nomail.afraid.org> wrote:
>
>"Ronny Mandal" <ronnyma@math.uio.no> wrote in message
>news:9v7sp11683qrj055magiphfo0rthsg4jgf@4ax.com...
>> Hello.
>>
>> I am running the latest ActivePerl on Win32. I utilize the LWP::Simple
>> and it's get to fetch images from the web.
>>
>> However, on UNIX, it fetches binary, but on Windows it seems like the
>> transfer is ASCII. I cannot find anything about the change of mode in
>> the doc, anyone knows?
>>
>
>Just binmode the filehandle before you write what you get() to file:
Yes! The binmode really did the trick. Just the same as when emitting
pictures from .pl
>
>use warnings;
>use strict;
>use LWP::Simple;
>
>my $url = "http://www.kalinabears.com.au/ameliagall.jpg";
>
>my $content = get($url);
>
>open(WR, ">pic.jpg") or die "Can't open file for writing: $!";
>binmode(WR);
>print WR $content;
>close(WR) or die "Can't close file after writing: $!";
>
>__END__
>
>Cheers,
>Rob
>
Thanks, Rob!
-Ronny Mandal
------------------------------
Date: Tue, 13 Dec 2005 15:29:20 +0200
From: "Perl_user" <oohay.liam@gmail.com>
Subject: Problem with body text extraction with HTML::Parser
Message-Id: <dnmifi$1eck$1@ulysses.noc.ntua.gr>
Hi,
I have been using HTML::Parser to extract the textual data from an HTML
document
I am using the following code:
my $p = HTML::Parser->new(api_version => 3,
start_h => [\&a_start_handler, "self,tagname"],
report_tags => [qw(title h1 h2 h3 h4 h5 h6)],
);
$p->parse_file($file || die) || die $!;
sub a_start_handler
{
my($self, $tag) = @_;
$self->handler(text => [], '@{dtext}' );
$self->handler(start => \&text);
$self->handler(end => \&a_end_handler, "self,tagname,text");
}
sub text
{
my($self, $tag) = @_;
my $text=@{$self->handler("text")};
}
sub a_end_handler
{
my($self, $tag) = @_;
my $text = join("", @{$self->handler("text")});
$self->handler("text", undef);
$self->handler("start", \&a_start_handler);
$self->handler("end", undef);
}
which reports the title and headers from the page. This works, but I have a
problem getting the body text (seperately), as it isn't contained inside
HTML tags, that I can report.
Web-site...
------------
<html>
<head>
<title>This is the title of the webpage.</title>
</head>
<body>
<h1>First Type Header</h1>
<h2>Second Type Header</h2>
This is the main body of the text. It will be concidered as the article.
Blah Blah blah
</body>
</html>
------------
Any ideas appreciated
Output with reported tags [title h1 h2 h3 h4 h5 h6]
--
title
This is the title of the webpage.
h1
First type
h2
Second Type Header
h3
Third Type Header
--
Output with reported tag <body>
--
This is the title of the webpage. It is a mess.
First type header
Second Type Header
Third Type Header
This is the main body of the text. It will be concidered as the article.
--
with regards,
Perlusr
------------------------------
Date: Tue, 13 Dec 2005 13:50:08 +0000
From: Ian Stuart <Ian.Stuart@ed.ac.uk>
Subject: Re: Problem with body text extraction with HTML::Parser
Message-Id: <dnmjig$nh1$1@scotsman.ed.ac.uk>
> Web-site...
> ------------
> <html>
> <head>
> <title>This is the title of the webpage.</title>
> </head>
> <body>
> <h1>First Type Header</h1>
> <h2>Second Type Header</h2>
> This is the main body of the text. It will be concidered as the article.
> Blah Blah blah
> </body>
> </html>
> ------------
Well, one problem is going to be that the main body of the text is,
technically, not in the body of a web page - if you try to validate that
page, it will complain that "This..." needs to be contained in an element.
Now, whether HTML::Parser takes any mind of this, I don't know...
------------------------------
Date: 13 Dec 2005 15:25:28 +0100
From: Ting Wang <tiw@stuwsl15.s.orthogon.com>
Subject: use one line Perl command to add a line at the begin of a file
Message-Id: <7ypso1jcpz.fsf@localhost.localdomain>
Hallo all,
I wanted to add a line (e.g #include "some.h") at the begin of all .c files
in a directory.
I try to change one .c file with one line Perl command
perl -i.org -p -e 'BEGIN{print "#include \"some.h\"\n";}'
But this doesn't work, "#include "some.h"" will be printed into STDOUT.
I did it with a 'long' Perl script:
my $f = shift;
my $fm = $f.".org";
`touch $fm`;
open F, $f or die "can not open file $f $!";
open FM, "> $fm" or die "can not open file $fm $!";
select FM;
print "#include \"some.h\"\n";
while (<F>)
{
print;
}
close F;
close FM;
`mv $fm tmp`;
`mv $f $fm`;
`mv tmp $f`;
Is there another way to do it (a one line Perl command)?
Thanks alot
Ting
------------------------------
Date: Tue, 13 Dec 2005 15:31:02 +0100
From: Erwin Moller <since_humans_read_this_I_am_spammed_too_much@spamyourself.com>
Subject: Re: What is the reason for Perl?
Message-Id: <439edb26$0$11067$e4fe514c@news.xs4all.nl>
robic0 wrote:
> Explain to me if you can why Perl is something I should use in
> replacement to say C++ and a native API....
> I say "if you can" because I'm interrested in your bullshit.
> After 2 years newbie Perl (forced on me). I know the breadth
> of it and the power boils down to package interfaced dll's
> to the os by an extroidnary amount of contributors who don't
> know when to hold off publishing, in lieu of the misguided
> fame (and down in flames) it is thought (in their heads) to
> bring.
>
> C++ and native API, without complex workarounds (for
> Perl language shortcomings the modules exhibit) is
> about a thousand percent more reliable and faster.
>
> Why should anybody invest time in a guessing game such
> as Perl. Not Perl per-say, but modules that leave you
> very short in the bottom line?
>
> Let the bullshit begin .........->
Hi,
(Just dropping in here)
Well, next time try asking more nicely. :-)
I quited Perl some years ago.
Why?
Because it was not 'my language', I had trouble expressing what I ment.
To me Perl looks often as garbled nonsense, not unlike my english.
But it isn't garbled nonsense of course.
Bottomline is: You are probably as stupid as I am, and do not have the
brains to read/write Perl as a natural language.
I switched to Java and PHP.
Both are very powerfull and can get the same job done as Perl can, be it in
a way I understand.
So why don't you stick Perl up yours and go coding C++, if that is what you
are good at?
What is your problem, man?
Are you frustrated you cannot code Perl well?
Don't be. Just stick to the languages you are comfortable with.
Oh well...
[back to PHP]
Regards,
Erwin Moller
------------------------------
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 8760
***************************************