[27958] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9322 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 20 11:05:42 2006

Date: Tue, 20 Jun 2006 08: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: 9322

Today's topics:
        Find repeating substring <msgrinnell@charter.net>
    Re: Find repeating substring <bugbear@trim_papermule.co.uk_trim>
    Re: Find repeating substring <msgrinnell@charter.net>
    Re: Find repeating substring <thundergnat@hotmail.com>
    Re: Find repeating substring <msgrinnell@charter.net>
    Re: Find repeating substring <peace.is.our.profession@gmx.de>
    Re: forks from within a perl daemon process? <dszostek@gmail.com>
    Re: How to write matching pattern for multi-line HTML t <mol10metal@hotmail.com>
    Re: How to write matching pattern for multi-line HTML t <mol10metal@hotmail.com>
    Re: How to write matching pattern for multi-line HTML t <benmorrow@tiscali.co.uk>
    Re: How to write matching pattern for multi-line HTML t <jurgenex@hotmail.com>
        problem in calling program in my perl script <Deb.Fang@gmail.com>
    Re: question on printing to /dev/lp <"v.niekerk at hccnet.nl">
    Re: question on printing to /dev/lp <benmorrow@tiscali.co.uk>
        setting processor affinity thru perl gepapa@gmail.com
        testing hard-ware modules using perl script <hara.acharya@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 20 Jun 2006 06:29:48 -0700
From: "Mike" <msgrinnell@charter.net>
Subject: Find repeating substring
Message-Id: <1150810188.021682.244250@u72g2000cwu.googlegroups.com>

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



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

Date: Tue, 20 Jun 2006 14:38:56 +0100
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: Find repeating substring
Message-Id: <4497fa70$0$22086$ed2619ec@ptn-nntp-reader01.plus.net>

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


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

Date: 20 Jun 2006 06:50:15 -0700
From: "Mike" <msgrinnell@charter.net>
Subject: Re: Find repeating substring
Message-Id: <1150811415.918191.310750@g10g2000cwb.googlegroups.com>

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.  

Mike



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

Date: Tue, 20 Jun 2006 09:51:27 -0400
From: thundergnat <thundergnat@hotmail.com>
Subject: Re: Find repeating substring
Message-Id: <aYCdnaLMi_j8YArZnZ2dnUVZ_vmdnZ2d@rcn.net>

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
> 

my $string = 'HEART (CONDUCTION DEFECT)  37.33/2  HEART (CONDUCTION DEFECT) 
WITH CATHETER 37.34/2';

if ($string =~ m/^(.+)(?=\s*).*\1/) {
     print $1;
}


This isn't foolproof, (what is?) but it may be good enough. Newlines in the
string may be problematic if they fall inside the term you are searching on.



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

Date: 20 Jun 2006 07:19:01 -0700
From: "Mike" <msgrinnell@charter.net>
Subject: Re: Find repeating substring
Message-Id: <1150813141.816810.199640@y41g2000cwy.googlegroups.com>

thundergnat 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
> >
>
> my $string = 'HEART (CONDUCTION DEFECT)  37.33/2  HEART (CONDUCTION DEFECT)
> WITH CATHETER 37.34/2';
>
> if ($string =~ m/^(.+)(?=\s*).*\1/) {
>      print $1;
> }
>
>
> This isn't foolproof, (what is?) but it may be good enough. Newlines in the
> string may be problematic if they fall inside the term you are searching on.

Hmm.  This seems very close.  It still picks up the code (37.33/2) that
is not repeated, but let me play with this a bit to see if I can
exclude that.



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

Date: Tue, 20 Jun 2006 16:28:14 +0200
From: Mirco Wahab <peace.is.our.profession@gmx.de>
Subject: Re: Find repeating substring
Message-Id: <e790sp$g05$1@mlucom4.urz.uni-halle.de>

Thus spoke Mike (on 2006-06-20 16:19):

