[27085] in Perl-Users-Digest
Perl-Users Digest, Issue: 8975 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 20 14:05:50 2006
Date: Mon, 20 Feb 2006 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 Mon, 20 Feb 2006 Volume: 10 Number: 8975
Today's topics:
Inline::C and multiple platforms (See Website For Email)
Re: Looking for a trick with strings <abaugher@esc.pike.il.us>
Re: Looking for a trick with strings (Anno Siegel)
Re: Looking for a trick with strings <january.weiner@gmail.com>
Re: Looking for a trick with strings <january.weiner@gmail.com>
Re: Looking for a trick with strings <january.weiner@gmail.com>
Re: Looking for a trick with strings <samwyse@gmail.com>
Re: Pattern Matching on Case <abaugher@esc.pike.il.us>
Re: Question about abuse of a CGI script <news@chaos-net.de>
www.perlservices.net <jeremy@websNOSPAMwonder.co.uk>
Re: www.perlservices.net <1usa@llenroc.ude.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 20 Feb 2006 10:14:08 -0800
From: "Andrei Alexandrescu (See Website For Email)" <SeeWebsiteForEmail@moderncppdesign.com>
Subject: Inline::C and multiple platforms
Message-Id: <IuzzzL.zzu@beaver.cs.washington.edu>
I'd like to put a Perl script using Inline::C on a shared filesystem.
Users might invoke the script from Linux or Solaris systems.
Now the problem is, the Inline module will use an MD5 digest and caching
to ensure that the C part is recompiled if changed. However, that also
means that the the mechanism won't detect that the script is being
invoked under different operating systems, so it will erroneously
attempt to use the Linux shared lib on Solaris or vice versa.
How can I avoid that in an elegant manner?
Thanks,
Andrei
------------------------------
Date: Mon, 20 Feb 2006 09:11:24 -0600
From: Aaron Baugher <abaugher@esc.pike.il.us>
Subject: Re: Looking for a trick with strings
Message-Id: <86fyme3w0z.fsf@cail.baugher.pike.il.us>
January Weiner <january.weiner@gmail.com> writes:
> I have strings (protein sequences, to be precise) that contain
> letters + '-':
>
> my $s = 'Y---ERI-TTKDIV----EIKRHLDYLQAPRITNNDLE' ; # for example
> my $s_nogaps = $s ;
> $s_nogaps =~ s/-//g ;
>
> Then I get two numbers:
>
> my ($from, $length) = (0, 5) ;
>
> These are the indices of a substring within $s_nogaps (and not $s).
> The above indices correspond to a string 'YERIT'.
>
> Now I would like to have fragments of $s corresponding to this
> substring. For example, given the above indices, I should get
> 'Y--ERI-T'.
I'd start out the way you are: strip the hyphens from the line and get
your substring. Then turn the substring into a search regex that will
accept any number of hyphens between each letter. Tested:
#!/usr/bin/perl -w
use strict;
my( $from, $length ) = (0,5);
my $s = 'Y---ERI-TTKDIV----EIKRHLDYLQAPRITNNDLE';
( my $nogaps = $s ) =~ s/-//g;
my $string = substr( $nogaps, $from, $length );
my $search = join '-*', split //, $string;
print "Search: $search\n";
$s =~ /($search)/;
my $result = $1;
print "Result: $result\n";
That could be simplified to use fewer lines and variables.
--
Aaron -- aaron_baugher@yahoo.com
http://360.yahoo.com/aaron_baugher
------------------------------
Date: 20 Feb 2006 16:01:16 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Looking for a trick with strings
Message-Id: <dtcp4c$ot9$1@mamenchi.zrz.TU-Berlin.DE>
Aaron Baugher <abaugher@esc.pike.il.us> wrote in comp.lang.perl.misc:
> January Weiner <january.weiner@gmail.com> writes:
>
> > I have strings (protein sequences, to be precise) that contain
> > letters + '-':
> >
> > my $s = 'Y---ERI-TTKDIV----EIKRHLDYLQAPRITNNDLE' ; # for example
> > my $s_nogaps = $s ;
> > $s_nogaps =~ s/-//g ;
> >
> > Then I get two numbers:
> >
> > my ($from, $length) = (0, 5) ;
> >
> > These are the indices of a substring within $s_nogaps (and not $s).
> > The above indices correspond to a string 'YERIT'.
> >
> > Now I would like to have fragments of $s corresponding to this
> > substring. For example, given the above indices, I should get
> > 'Y--ERI-T'.
>
> I'd start out the way you are: strip the hyphens from the line and get
> your substring. Then turn the substring into a search regex that will
> accept any number of hyphens between each letter. Tested:
[code snipped]
That doesn't give a unique identification in all cases. If
$s = 'E-E-E-E-E';
the substring "EE" of $s_nogaps can't be uniquely identified. Less trivial
examples are also possible.
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: Mon, 20 Feb 2006 17:18:13 +0100 (CET)
From: January Weiner <january.weiner@gmail.com>
Subject: Re: Looking for a trick with strings
Message-Id: <dtcq45$v6n$1@sagnix.uni-muenster.de>
Aaron Baugher <abaugher@esc.pike.il.us> wrote:
> I'd start out the way you are: strip the hyphens from the line and get
> your substring. Then turn the substring into a search regex that will
> accept any number of hyphens between each letter. Tested:
There can be different, but identical substrings in $s_nogaps, which,
however, have different numbers of gaps :-).
j.
--
------------------------------
Date: Mon, 20 Feb 2006 17:20:57 +0100 (CET)
From: January Weiner <january.weiner@gmail.com>
Subject: Re: Looking for a trick with strings
Message-Id: <dtcq99$v6n$2@sagnix.uni-muenster.de>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> Create an offset table @offset that points, for every character position
> in $s_nogaps, to the corresponding character in $s. That is, the array
> would start out ( 0, 4, 5, 6, 8, ...). Use that table to calculate
> the character positions in $s, given character positions in $s_nogap.
(snip)
Thanks! This is an elegant solution to my problem. I'm running benchmarks
to see which one is quicker (say, you have hundreds sequences, each with a
length of a couple of thousands, and you are searching for several
substrings in each sequence...).
Cheers,
January
--
------------------------------
Date: Mon, 20 Feb 2006 17:32:10 +0100 (CET)
From: January Weiner <january.weiner@gmail.com>
Subject: Re: Looking for a trick with strings
Message-Id: <dtcqua$v6n$3@sagnix.uni-muenster.de>
Lukas Mai <rwxr-xr-x@gmx.de> wrote:
> Hmm, you could define a gappy letter as [A-Z], followed by 0 or more
> dashes. Then you need to match a prefix of $from gappy letters, followed
> by $length gappy letter, which you extract.
> sub get_subseq {
> my ($str, $from, $len) = @_;
> return ($str =~ /(?:[A-Z]-*){$from}((?:[A-Z]-*){$len})/)[0];
> }
Oww, this is nice and compact.
> The only problem with this approach is that it will return all trailing
> dashes, i.e. get_subseq('Y--ERI-TT', 0, 1) eq 'Y--'.
This is not a problem at all, I can alwas strip the remaining -'s.
Could you explain why you use the (?: ) construct? It says in the perlre
that
This is for clustering, not capturing; it groups subexpressions like
"()", but doesn't make backreferences as "()" does. So
@fields = split(/\b(?:a|b|c)\b/)
is like
@fields = split(/\b(a|b|c)\b/)
but doesn't spit out extra fields. It's also cheaper not to capture
characters if you don't need to.
I assume that with (?: ) you dont get $1 and $2 in our example, but why
should it matter?
Cheers,
j.
--
------------------------------
Date: Mon, 20 Feb 2006 18:21:18 GMT
From: Samwyse <samwyse@gmail.com>
Subject: Re: Looking for a trick with strings
Message-Id: <yMnKf.23012$_S7.5273@newssvr14.news.prodigy.com>
January Weiner wrote:
> Aaron Baugher <abaugher@esc.pike.il.us> wrote:
>
>>I'd start out the way you are: strip the hyphens from the line and get
>>your substring. Then turn the substring into a search regex that will
>>accept any number of hyphens between each letter. Tested:
>
> There can be different, but identical substrings in $s_nogaps, which,
> however, have different numbers of gaps :-).
This is untested, but based on Aaron's code:
#!/usr/bin/perl -w
use strict;
my( $from, $length ) = (0,5);
my (@matches, @offsets, @lengths);
my $s = 'Y---ERI-TTKDIV----EIKRHLDYLQAPRITNNDLE';
( my $nogaps = $s ) =~ s/-//g;
my $string = substr( $nogaps, $from, $length );
my $search = join '-*', split //, $string;
print "Search: $search\n";
while ($s =~ /($search)/g) {
push @matches, $1;
push @offsets, pos $s;
push @lengths, length $1;
}
This gives you all of the matching subsequences, where they are in the
original string, and their lengths (including the gaps).
BTW, does anyone know if "study $s;" be useful for very long values of
$s? Obviously, all of these solutions need to be tested (via "use
Benchmark;") to see which works best for your typical data.
------------------------------
Date: Mon, 20 Feb 2006 09:13:17 -0600
From: Aaron Baugher <abaugher@esc.pike.il.us>
Subject: Re: Pattern Matching on Case
Message-Id: <86bqx23vxu.fsf@cail.baugher.pike.il.us>
"Matt Garrish" <matthew.garrish@sympatico.ca> writes:
> But then consider:
> <td>I like to</td><td>Format everything</td><td>Inside
> cells</td><td>On one line</td>
> Never underestimate a bad html parsing job... : )
Yep. When I really want to get the visible text of a page without the
html, `lynx -dump $url` comes in handy.
--
Aaron -- aaron_baugher@yahoo.com
http://360.yahoo.com/aaron_baugher
------------------------------
Date: Mon, 20 Feb 2006 16:42:19 +0100
From: Martin Kissner <news@chaos-net.de>
Subject: Re: Question about abuse of a CGI script
Message-Id: <slrndvjoqr.44f.news@maki.homeunix.net>
Ian Wilson wrote :
> Martin Kissner wrote:
>> Maybe you missed the fact that I have changed my script so the actual
>> spammer is not able to use it any more.
>
> Have you? I thought you had just changed it to check the referrer_URI.
Yes, I have. I never mentioned that I changed the script to check the
referer URI, have I? As a first step I checked the "user" input for some
strings that were common to all spam mails.
In the meantime I have added some more input checking to make sure that
there can be only one email address in the appropriate field and nothing
else. All other fields are now checked against a list of allowed
charakters (letters, numbers, braces, comas, fullstops and newlines only
in the textarea field)
> These URI's are harvested by bots which inspect feedback forms. Soon a
> bot will pick up your modified form and start using the new action URI
> it finds there, which is the one your modified script allows through.
>
> Much better to sanitise the form data. I'd discard any transaction that
> contains suspicious data, e.g. newlines in a subject field. If I
> couldn't use (or adapt) an already existing well tested script such as
> the nms scripts, I'd specify a minimum set of allowable characters for
> each field. Have you looked at the scripts at
Thanks for your hint, I have already done so.
> http://nms-cgi.sourceforge.net/ - even if you can't use them, they'll
> give some ideas on sanitising form data.
Not yet, but I will take a look at it. Thanks for the link.
Best regards
Martin
--
perl -e '$S=[[73,116,114,115,31,96],[108,109,114,102,99,112],
[29,77,98,111,105,29],[100,93,95,103,97,110]];
for(0..3){for$s(0..5){print(chr($S->[$_]->[$s]+$_+1))}}'
------------------------------
Date: Mon, 20 Feb 2006 16:57:53 +0000
From: Jeremy Clulow <jeremy@websNOSPAMwonder.co.uk>
Subject: www.perlservices.net
Message-Id: <ausjv1d09j2sicidfqkd5ipc9thiv6eck7@4ax.com>
Hi,
Does anyone know whether www.perlservices.net is still trading?
I paid 30 dollars for a script from them 50 hours ago by credit card. I
received no acknowledgement or script. I have an order number received
after paying. I've e-mailed them twice since ordering but still no reply.
They only have a form on their site, but no e-mail or physical address. Any
information would be gratefully received.
Thanks.
Jeremy Clulow
--
~~~~~~~~~~~~~~~~~~~~~~~~~~
Jeremy Clulow,
Webs Wonder Design
www.webswonder.co.uk
jeremy@websNOSPAMwonder.co.uk
~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Mon, 20 Feb 2006 18:55:30 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: www.perlservices.net
Message-Id: <Xns97708DC0465B7asu1cornelledu@127.0.0.1>
Jeremy Clulow <jeremy@websNOSPAMwonder.co.uk> wrote in
news:ausjv1d09j2sicidfqkd5ipc9thiv6eck7@4ax.com:
> Does anyone know whether www.perlservices.net is still trading?
I am not sure what you are asking.
> I paid 30 dollars for a script from them 50 hours ago by credit card.
> I received no acknowledgement or script. I have an order number
> received after paying. I've e-mailed them twice since ordering but
> still no reply.
I would recommend getting in touch with the fraud division at your
credit card company.
> They only have a form on their site, but no e-mail or physical
> address.
You are very trusting indeed.
In any case, I do not see anything in your post that is topical for
comp.lang.perl.misc.
> --
Your sig separator is incorrectly specified. It should be
dash-dash-space-newline.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
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 8975
***************************************