[27960] in Perl-Users-Digest
Perl-Users Digest, Issue: 9324 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 20 14:05:37 2006
Date: Tue, 20 Jun 2006 11:05:06 -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 Tue, 20 Jun 2006 Volume: 10 Number: 9324
Today's topics:
Re: Find repeating substring <tzz@lifelogs.com>
Re: Find repeating substring xhoster@gmail.com
Re: fork messing up parent filehandle <darksaga_work@yahoo.com>
Re: fork messing up parent filehandle xhoster@gmail.com
Re: fork messing up parent filehandle <darksaga_work@yahoo.com>
Re: How to pass a control-6 in Net::Telnet <tzz@lifelogs.com>
Re: How to write matching pattern for multi-line HTML t krakle@visto.com
Re: How to write matching pattern for multi-line HTML t <tadmc@augustmail.com>
Re: Out of memory xhoster@gmail.com
Re: problem in calling program in my perl script <sherm@Sherm-Pendleys-Computer.local>
Re: problem in calling program in my perl script krakle@visto.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 20 Jun 2006 11:59:45 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Find repeating substring
Message-Id: <g69odwn24y6.fsf@CN1374059D0130.kendall.corp.akamai.com>
On 20 Jun 2006, msgrinnell@charter.net wrote:
bugbear wrote: > Mike wrote:
>>> Hi All,
>>>
>>> I need a regular expression to find repeating substrings (in particular
>>> the substring that starts in position 1 of the string and is repeated
>>> elsewhere in the string). For example, in the case below, the
>>> substring of interest would be "HEART (CONDUCTION DEFECT)".
>>>
>>> Thanks much for any insights,
>>>
>>> Mike
>>>
>>>
>>>
>>> HEART (CONDUCTION DEFECT) 37.33/2 HEART (CONDUCTION DEFECT) WITH
>>> CATHETER 37.34/2
>>>
>>
>> That sounds related to this:
>>
>> http://www.cs.sunysb.edu/~algorith/files/longest-common-substring.shtml
>>
>> and may be beyond a regexp.
>>
>> BugBear
>
> Thank you for the reference. This problem while simple at first glance
> has so far proved quite challenging for me.
You asked a very open-ended question that, while theoretically
interesting, may not be the real problem in your case. Can you try to
restate your request in a different way, for example:
"I want to extract data where the format is
[LABEL] [NUMBER] [LABEL][EXTRA_INFORMATION1] [NUMBER] [LABEL][EXTRA_INFORMATION2] [NUMBER]"
And then explain the syntax of [LABEL] and [EXTRA_INFORMATION*] if
possible?
Ted
------------------------------
Date: 20 Jun 2006 16:02:50 GMT
From: xhoster@gmail.com
Subject: Re: Find repeating substring
Message-Id: <20060620120336.105$0O@newsreader.com>
"Mike" <msgrinnell@charter.net> wrote:
> Hi All,
>
> I need a regular expression to find repeating substrings (in particular
> the substring that starts in position 1 of the string and is repeated
> elsewhere in the string). For example, in the case below, the
> substring of interest would be "HEART (CONDUCTION DEFECT)".
>
> Thanks much for any insights,
>
> Mike
>
> HEART (CONDUCTION DEFECT) 37.33/2 HEART (CONDUCTION DEFECT) WITH
> CATHETER 37.34/2
This seems pretty simple. What am I missing?
/^(.*).*\1/s
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 20 Jun 2006 08:54:18 -0700
From: "darksaga" <darksaga_work@yahoo.com>
Subject: Re: fork messing up parent filehandle
Message-Id: <1150818858.774817.4680@p79g2000cwp.googlegroups.com>
problem won't occur on a linux system, seems to be sun solaris related.
just read the posts i've linked above, there problems also occured on
solaris machines only.
> (I noticed a few other problems with your program - but they don't seem
> to be related to the problem you describe, so I guess they are caused by
> cutting down a real program down to a minimal test case)
jupp, just stripped testcode.
on a sun solaris machines you never get the "readline() on closed
filehandle" errorMsg,
coz the prog. is somehow caught in endless loop reading the file.
there seems to be some problem with the EOF detection of a file handle
on solaris machines. somehow the current filehandle position is
corrupted, me wonders why, and then is reset to a position near the
beginning of the file.
greetz
darksaga
------------------------------
Date: 20 Jun 2006 16:17:41 GMT
From: xhoster@gmail.com
Subject: Re: fork messing up parent filehandle
Message-Id: <20060620121827.087$Mg@newsreader.com>
"darksaga" <darksaga_work@yahoo.com> wrote:
> hi everybody,
>
> i wrote a script where i use the fork command to speed up computation
> of a program. the parent process spawns a limited number of children,
> which process something. after a child process finishes its task a new
> child is generated. this is repeated until the parent process reaches
> the end of a file it runs through.
>
> problem is that the fork command seems to mess up the parent filehandle
> to my file, altough the children do not use this filehandle. when
> looping through the file, the filehandle is magically reset to the
> beginning of the file, or a position near the beginning. (see code
> below)
Solaris is buggy on closing forked file handles--when one copy closes
it screws up the other copies.
Change the child's exit to a POSIX::_exit. This bypasses the implicit
closing of the child's file handles.
Make sure you explicitly close all child's open file handles, other than
the ones shared with the parent, before calling _exit.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 20 Jun 2006 10:04:13 -0700
From: "darksaga" <darksaga_work@yahoo.com>
Subject: Re: fork messing up parent filehandle
Message-Id: <1150823052.906651.71240@y41g2000cwy.googlegroups.com>
> Change the child's exit to a POSIX::_exit. This bypasses the implicit
> closing of the child's file handles.
the POSIX::_exit() command solves the prob.
did some research about it, and found the following statement @ cpan:
"The exit() function does not always exit immediately. It calls any
defined END routines first, but these END routines may not themselves
abort the exit. Likewise any object destructors that need to be called
are called before the real exit. If this is a problem, you can call
POSIX:_exit($status) to avoid END and destructor processing. See
perlmod for details."
seems that these "defined END routines" close or somehow mess up the
filehandle of the parent process on solaris machines, if you call a
simple exit in one of your spawned child processes to end it. then its
seems to be reopened or shifted to somewhere near the beginning of your
file in the parent process. result is a endless loop.
tricky thing, imo. me wonders how a M$ os behaves ;-).
thanks @ Xho
greetz darksaga
------------------------------
Date: Tue, 20 Jun 2006 12:17:23 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: How to pass a control-6 in Net::Telnet
Message-Id: <g69k67b244s.fsf@CN1374059D0130.kendall.corp.akamai.com>
On 19 Jun 2006, pablo.barbachano@gmail.com wrote:
> Hi, I'm just developing a small script that communicates with a small
> piece of hw. The hw switches between modes when you press Control-6.
> How can I send that from Net::Telnet? I suppose that the ->put($value)
> is the most suitable since it doesn't add a "\n" at the end, but what
> is the $value I have to put there? AFAIK control-6 is not one of the
> ASCII escape sequences, is it?
(usually you can use Control-V to input a character in the shell, as I
did below)
perl -ne 'chomp; foreach $c (split //, $_) { printf "char code %d\n", ord $c;}'
h
char code 104
hello
char code 104
char code 101
char code 108
char code 108
char code 111
^^ <- I pressed Control-V Control-6 here
char code 30
Note that Control-6 is actually Control-^ probably. There are strange
interactions between input layers in Unix sometimes, and Control
combinations are an example. When X listens to keyboard events, it
will see Control and 6, while a terminal process will see Control-^
only (terminals only have ASCII controls available, basically, and
those only cover a few of the possible Control-KEY combinations, and
always assume uppercase when KEY is a letter). So you can enter
Control-^ in Emacs, for example, with
Control-q Control-Shift-6
and then move to the "^^" character and press C-x = to see its decimal
and hex code. I'm mentioning this in case you want to type this
character directly into a file while using a X editor such as Emacs.
Control-6 won't do it.
Hope this helps somewhat...
Ted
------------------------------
Date: 20 Jun 2006 09:03:51 -0700
From: krakle@visto.com
Subject: Re: How to write matching pattern for multi-line HTML tag ?
Message-Id: <1150819431.377056.74040@u72g2000cwu.googlegroups.com>
Saurabh wrote:
> I want to create a pattern to remove the tags from a HTML source file.
There are modules for this... Why reinvent the wheel? The purpose of a
module is so you can accomplish a task without slaving over the code to
come up with a decent untested algorithm...
If it wasn't for CPAN Perl would be the most useless language to write
anything efficient. I don't think there is ONE script I wrote (even if
10 lines) that doesn't utilize a module.
------------------------------
Date: Tue, 20 Jun 2006 11:23:41 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How to write matching pattern for multi-line HTML tag ?
Message-Id: <slrne9g88d.pik.tadmc@magna.augustmail.com>
Nick of course <mol10metal@hotmail.com> wrote:
> Nick of course wrote:
>> Try something like
>>
>> s/<.*?>//
> Whoops!
>
> s/<.*?>//sg
Whoops some more! (that is what usually happens when you attempt
to re-answer a Frequently Asked Question).
Try it on these HTML snippets:
<p>A < B</p>
<!-- <no><tags><here> -->
See the answer to this FAQ for yet more examples that make
your attempt to use regexes on HTML futile.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 20 Jun 2006 16:20:25 GMT
From: xhoster@gmail.com
Subject: Re: Out of memory
Message-Id: <20060620122110.550$q2@newsreader.com>
"janicehwang1325@yahoo.com" <janicehwang1325@yahoo.com> wrote:
> Hi,
>
> I have a server running daemon and using thread to handle multiple
> clients. However, when there is a huge data cominig from to the server,
> the error prompt out saying it's out of memory. What is the cause of
> that?
Um, you are out of memory.
Oh, and you have a bug in line 42.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Tue, 20 Jun 2006 11:25:10 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: problem in calling program in my perl script
Message-Id: <m2lkrretnt.fsf@Sherm-Pendleys-Computer.local>
"debbie523" <Deb.Fang@gmail.com> writes:
> I have a program named p1.c, it works file in windows(the p1.exe works
> file).
> But it does not work in my perl script.
Please define "does not work".
<http://catb.org/~esr/faqs/smart-questions.html>
> Part of my script is as following:
>
> #!/bin/perl -w
>
> use CGI;
>
> $query=new CGI;
>
> my $nominees=$query->param('n1');
> my $nominations=$query->param('n2');
> my $leaders=$query->param('n3');
> my $followers=$query->param('n4');
> my $filename=$query->param('f1');
> exec ("p1.exe");
Check the documentation for the function you're using. exec() does not do
what you think it does.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 20 Jun 2006 09:15:38 -0700
From: krakle@visto.com
Subject: Re: problem in calling program in my perl script
Message-Id: <1150820138.415218.130850@u72g2000cwu.googlegroups.com>
debbie523 wrote:
> I have a program named p1.c, it works file in windows(the p1.exe works
> file).
> But it does not work in my perl script.
>
> Part of my script is as following:
>
> #!/bin/perl -w
>
> use CGI;
Where is "use strict;". MANY problems can be resolved with using this
pragma... So:
#!/bin/perl -w
use strict; # Just keep it
use warnings; # For testing
use diagnostics; # For testing
use CGI;
>
> $query=new CGI;
>
my $query = new CGI;
> my $nominees=$query->param('n1');
> my $nominations=$query->param('n2');
> my $leaders=$query->param('n3');
> my $followers=$query->param('n4');
> my $filename=$query->param('f1');
Although not *important* for running code... It helps if your code is
more readable
my $nominees = $query->param('n1');
my $nominations = $query->param('n2');
my $leaders = $query->param('n3');
my $followers = $query->param('n4');
my $filename = $query->param('f1');
> exec ("p1.exe");
Does p1.exe even exist to execute?
>
> print $query->header();
> print "<html><body bgcolor=black text=lime>\n";
> print "<center><br><br><br><H2>get data and run the
> program</H2>\n<hr>";
> print "<form action='p1.cgi' method='post'>";
> print "<h4>nominees = <input type='text' value=$nominees></h4>\n";
> print "<h4>nominations = <input type='text'
> value=$nominations></h4>\n";
> print "<h4>leaders = <input type='text' value=$leaders></h4>\n";
> print "<h4>followers = <input type='text' value=$followers></h4>\n";
> print "<br><input type='submit' name='s1' value='ok'>";
> print "</form>";
> print "<h4>filename = $filename</h4>\n";
> print "</center>";
> print "</body></html>\n";
This type of printing HTML seems like a waste of time to me...
print $query->header();
print <<End_Html;
<html>
<body bgcolor=black text=lime>
<center>
<br><br><br>
<H2>get data and run the program</H2>
<hr>
<form action='p1.cgi' method='post'>
<h4>nominees = <input type='text' value=$nominees></h4>
<h4>nominations = <input type='text' value=$nominations></h4>
<h4>leaders = <input type='text' value=$leaders></h4>
<h4>followers = <input type='text' value=$followers></h4>
<br><input type='submit' name='s1' value='ok'>
</form>
<h4>filename = $filename</h4>
</center>
</body>
</html>
End_Html
>
>
> ps:the function of p1.exe is writing word "welcome" to a text file
> "op.txt".
>
> I appreciate your help.
What doesn't work?
What does p1.exe do?
You do realise ALL of your HTML inputs do NOT have names YET your Perl
script is attempting to get the queries by name... That's one thing
that doesn't work for you...
------------------------------
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 9324
***************************************