> Hmm.  This seems very close.  It still picks up the code (37.33/2) that
> is not repeated, but let me play with this a bit to see if I can
> exclude that.

It doesn't here, consider:


my $text = <<END_OF_TEXT;
HEART (CONDUCTION DEFECT)  37.33/2  HEART (CONDUCTION DEFECT) WITH
CATHETER 37.34/2
END_OF_TEXT

my $rep = qr{ ^(.+)(?=\s*).*?\1 }msx;
my ($repeated) = $text=~/$rep/;

print $repeated;



prints: HEART (CONDUCTION DEFECT)


(BTW: I made the final .* non-greedy)

Regards

Mirco


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

Date: 20 Jun 2006 07:18:49 -0700
From: "Dave" <dszostek@gmail.com>
Subject: Re: forks from within a perl daemon process?
Message-Id: <1150813129.547502.137580@g10g2000cwb.googlegroups.com>

Hi,

Thank you very much Xho -- at least at a cursory glance, that seemed to
do the trick. I will test with it more today. I never would have
thought of that -- thanks again. I apologize for not replying to the
'what was the exit message' as I only just logged back on to the
newsgroups. It did not exit with any message that I saw, it just went
away.

Tad - It was working ok with cron, but when I fork ~ 2500 routines at
once or so every 5 mins, the load goes up to 6-10 so I thought better
if I spaced those forks out over every 15 seconds or so. I don't know
if that is better yet as I haven't tested it, but I think it will
probably reduce the strain quite a bit.

Thanks very much. Other peoples' knowledge never ceases to amaze me :)
~dave



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

Date: 20 Jun 2006 06:13:24 -0700
From: "Nick of course" <mol10metal@hotmail.com>
Subject: Re: How to write matching pattern for multi-line HTML tag ?
Message-Id: <1150809204.790788.69260@i40g2000cwc.googlegroups.com>


Saurabh wrote:
>                            s!\<(\!\|\/)?.*?(\/)?\>!!gix
I find it hard to believe that this regex could ever do anything
useful.
The /x modifier does nothing cos there's no spaces to ignore
The /i modifier is redundant cos there's no alphas in the regex
You need the /s modifier to operate on multiline strings
The | used for alternation is escaped so you're looking for a literal |

Try something like

s/<.*?>//



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

Date: 20 Jun 2006 06:15:43 -0700
From: "Nick of course" <mol10metal@hotmail.com>
Subject: Re: How to write matching pattern for multi-line HTML tag ?
Message-Id: <1150809343.513536.61660@c74g2000cwc.googlegroups.com>


Nick of course wrote:
> Saurabh wrote:
> >                            s!\<(\!\|\/)?.*?(\/)?\>!!gix
> I find it hard to believe that this regex could ever do anything
> useful.
> The /x modifier does nothing cos there's no spaces to ignore
> The /i modifier is redundant cos there's no alphas in the regex
> You need the /s modifier to operate on multiline strings
> The | used for alternation is escaped so you're looking for a literal |
> 
> Try something like
> 
> s/<.*?>//
Whoops!

s/<.*?>//sg



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

Date: Tue, 20 Jun 2006 15:17:12 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: How to write matching pattern for multi-line HTML tag ?
Message-Id: <8kclm3-tbp.ln1@osiris.mauzo.dyndns.org>


Quoth "Saurabh" <saurabh.sangfroid@gmail.com>:
> 
> I want to create a pattern to remove the tags from a HTML source file.
> But the pattern I have created does not handle the multiline tags. Is
> there any way to handle the tags spanning over more than one line in
> following pattern ?
> 
>                            s!\<(\!\|\/)?.*?(\/)?\>!!gix

See perldoc -q html. Preferably before bothering people all over the
world with a question you could answer yourself.

Ben

-- 
                Outside of a dog, a book is a man's best friend.
                Inside of a dog, it's too dark to read.
benmorrow@tiscali.co.uk                                           Groucho Marx


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

