[23030] in Perl-Users-Digest
Perl-Users Digest, Issue: 5250 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 21 14:06:22 2003
Date: Mon, 21 Jul 2003 11:05:10 -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 Mon, 21 Jul 2003 Volume: 10 Number: 5250
Today's topics:
Any advice on how to fix this? <bbowler@bigelow.org>
Re: Any advice on how to fix this? <ubl@schaffhausen.de>
Re: File::Find is slower than using recursion!? <stevea@wrq.com>
Re: JOIN problem ? (2nd attempt to post) (Tad McClellan)
Re: JOIN problem ? (2nd attempt to post) (Tad McClellan)
Limit the types of extension that can be uploaded <his_ron@yahoo.com>
Re: Limit the types of extension that can be uploaded <jurgenex@hotmail.com>
Re: Matching URls (JR)
Newbie - skipping lines of a file. <cvidal@att.com>
Re: Newbie - skipping lines of a file. (Tad McClellan)
Re: Newbie - skipping lines of a file. <nobull@mail.com>
One Off Script (JP Ogden)
Re: One Off Script <emschwar@pobox.com>
Open2 call hangs <admin@asarian-host.net>
Re: Open2 call hangs <abigail@abigail.nl>
oriented object programming <franck@noSpam.fr>
Re: oriented object programming <pinyaj@rpi.edu>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 21 Jul 2003 09:47:43 -0400
From: Bruce Bowler <bbowler@bigelow.org>
Subject: Any advice on how to fix this?
Message-Id: <pan.2003.07.21.13.47.38.245402@bigelow.org>
I'll start by saying I'm NOT a perl programmer and I'm not sure this is
the right group, but I'm sure you'll tell me where to go if it's not :-)
I have a perl script that I didn't write that works with perl 5.005_03
(solaris 2.7). It doesn't even compile with 5.8.0 (Redhat 8.0).
The error message from the compiler is
Can't modify reference constructor in list assignment at ./f77toM.pl line 465, near ");"
Execution of ./f77toM.pl aborted due to compilation errors.
The code in question is
for ( $ifmt=0;$ifmt<=$#fmt_array;$ifmt++ ) {
($space_str,$nchars,$imat,\@fmt_matlab,\@fmt_matvar) =
parse_write_fmt($space_str,$nchars,$ifmt,$imat,\@fmt_array,\@fmt_matlab,\@fmt_matvar,\@fmtstr,\@var_type);
} # end for on ifmt
where line 465 is the "parse_write_fmt" line.
The entire script is almost 3K lines long so I wont post it, but if you
want to examine the whole thing, it can be found at
ftp://ftp.math.umn.edu/pub/MCIM/f77toM.pl.gz
TIA,
Bruce
--
+-------------------+---------------------------------------------------+
Bruce Bowler | The most dangerous thing in the world is to leap a
1.207.633.9600 | chasm in two jumps. - David Lloyd George
bbowler@bigelow.org |
+-------------------+---------------------------------------------------+
------------------------------
Date: Mon, 21 Jul 2003 16:09:49 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Any advice on how to fix this?
Message-Id: <bfgvbd$d87$1@news.dtag.de>
Bruce Bowler wrote:
> I'll start by saying I'm NOT a perl programmer and I'm not sure this is
> the right group, but I'm sure you'll tell me where to go if it's not :-)
>
> I have a perl script that I didn't write that works with perl 5.005_03
> (solaris 2.7). It doesn't even compile with 5.8.0 (Redhat 8.0).
>
> The error message from the compiler is
>
> Can't modify reference constructor in list assignment at ./f77toM.pl line 465, near ");"
> Execution of ./f77toM.pl aborted due to compilation errors.
>
> The code in question is
>
> for ( $ifmt=0;$ifmt<=$#fmt_array;$ifmt++ ) {
>
> ($space_str,$nchars,$imat,\@fmt_matlab,\@fmt_matvar) =
^^ ^^
This certainly doesnt do anything useful. The compile time error is the
right thing.
Try this:
($space_str,$nchars,$imat,$fmt_matlab,$fmt_matvar) = parse....
@fmt_matlab = @$fmt_matlab;
@$fmt_matvar = @$fmt_matvar;
Bye
malte
------------------------------
Date: Mon, 21 Jul 2003 17:51:19 GMT
From: Steve Allan <stevea@wrq.com>
Subject: Re: File::Find is slower than using recursion!?
Message-Id: <u3cgz22g9.fsf@wrq.com>
It appears symlinks are the main issue here.
Sam correctly pointed out that the recursive version didn't address
symlinks. That turned out to be more significant than I initially
realized (being on a windows box). I tried benchmarking this version
from Ben:
>Benjamin Goldberg <ben.goldberg@hotpop.com> writes:
>Steve Allan wrote:
>[snip]
>
>You could go even faster, if you used neither recursion nor File::Find.
>
> sub get_files {
> my (@dirs, @flist) = ".";
> while( my $dir = pop @dirs ) {
> opendir( my $dh, $dir ) or die "opendir($dir): $!";
> for my $f (readdir $dh) {
> next if $f eq "." or $f eq "..";
> $f = "$dir/$f";
> push @dirs, $f if !-l $f and -d _;
> push @flist, $f if -f $f;
> }
> }
> print "In GetFiles: found ", scalar @flist, " files\n";
> }
>
and recursion was still much faster. Then I modified the recursive
function to check for symlinks, namely I changed
if ( chdir $fileToCheck ) { .. }
to
if ( not -l $fileToCheck and -d $fileToCheck ) {
chdir $fileToCheck or die "Can't cd to $fileToCheck: $! ";
...
and with that one change, the recursive version is the slowest. Here
are the benchmarks for all three:
s/iter Recursion File::Find Get_Files
Recursion 9.13 -- -23% -31%
File::Find 7.05 30% -- -10%
Get_Files 6.34 44% 11% --
It would seem that, on windows at least, just checking for a symlink
is expensive. Is this because a Perl script running on windows still
has to be able to recognize symlinks on samba-mounted file systems
that support symlinks?
Whatever the reason, the above numbers seem much more in line with my
expectations.
Thanks for all the feedback. This has been very educational for me.
--
-- Steve
------------------------------
Date: Mon, 21 Jul 2003 09:17:23 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: JOIN problem ? (2nd attempt to post)
Message-Id: <slrnbhntfj.dk8.tadmc@magna.augustmail.com>
Abigail <abigail@abigail.nl> wrote:
> Sam Holden (sholden@flexal.cs.usyd.edu.au) wrote on MMMDCX September
> MCMXCIII in <URL:news:slrnbhjtoq.rop.sholden@flexal.cs.usyd.edu.au>:
>:) On 19 Jul 2003 18:40:43 -0700, stu7 <stuseven@hotmail.com> wrote:
>:) > *** No thanks to you Eric...
>:) > *** your post had
>:) > *** virtually nothing to do with my questions
First, there is no requirement that followups address any
question that was asked. This is a _discussion_ newsgroup.
People post things, and we discuss them.
Sometimes the discussion leads to an answer to a question.
Sometimes is doesn't.
Second, there was no technical value in Eric's followup, but
there was a great deal of _social_ value in it.
The answer to your question was a short-term transient thing,
it a few minutes/hours/days it has been solved.
The topic of Eric's subthread was long-term, it would have
served you well even years from now.
>:) > *** to your "style whine"_ value of your spam is ? (right... nothing).
The value was that, if you had followed netiquette, you could
have avoided that very last entry below...
>:) [snip a post that breaks almost all the conventions of clpm]
>
>
> I've been killfiling everything coming from an hotmail account for
> many years, and I've never regret it.
I became a "domainist" about 3 years ago and have never looked back.
Only I just "score down" rather than "kill", and I only
score down "most everything".
I don't even read the Subject lines below a score of -9000, and
I rarely have time to read those that are below -5000.
% wasteland domains
Score:: -9000
From: aol\.com
From: msn\.com
% silly domains
Score:: -1000
From: hotmail\.com
From: yahoo\.com
From: dbforums.com
% exceptions for silly domains
Score:: +1000
< a few regular posters who use hotmail... >
...
% anti-FAQers, anti-netiquette, usenet abusers
Score:: -9998
From: stuseven@hotmail.com
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 21 Jul 2003 09:21:55 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: JOIN problem ? (2nd attempt to post)
Message-Id: <slrnbhnto3.dk8.tadmc@magna.augustmail.com>
stu7 <stuseven@hotmail.com> wrote:
> *** B) If using my quoting style fouls up your newsreader, then,
^^^^^^^^^^^^^^^
It fouled up *hundreds* of newsreaders around the world...
> *** I feel as though I have contributed something extra.
... and you are proud(!) of that?
> *** dont bother spamming people on these newsgroups again.
We can tell who is concerned about good manners and who isn't.
Can you?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 21 Jul 2003 14:01:19 GMT
From: "Ron" <his_ron@yahoo.com>
Subject: Limit the types of extension that can be uploaded
Message-Id: <PmSSa.97379$TJ.5758705@twister.austin.rr.com>
Trying to limit the type (file extension) of files that can be uploaded.
Using cgi. Can anyone tell my what is wrong with this script? I get a
server 500 Error.
Thanks,
Ron
#Limit the types of extension that can be uploaded
@bad_extensions = ();
@good_extensions = ('dss');
#undef @bad_extensions if @good_extensions;
for(my $a = 1; $a <= $max_num_files; $a++) {
my $req = new CGI;
if($req->param("FILE$a")) {
my $file = $req->param("FILE$a");
my $filename = $file;
$filename =~ s/^.*(\\|\/)//;
$filename =~ s/ +/\_/g;
#For IE
$filename =~ s/ +/\_/g;
#For Opera
$filename =~ s/\"//g;
my $proceed_type = 0;
if(@good_extensions) {
foreach(@good_extensions) {
my $ext = $_;
$ext =~ s/\.//g;
if($filename =~ /\.$ext$/) {
$proceed_type = 1;
last;
}
}
unless($proceed_type) {
push(@was_not_good_type, $filename);
}
}
elsif(@bad_extensions) {
$proceed_type = 1;
foreach(@bad_extensions) {
my $ext = $_;
$ext =~ s/\.//g;
if($filename =~ /\.$ext$/) {
$proceed_type = 0;
last;
}
}
unless($proceed_type) {
push(@was_a_bad_type, $filename);
}
if(@was_not_good_type) {print "<B>The following file(s) were not stored as
their file extension<BR>did not match any of the valid extensions specified
in the program:<BR><BR>\n"; print join("<BR>", @was_not_good_type); print
"<BR><BR>\n"}
if(@was_a_bad_type) {print "<B>The following files were not stored as their
file extension<BR>are on the list of extensions not permitted for
upload:<BR><BR>\n"; print join("<BR>", @was_a_bad_type); print "<BR><BR>\n"}
------------------------------
Date: Mon, 21 Jul 2003 14:04:51 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Limit the types of extension that can be uploaded
Message-Id: <7qSSa.47245$EZ2.15965@nwrddc01.gnilink.net>
Ron wrote:
> Trying to limit the type (file extension) of files that can be
> uploaded. Using cgi. Can anyone tell my what is wrong with this
> script? I get a server 500 Error.
Your Question is Asked Frequently, please see The Fine Manual: "perldoc -q
500":
My CGI script runs from the command line but not the browser. (500
Server Error)
jue
------------------------------
Date: 21 Jul 2003 09:17:03 -0700
From: jrolandumuc@yahoo.com (JR)
Subject: Re: Matching URls
Message-Id: <b386d54b.0307210817.52f090a2@posting.google.com>
"Seansan" <sheukels=cuthere=@yahoo.co.uk> wrote in message news:<3f1ae5b0$0$61642$e4fe514c@dreader3.news.xs4all.nl>...
> Thx JR (and others),
>
> I tried it, and it works. But I only have 1 problem:
>
> *) It matches all the text after the url as well."My String: "Homepage is @
> http://www.homepage.nl, yep thats it" becomes
> "Homepage is @ <A HREF=http://www.homepage.nl yep thats
> it>http://www.homepage.nl yep thats it</A>"
>
> Any ideas on how to solve this? I played witht he regexp a while, but I cant
> figure it out.
>
> ps. How would I alter the regexp to match www. also? Like this?
> s/([http:\/\/www|www].*)\b/<a href='$1'>$1<\/a>/g;
>
> Seansan
>
>
> "JR" <jrolandumuc@yahoo.com> wrote in message
> news:b386d54b.0307200940.b8ef6b9@posting.google.com...
> > "Seansan" <sheukels=cuthere=@yahoo.co.uk> wrote in message
> news:<3f1aa893$0$61643$e4fe514c@dreader3.news.xs4all.nl>...
> > > Hi,
> > >
> > > Does anyone know of a link to or an example of a decent regexp that wil
> > > recognize internet URLs? (It needs to match urls starting with http://
> and
> > > www.)
> > >
> > > I am trying to replace a string like
> > > "My Homepage is @ http://www.homepage.nl"
> > > with
> > > "My Homepage is @ <A HREF =
> > > 'http://www.homepage.nl'>http://www.homepage.nl</A>"
> > >
> > > Thx, Seansan
> >
> > ## I think this is what you want. Good luck.
> > ## JR
> >
> > #!/perl
> > use strict;
> > use diagnostics;
> > use warnings;
> >
> > while(<DATA>) {
> > s/(http:\/\/www.*)\b/<a href='$1'>$1<\/a>/g;
> > print $_, "\n";
> > }
> >
> > __DATA__
> > My homepage is @ http://www.homepage.nl
> > My favorite site is @ http://www.espn.com
> > My second most favorite site is @ http://www.whatever.org
> >
> > =pod
> > ## OUTPUT
> >
> > My homepage is @ <a
> href='http://www.homepage.nl'>http://www.homepage.nl</a>
> > My favorite site is @ <a
> > href='http://www.espn.com'>http://www.espn.com</a>
> > My second most favorite site is @ <a
> > href='http://www.whatever.org'>http://www.whatever.org</a>
> >
> > =cut
## This modification should do the trick for most patterns. Good
luck.
## JR
#!/perl
use strict;
use diagnostics;
use warnings;
while(<DATA>) {
s/(http:\/\/www.*\.\w+)\b/<a href='$1'>$1<\/a>/g;
print;
}
__DATA__
1st Homepage is @ http://www.homepage.nl, yep that...
2nd Homepage is @ http://www.homepage.nl yet that
3rd Homepage is @ http://www.homepage.nl-yep that
=pod
## Output
1st Homepage is @ <a
href='http://www.homepage.nl'>http://www.homepage.nl</a>, yep that...
2nd Homepage is @ <a
href='http://www.homepage.nl'>http://www.homepage.nl</a> yet that
3rd Homepage is @ <a
href='http://www.homepage.nl'>http://www.homepage.nl</a>-yep that
=cut
------------------------------
Date: Mon, 21 Jul 2003 11:30:04 -0400
From: "Chris Vidal" <cvidal@att.com>
Subject: Newbie - skipping lines of a file.
Message-Id: <bfh0rv$99l13@kcweb01.netnews.att.com>
If I had the file named tfile.
AAA
BBB
CCC
DDD
aaa
bbb
ccc
ddd
eee
fffff
sed '/AAA/,/DDD/d' tfile would delete AAA, BBB, CCC, DDD
How would I do this using perl until loop structure.
I posted this question on comp.lang.perl and got a hostile response. I
should be posting this elsewhere, please point me in the right direction.
begin 666 cvidal.vcf
M0D5'24XZ5D-!4D0-"E9%4E-)3TXZ,BXQ#0I..CMC=FED86P-"D9..F-V:61A
M; T*14U!24P[4%)%1CM)3E1%4DY%5#IC=FED86Q 871T+F-O;0T*4D56.C(P
;,#,P-S(Q5#$U,S P-%H-"D5.1#I60T%21 T*
`
end
------------------------------
Date: Mon, 21 Jul 2003 11:14:21 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Newbie - skipping lines of a file.
Message-Id: <slrnbho4at.e16.tadmc@magna.augustmail.com>
Chris Vidal <cvidal@att.com> wrote:
> If I had the file named tfile.
>
> AAA
> BBB
> CCC
> DDD
> aaa
> bbb
> ccc
> ddd
> eee
> fffff
>
> sed '/AAA/,/DDD/d' tfile would delete AAA, BBB, CCC, DDD
>
> How would I do this using perl until loop structure.
^^^^^ ^^^^^^^^^^
I don't know how to do it that way.
I know how to do it some other way though...
> I posted this question on comp.lang.perl and got a hostile response.
That type of response should be expected when you post a
Frequently Asked Question.
(and there is no comp.lang.perl newsgroup, it was removed years ago.)
> I
> should be posting
FAQs should never need to be posted, unless there was some part
of the FAQ's answer that you didn't understand.
> Subject: Newbie - skipping lines of a file.
^^^^^
^^^^^
perldoc -q lines
How can I pull out lines between two patterns that are
themselves on different lines?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 21 Jul 2003 17:58:50 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Newbie - skipping lines of a file.
Message-Id: <u9ispvyfxx.fsf@wcl-l.bham.ac.uk>
tadmc@augustmail.com (Tad McClellan) writes:
> Chris Vidal <cvidal@att.com> wrote:
> > If I had the file named tfile.
> >
> > AAA
> > BBB
> > CCC
> > DDD
> > aaa
> > bbb
> > ccc
> > ddd
> > eee
> > fffff
> >
> > sed '/AAA/,/DDD/d' tfile would delete AAA, BBB, CCC, DDD
> >
> > How would I do this using perl until loop structure.
> ^^^^^ ^^^^^^^^^^
>
> I don't know how to do it that way.
>
> I know how to do it some other way though...
>
>
> > I posted this question on comp.lang.perl and got a hostile response.
>
>
> That type of response should be expected when you post a
> Frequently Asked Question.
The irony is that I somehow failed to recognise this as a FAQ! I just
answered the question patiently without any hostility explaining
exactly where I suspected the OP's misconception in the meaning of
'until' lay.
> (and there is no comp.lang.perl newsgroup, it was removed years ago.)
For the befefit of on-lookers who can't see non-existant newsgroups,
here is my so-called "hostile" response:
You have misunderstood what until means in Perl.
until (EXPR) {BLOCK}
is a _looping_ construct.
_Each_ time the above is executed it will repeatedly do BLOCK until
EXPR is true. If BLOCK cannot make EXPR become false and does not
break out of the loop by some other means then this is an infinite
loop.
You you evidently believe until is a simple negated condition with
memory. i.e. it does something once each time it is executed until
some condition is true and thereafter never does it again.
In Perl that would be written:
unless ( EXPR .. 1 == 0 ) { BLOCK }
Also you want the 'next' to go to the next line, i.e. the next
iteration of the while loop. But by default it goes to the next
iteration of the inner-most looping construct (the until). You could
get around this by labling your loops (see perldoc -f next).
But, of course, you didn't want the inner loop at all.
This newsgroup does not exist (see FAQ). Please do not start threads
here.
Quick staw-poll, does anyone, appart from the OP see that as hostile?
That didn't seem to be enough for the OP so he spat TOFU in my face.
Obviously this would put me in a hostile frame of mind but I think I
controlled my hostility quite well and went on calmly to explain:
> Yes you are right,
I said a lot of things. As far as I know all of them were true.
Without context I have no idea which to refer to.
> thats why I posted my question here.
None of the things I said could have accounted for your decision to
post to a non-existant newsgroup.
> ...cant figure it out or find a good example.
I have no idea what you are talking about.
> I want to skip some lines ...
This was clear from your original post. And appart from your
confusion about 'until' and 'unless' you were basically doing it right
(i.e. using 'next') in your OP. Now I've cleared that up your code
would almost work (except it would include in the output the line that
triggered the state change).
The obvious way to avoid that just to spell it out:
use strict;
use warnings;
my $seen_trigger;
while (<>) {
unless ( $seen_trigger ) {
$seen_trigger = /PATTERN/;
next;
} print;
}
If you still have a problem then I suggest you produce another minimal
but complete script that illustrates your problem (see posting
guidelines in comp.lang.perl.misc) and post it to that newsgroup
because this one does not exist (see FAQ).
If someone tries to help do not insult them by spitting TOFU in their
faces (see guidelines). Doing so will rapidly exhaust your quota of
good-will.
So not only is the OP asking a FAQ. He's also asking a question that
has already been answered for him personally. He also, despite being
advised to check the guidelines _and_ explicitly being advised to
include a minimal but complete example script, failed to include such
a script.
Plonkers take note!
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 21 Jul 2003 10:29:10 -0700
From: jp@in3corp.com (JP Ogden)
Subject: One Off Script
Message-Id: <4340eaf1.0307210929.3e3aa70d@posting.google.com>
I am currently working on a PERL script that will allow me to mine
records out of a very large data set (1 million+ records) that have a
specific field that is one off (possibly two off). In other words I
would like for my script to find records where "Field A" is 123 and
123B. Not sure where to start and how to get this done? Any thoughts
would be appreciated.
------------------------------
Date: Mon, 21 Jul 2003 11:44:03 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: One Off Script
Message-Id: <etosmoz6aho.fsf@wormtongue.emschwar>
jp@in3corp.com (JP Ogden) writes:
> I am currently working on a PERL script that will allow me to mine
> records out of a very large data set (1 million+ records) that have a
> specific field that is one off (possibly two off). In other words I
> would like for my script to find records where "Field A" is 123 and
> 123B. Not sure where to start and how to get this done? Any thoughts
> would be appreciated.
As a short aside, consider that when you looked for an answer on
Google Groups, or whatever your favourite USENET search engine is (you
*did* look, didn't you?), if you had seen a topic called "One Off
Script", you probably wouldn't have thought it relevant, right? If
you pick Subject: lines that have to do with what you're asking about,
it helps others find the answers later on, as well.
Anyway, as per your actual question: until you show us some actual
data (and preferably, any code you've tried writing already), we can't
be of much help. Just to pick one aspect out of the air, we don't
know if your data is in a flat file, or a database, or available from
an HTTP server somehow. We don't know what format it's in. We don't
know what "one off" means in this context-- is it the same value as in
another row, only with one more character appended? Does the appended
character have to be a 'B', or just alphabetical, or could it be
anything? For that matter, do you want a list of all rows that have
another row where "Field A" is one off (whatever that means), or do
you have a 'key row' which denotes the value for rows to be one off
from?
I'm not trying to put you or your question down; I just want to point
out that from all that you've given us so far, the answer could be
anything from 5 to 50 lines of code (or more). We simply don't know
enough to help.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Mon, 21 Jul 2003 16:23:32 +0200
From: "Mark" <admin@asarian-host.net>
Subject: Open2 call hangs
Message-Id: <loScndWjVIb7aoaiXTWJjQ@giganews.com>
I use an Open2 call to a process which checks mail, write data to it, and
collect the result. Like so:
use FileHandle;
use IPC::Open2;
$pid = open2 (*READER, *WRITER, "/usr/local/sa/bin/spamc -f -d 127.0.0.1 -u
test");
print WRITER $text;
close (WRITER);
$body .= $_ while (<READER>);
close (READER);
This works flawlessly on not all that large files; but when I tried it on a
file over 1M, the whole process hangs at "print WRITER $text;". I know the
docs talk about unix buffering and all, but the output of spamc is supposed
to be unbuffered.
Does anyone have any idea why it would hang altogether?
Thanks,
- Mark
------------------------------
Date: 21 Jul 2003 14:28:08 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Open2 call hangs
Message-Id: <slrnbhnu3o.t8o.abigail@alexandra.abigail.nl>
Mark (admin@asarian-host.net) wrote on MMMDCXI September MCMXCIII in
<URL:news:loScndWjVIb7aoaiXTWJjQ@giganews.com>:
"" I use an Open2 call to a process which checks mail, write data to it, and
"" collect the result. Like so:
""
"" use FileHandle;
"" use IPC::Open2;
""
"" $pid = open2 (*READER, *WRITER, "/usr/local/sa/bin/spamc -f -d 127.0.0.1 -u
"" test");
"" print WRITER $text;
"" close (WRITER);
"" $body .= $_ while (<READER>);
"" close (READER);
""
"" This works flawlessly on not all that large files; but when I tried it on a
"" file over 1M, the whole process hangs at "print WRITER $text;". I know the
"" docs talk about unix buffering and all, but the output of spamc is supposed
"" to be unbuffered.
""
"" Does anyone have any idea why it would hang altogether?
One reason could be that spamc is also writing, and both pipe buffers
are filled. Your program is waiting for spamc to read something,
so it can write, while spamc is also waiting for your program to read
so it can continue writing.
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'
------------------------------
Date: Mon, 21 Jul 2003 15:51:16 +0200
From: franck <franck@noSpam.fr>
Subject: oriented object programming
Message-Id: <bfgr77$nd92@news.rd.francetelecom.fr>
Greetings
I have the following class:
#!/usr/bin/perl
package monParser;
use HTML::Parser;
@ISA = qw(HTML::Parser);
my $ligne;
my $flag = 0;
my %want = (tag => 'font',
attrs => { face => "Arial", size => "2" });
sub start_handler {
my($tag, $attr) = @_;
return unless $tag eq $want{tag};
foreach my $name ( keys %{$want{attrs}} ) {
return unless $attr->{$name} eq $want{attrs}{$name};
}; $flag = 1;
}
sub new
{
my ($class) = @_;
my $this = $class -> SUPER::new(api_version => 3,
start_h => [\&start_handler, "tagname, attr"],
end_h => [sub {$flag=0 if shift eq $want{tag}},
"tagname"],
text_h => [sub {$ligne.= shift, "\n" if $flag}, "dtext"],
);
$this -> {'LIGNE'} = $ligne;
bless ($this,$class);
return $this;
}
sub affiche
{
my ($this) = @_;
print $this->{'LIGNE'};
}
1;
I use this class in this script:
#!/usr/bin/perl -I /home/Perl/Programmes//module
use monParser;
my $p = monParser->new();
$p->parse_file("\/home\/Perl\/Programmes\/arrivee\/tempo\.txt") || die $!;
$p->affiche;
I would like to print the LIGNE attibut with the "affiche" method
It does not work !
What is the problem ?
Thanks.
Franck
------------------------------
Date: Mon, 21 Jul 2003 10:48:57 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: franck <franck@noSpam.fr>
Subject: Re: oriented object programming
Message-Id: <Pine.SGI.3.96.1030721104633.35004C-100000@vcmr-64.server.rpi.edu>
[posted & mailed]
On Mon, 21 Jul 2003, franck wrote:
>package monParser;
>use HTML::Parser;
>@ISA = qw(HTML::Parser);
>
>
>my $ligne;
You defined $ligne here, but it doesn't have a value...
>my $flag = 0;
>my %want = (tag => 'font',
> attrs => { face => "Arial", size => "2" });
>
>sub start_handler {
> my($tag, $attr) = @_;
> return unless $tag eq $want{tag};
> foreach my $name ( keys %{$want{attrs}} ) {
> return unless $attr->{$name} eq $want{attrs}{$name};
> }; $flag = 1;
>}
>
>sub new
>{
> my ($class) = @_;
> my $this = $class -> SUPER::new(api_version => 3,
> start_h => [\&start_handler, "tagname, attr"],
> end_h => [sub {$flag=0 if shift eq $want{tag}},
>"tagname"],
> text_h => [sub {$ligne.= shift, "\n" if $flag}, "dtext"],
> );
>
> $this -> {'LIGNE'} = $ligne;
Here you've assigned $ligne to $this->{LIGNE}, but it still has no value.
Perhaps you wanted to get it from $_[1]?
> bless ($this,$class);
> return $this;
>}
>$p->parse_file("\/home\/Perl\/Programmes\/arrivee\/tempo\.txt") || die $!;
Is that argument supposed to be the value put in the LIGNE attribute? And
why are you backslashing everything?
$p->parse_file(/home/Perl/Programmes/arrivee/tempo.text") or die $!;
works just fine.
--
Jeff Pinyan RPI Acacia Brother #734 2003 Rush Chairman
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
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 5250
***************************************