Date: Tue, 20 Jun 2006 14:26:55 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How to write matching pattern for multi-line HTML tag ?
Message-Id: <PATlg.22488$YI2.7498@trnddc01>

Saurabh wrote:
> I want to create a pattern to remove the tags from a HTML source file.
> But the pattern I have created does not handle the multiline tags. Is

That is the least of your problems. As has been mentioned gazillion of times 
REs are the wrong tool for parsing HTML.
See "perldoc -q HTML" for details why and for much better approaches.
And don't forget to check CPAN for ready-made solutions (yes, there is a 
module to strip tags from HTML code).

jue 




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

Date: 20 Jun 2006 06:55:25 -0700
From: "debbie523" <Deb.Fang@gmail.com>
Subject: problem in calling program in my perl script
Message-Id: <1150811725.155378.295510@h76g2000cwa.googlegroups.com>

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;

$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");

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";


ps:the function of  p1.exe is writing word "welcome" to a text file
"op.txt".

I appreciate your help.



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

Date: Tue, 20 Jun 2006 15:06:35 +0200
From: Huub <"v.niekerk at hccnet.nl">
Subject: Re: question on printing to /dev/lp
Message-Id: <4497ee49$0$32331$e4fe514c@dreader25.news.xs4all.nl>

> 
> No. You have to open a pipe lpr(1) or lp(1). If you don't understand
> this statement you need to find out more about how your OS works before
> you try programming for it; and, as I said, you need to find out what
> data formats your print spooler will accept.
> 
> Ben
> 

I think I got it. You mean e.g. open(OUTPUT,'|/dev/lp0'), where '|' is 
the pipe.


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

Date: Tue, 20 Jun 2006 15:15:29 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: question on printing to /dev/lp
Message-Id: <1hclm3-tbp.ln1@osiris.mauzo.dyndns.org>


Quoth Huub <"v.niekerk at hccnet.nl">:
> <benmorrow@tiscali.co.uk>

[ please attribute quotations. next time you'll go in the killfile. ]

> > 
> > No. You have to open a pipe lpr(1) or lp(1). If you don't understand
> > this statement you need to find out more about how your OS works before
> > you try programming for it; and, as I said, you need to find out what
> > data formats your print spooler will accept.
> 
> I think I got it. You mean e.g. open(OUTPUT,'|/dev/lp0'), where '|' is 
> the pipe.

No, I don't. I mean e.g. 

    open my $LPR, '|-', qw/lpr -Pprinter/ or die "can't fork lpr: $!";

but with the appropriate syntax for the lpr(1) or lp(1) on your system.
Please learn how printing works on your system before trying to do it
from Perl. As I said, on most Unixen printing is through one of the
*programs* lpr or lp; but the syntax and accepted formats vary.

Ben

-- 
   Razors pain you / Rivers are damp
   Acids stain you / And drugs cause cramp.                    [Dorothy Parker]
Guns aren't lawful / Nooses give
  Gas smells awful / You might as well live.            benmorrow@tiscali.co.uk


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

Date: 20 Jun 2006 07:08:18 -0700
From: gepapa@gmail.com
Subject: setting processor affinity thru perl
Message-Id: <1150812498.462664.141160@y41g2000cwy.googlegroups.com>

I would like to be able to set the processor affinity for a specific
process using a perl script.  My understanding is that one could use
the Win32 api to do this.  Does anyone have an example of using this?
Also, is there any platform independent way of doing this?
Any help would be greatly appreciated.
Thanks,
George



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

Date: 20 Jun 2006 07:33:05 -0700
From: "king" <hara.acharya@gmail.com>
Subject: testing hard-ware modules using perl script
Message-Id: <1150813985.067328.254050@r2g2000cwb.googlegroups.com>

How can I generate soft errors and or hard errors in a hard disk using
a perl script.

Is there any hardware module which can help in generating errors or
events in the hard disk or CD Rom

Can any body help me on this.

Is there any hardware modules in perl which can help me doing hardware
testing.



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

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


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