[29995] in Perl-Users-Digest
Perl-Users Digest, Issue: 1238 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 28 14:09:39 2008
Date: Mon, 28 Jan 2008 11:09:04 -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, 28 Jan 2008 Volume: 11 Number: 1238
Today's topics:
CRLF problem. <john1949@yahoo.com>
Re: CRLF problem. <peter@makholm.net>
Re: CRLF problem. <john1949@yahoo.com>
Re: CRLF problem. <jl_post@hotmail.com>
Re: CRLF problem. <john1949@yahoo.com>
Re: Get an arbitrary hash key, quickly. <simon.chao@fmr.com>
Re: Is it incorrect for a module to "use" subroutines f <noreply@gunnar.cc>
Re: Is it incorrect for a module to "use" subroutines f xhoster@gmail.com
Re: Is it incorrect for a module to "use" subroutines f <news@lawshouse.org>
line wrapping <user@example.net>
Re: line wrapping <rkb@i.frys.com>
new CPAN modules on Mon Jan 28 2008 (Randal Schwartz)
Re: Regexp to search over several lines in one string <rvtol+news@isolution.nl>
Re: regular expression negate a word (not character) (Greg Bacon)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 28 Jan 2008 11:19:42 -0000
From: "John" <john1949@yahoo.com>
Subject: CRLF problem.
Message-Id: <odednbYNTOz-JwDanZ2dnUVZ8uqdnZ2d@eclipse.net.uk>
I create a small perl file on a Windows platform and all the lines will end
CRLF. I upload the file to server A and it runs OK. I upload the same file
to server B and I get the 500 error message. If I chande all the CRLF to
LF the program works OK on server B.
Both servers are on Linux platforms. How can I automatically convert CRLF
to LF on server B. Or, what is server A doing that server B is not.
Regards
John
------------------------------
Date: Mon, 28 Jan 2008 11:22:42 +0000
From: Peter Makholm <peter@makholm.net>
Subject: Re: CRLF problem.
Message-Id: <87fxwikxdp.fsf@hacking.dk>
"John" <john1949@yahoo.com> writes:
> Both servers are on Linux platforms. How can I automatically convert CRLF
> to LF on server B. Or, what is server A doing that server B is not.
My guess would be that you upload to A using FTP in ASCII-mode and
upload to B in some sort of binary mode.
//Makholm
------------------------------
Date: Mon, 28 Jan 2008 11:31:22 -0000
From: "John" <john1949@yahoo.com>
Subject: Re: CRLF problem.
Message-Id: <o5CdncvkQ_-aIADaRVnygQA@eclipse.net.uk>
"Peter Makholm" <peter@makholm.net> wrote in message
news:87fxwikxdp.fsf@hacking.dk...
> "John" <john1949@yahoo.com> writes:
>
>> Both servers are on Linux platforms. How can I automatically convert
>> CRLF
>> to LF on server B. Or, what is server A doing that server B is not.
>
> My guess would be that you upload to A using FTP in ASCII-mode and
> upload to B in some sort of binary mode.
>
> //Makholm
Using WS-FTP Pro. Settings are identical.
Regards
John
------------------------------
Date: Mon, 28 Jan 2008 09:12:44 -0800 (PST)
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: CRLF problem.
Message-Id: <38c5c2ea-4e75-443e-8358-f83e57514e90@y5g2000hsf.googlegroups.com>
On Jan 28, 4:19 am, "John" <john1...@yahoo.com> wrote:
>
> Both servers are on Linux platforms. How can I automatically convert CRLF
> to LF on server B. Or, what is server A doing that server B is not.
On a Unix/Linux platform, you can remove all the CRs from a script
(or any file, really) with the following:
perl -pi.bak -e 's/\cM//g' script.pl
This removes all the CRs from the file named "script.pl", converting
all CRLFs to just LFs. (A copy of the original file will be saved as
"script.pl.bak".)
Also, how are you uploading the file to servers A and B? If you're
using ftp, I recommend using "ascii" mode before "send"ing or
"put"ting. This will convert your Windows line endings to Unix line
endings (so that you won't have to do it yourself later).
Another thing you might try is to call the script with "perl" in
the command line, like this:
perl script.pl
instead of just:
./script.pl
Not using "perl" in the command line will call whatever's specified in
the shebang line, and if the shebang line ends with a CR, like this:
#!/usr/bin/perl^M
the "perl^M" interpreter will be called, which can cause unexpected
things to happen.
(To confuse matters, some text editors will automatically hide the
"^M" characters, making you think they don't exist when in fact they
do.)
Calling your script with "perl" in front of it avoids several other
problems as well (like ones related to executable permissions and
$PATH issues), so I usually recommend that people run Perl scripts as
"perl script.pl" instead of just "script.pl".
So if you aren't already, call your script with "perl" before it
and see if that makes any difference.
I hope this helps, John.
-- Jean-Luc
------------------------------
Date: Mon, 28 Jan 2008 17:54:34 -0000
From: "John" <john1949@yahoo.com>
Subject: Re: CRLF problem.
Message-Id: <JvSdnZ8N8edKiwPanZ2dnUVZ8taknZ2d@eclipse.net.uk>
<jl_post@hotmail.com> wrote in message
news:38c5c2ea-4e75-443e-8358-f83e57514e90@y5g2000hsf.googlegroups.com...
> On Jan 28, 4:19 am, "John" <john1...@yahoo.com> wrote:
>>
>> Both servers are on Linux platforms. How can I automatically convert
>> CRLF
>> to LF on server B. Or, what is server A doing that server B is not.
>
>
> On a Unix/Linux platform, you can remove all the CRs from a script
> (or any file, really) with the following:
>
> perl -pi.bak -e 's/\cM//g' script.pl
>
> This removes all the CRs from the file named "script.pl", converting
> all CRLFs to just LFs. (A copy of the original file will be saved as
> "script.pl.bak".)
>
> Also, how are you uploading the file to servers A and B? If you're
> using ftp, I recommend using "ascii" mode before "send"ing or
> "put"ting. This will convert your Windows line endings to Unix line
> endings (so that you won't have to do it yourself later).
>
> Another thing you might try is to call the script with "perl" in
> the command line, like this:
>
> perl script.pl
>
> instead of just:
>
> ./script.pl
>
> Not using "perl" in the command line will call whatever's specified in
> the shebang line, and if the shebang line ends with a CR, like this:
>
> #!/usr/bin/perl^M
>
> the "perl^M" interpreter will be called, which can cause unexpected
> things to happen.
>
> (To confuse matters, some text editors will automatically hide the
> "^M" characters, making you think they don't exist when in fact they
> do.)
>
> Calling your script with "perl" in front of it avoids several other
> problems as well (like ones related to executable permissions and
> $PATH issues), so I usually recommend that people run Perl scripts as
> "perl script.pl" instead of just "script.pl".
>
> So if you aren't already, call your script with "perl" before it
> and see if that makes any difference.
>
> I hope this helps, John.
>
> -- Jean-Luc
Hi
Problem solved. The clue was 'ascii mode'. Server B uses vsftpd as the ftp
program.
Once I added ascii_enabled_download=YES and ascii_enabled_upload=YES all was
well.
Many thanks for pointing me in that direction.
Regards
John
------------------------------
Date: Mon, 28 Jan 2008 07:01:34 -0800 (PST)
From: nolo contendere <simon.chao@fmr.com>
Subject: Re: Get an arbitrary hash key, quickly.
Message-Id: <5e186e8c-f84f-44dc-9a40-a079d742081b@e23g2000prf.googlegroups.com>
On Jan 26, 8:05=A0pm, xhos...@gmail.com wrote:
> nolo contendere <simon.c...@fmr.com> wrote:
> > On Jan 25, 12:32=3DA0pm, xhos...@gmail.com wrote:
> > =3D2E..
>
> > > But replicates can still build up to unacceptable levels before the
> > > first instance of one ever gets $done{}. =3DA0So then you need another=
> > > hash, %queued_but_not_done, to reject duplicate entries at the earlies=
t
> > > stage.
>
> > From this I infer that you are engaging in parallel processing. Is
> > this correct?
>
> I have run into these constructs in parallel processing, but that was not
> the immediate case here. =A0I was computing a single-linkage hierarchical
> clustering tree from a distance matrix that is way too large for the COTS
> software I have access to handle. =A0I've also ran into in certain travers=
als
> of extremely large graphs.
yeah, well...that was my second guess.
------------------------------
Date: Mon, 28 Jan 2008 00:13:38 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Is it incorrect for a module to "use" subroutines from itself?
Message-Id: <604hhaF1or5ipU1@mid.individual.net>
Henry Law wrote:
> I have some code of which this is the relevant part:
>
> package NFB::Utilities::Common;
> # ...
> our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'}}, qw(
> db_connect get_file_gm_info
> # etc ... ('all' is defined but I've snipped it)
> ) );
>
> # ... other subs
>
> sub db_connect {
> # ...etc
> }
>
> sub get_file_gm_info {
> # 'db_connect' is actually in this module. The call
> # is left over from when the sub was developed in-line.
> use NFB::Utilities::Common qw(db_connect);
> }
To me, that use-statement makes no sense at all. You don't need to load
the module, since it's obviously already loaded, and the "db_connect"
symbol is already in the NFB::Utilities::Common package, so why on earth
would you want to import it to that same package?
HTH
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 27 Jan 2008 23:22:27 GMT
From: xhoster@gmail.com
Subject: Re: Is it incorrect for a module to "use" subroutines from itself?
Message-Id: <20080127182230.416$7k@newsreader.com>
Henry Law <news@lawshouse.org> wrote:
> I have some code of which this is the relevant part:
>
> package NFB::Utilities::Common;
> # ...
> our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'}}, qw(
> db_connect get_file_gm_info
> # etc ... ('all' is defined but I've snipped it)
> ) );
Presumably there is also a relevant part where you
put Exporter in ISA, or use base.
>
> # ... other subs
>
> sub db_connect {
> # ...etc
> }
>
> sub get_file_gm_info {
> # 'db_connect' is actually in this module. The call
> # is left over from when the sub was developed in-line.
> use NFB::Utilities::Common qw(db_connect);
> }
>
> I'm trying the code newly-installed on a Fedora Core 6 system running
> Perl 5.8.8 and it fails to compile, complaining that (in the above
> example) "db_connect" is not exported by the NFB::Utilities::Common
> module". It's clear that it is exported. Commenting out the offending
> lines, where the module uses subroutines from itself, fixes the problem.
The "use" happens at compile time, at which point your
@EXPORT_OK is not yet set up because that happens at run time. If
I put the @EXPORT_OK assignment in a BEGIN block, then that particular
problem goes away.
> That's OK: I can easily find and remove the offending lines.
Good, because I think they are conceptual nightmare. Why would a module
want to import into its own name space something which is already in
its name space to start with?
> But the
> code runs clean on an FC5 machine also running perl 5.8.8, and on my
> Windows machine running ActiveState 5.8.8, so I'm worried that I'm
> chasing a secondary error, actually caused by something else.
I get the warning on my 5.8.8 ActiveState.
Binary build 817 [257965] provided by ActiveState
http://www.ActiveState.com
Are you sure you are running the exact same code (and with it being
initially "use"d from the exact same code) in both places?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Sun, 27 Jan 2008 23:55:41 +0000
From: Henry Law <news@lawshouse.org>
Subject: Re: Is it incorrect for a module to "use" subroutines from itself?
Message-Id: <1201478137.39722.0@demeter.uk.clara.net>
xhoster@gmail.com wrote:
>> package NFB::Utilities::Common;
>> # ...
>> our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'}}, qw(
>> db_connect get_file_gm_info
>> # etc ... ('all' is defined but I've snipped it)
>> ) );
>
> Presumably there is also a relevant part where you
> put Exporter in ISA, or use base.
Yes; maybe I snipped too much, in the interests of brevity.
>
>> # ... other subs
>>
>> sub db_connect {
>> # ...etc
>> }
>>
>> sub get_file_gm_info {
>> # 'db_connect' is actually in this module. The call
>> # is left over from when the sub was developed in-line.
>> use NFB::Utilities::Common qw(db_connect);
>> }
> The "use" happens at compile time, at which point your
> @EXPORT_OK is not yet set up because that happens at run time. If
> I put the @EXPORT_OK assignment in a BEGIN block, then that particular
> problem goes away.
Mmm, yes. But the perplexing thing is that this code (at a slightly
earlier modification level) has been running sweetly for a year now.
>> That's OK: I can easily find and remove the offending lines.
>
> Good, because I think they are conceptual nightmare. Why would a module
> want to import into its own name space something which is already in
> its name space to start with?
There's no reason; the cause is mistakes on my part. It came about
because I develop subs in-line (at which point they do need to import
the other subs) and then move them into the package where they belong.
Sometimes I fail to delete all the "use" statements that import stuff
from the package they eventually get put into.
>
>> But the
>> code runs clean on an FC5 machine also running perl 5.8.8, and on my
>> Windows machine running ActiveState 5.8.8, so I'm worried that I'm
>> chasing a secondary error, actually caused by something else.
>
> I get the warning on my 5.8.8 ActiveState.
> Binary build 817 [257965] provided by ActiveState
> http://www.ActiveState.com
Do you indeed? I have the same build (817) and the sample code I posted
compiles cleanly with perl -c. I sense the influence of dark matter, or
spacemen, or spies from Redmond.
> Are you sure you are running the exact same code (and with it being
> initially "use"d from the exact same code) in both places?
As sure as I am of anything. The code is tar'd on the FC5 machine where
it runs smoothly and is then un-tar'd onto the FC6 machine where I get
the "not exported" errors, ending up in same-named directories. But
there is always a chance, I must admit.
> Xho
Thanks for trying to help. Since nobody has posted with detailed wisdom
about some other problem that is manifesting itself like this I'll just
write a little utility to whip through and remove the offending
references.
--
Henry Law Manchester, England
------------------------------
Date: Mon, 28 Jan 2008 13:34:31 -0500
From: monkeys paw <user@example.net>
Subject: line wrapping
Message-Id: <5vGdncn_6fOtvQPanZ2dnUVZ_rignZ2d@insightbb.com>
I have entries typed in by clients that need to wrap.
If a client were to type in a string of chars (say 100) without a space,
i need a substitution that would insert a break and newline at space
80. How would one do that with a s/// type statement?
------------------------------
Date: Mon, 28 Jan 2008 10:45:18 -0800 (PST)
From: Ron Bergin <rkb@i.frys.com>
Subject: Re: line wrapping
Message-Id: <3974d19a-d399-4695-bbc0-b21227711e9f@d4g2000prg.googlegroups.com>
On Jan 28, 10:34 am, monkeys paw <u...@example.net> wrote:
> I have entries typed in by clients that need to wrap.
> If a client were to type in a string of chars (say 100) without a space,
> i need a substitution that would insert a break and newline at space
> 80. How would one do that with a s/// type statement?
use Text::Wrap
http://search.cpan.org/~muir/Text-Tabs+Wrap-2006.1117/lib/Text/Wrap.pm
------------------------------
Date: Mon, 28 Jan 2008 05:42:16 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Mon Jan 28 2008
Message-Id: <JvCAIG.1BsD@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Acme-BabyEater-0.02
http://search.cpan.org/~zoffix/Acme-BabyEater-0.02/
Baby eating has never been easier!
----
Acme-Numbers-1.0
http://search.cpan.org/~simonw/Acme-Numbers-1.0/
a fluent numeric interface
----
Acme-Numbers-1.1
http://search.cpan.org/~simonw/Acme-Numbers-1.1/
a fluent numeric interface
----
Archive-Extract-0.26
http://search.cpan.org/~kane/Archive-Extract-0.26/
A generic archive extracting mechanism
----
Asterisk-config-0.92
http://search.cpan.org/~hoowa/Asterisk-config-0.92/
the Asterisk config read and write module.
----
BSD-Resource-1.29
http://search.cpan.org/~jhi/BSD-Resource-1.29/
BSD process resource limit and priority functions
----
CPAN-Reporter-1.08
http://search.cpan.org/~dagolden/CPAN-Reporter-1.08/
Adds CPAN Testers reporting to CPAN.pm
----
CatalystX-Foorum-0.1.3
http://search.cpan.org/~fayland/CatalystX-Foorum-0.1.3/
Forum/BBS system based on Catalyst
----
DBIx-PDlib-1.009
http://search.cpan.org/~unrtst/DBIx-PDlib-1.009/
DBI SQL abstraction and convenience methods
----
ExtUtils-MY_Metafile-0.09
http://search.cpan.org/~hio/ExtUtils-MY_Metafile-0.09/
META.yml customize with ExtUtil::MakeMaker 1
----
Geo-Proj-Japan-0.0.1
http://search.cpan.org/~kokogiko/Geo-Proj-Japan-0.0.1/
Add famous Japanese datums to Geo::Proj
----
Gtk2-CV-1.51
http://search.cpan.org/~mlehmann/Gtk2-CV-1.51/
----
Heap-Simple-0.13
http://search.cpan.org/~thospel/Heap-Simple-0.13/
Fast and easy to use classic heaps
----
Heap-Simple-Perl-0.13
http://search.cpan.org/~thospel/Heap-Simple-Perl-0.13/
A pure perl implementation of the Heap::Simple interface
----
Heap-Simple-Perl-0.14
http://search.cpan.org/~thospel/Heap-Simple-Perl-0.14/
A pure perl implementation of the Heap::Simple interface
----
Math-MatrixReal-2.03
http://search.cpan.org/~leto/Math-MatrixReal-2.03/
Matrix of Reals
----
Math-Symbolic-0.510
http://search.cpan.org/~smueller/Math-Symbolic-0.510/
Symbolic calculations
----
Math-Symbolic-Custom-Pattern-2.00
http://search.cpan.org/~smueller/Math-Symbolic-Custom-Pattern-2.00/
Pattern matching on Math::Symbolic trees
----
Math-SymbolicX-Error-1.00
http://search.cpan.org/~smueller/Math-SymbolicX-Error-1.00/
Parser extension for dealing with numeric errors
----
Math-SymbolicX-ParserExtensionFactory-2.01
http://search.cpan.org/~smueller/Math-SymbolicX-ParserExtensionFactory-2.01/
Generate parser extensions
----
Memcached-libmemcached-0.1402
http://search.cpan.org/~timb/Memcached-libmemcached-0.1402/
Thin fast full interface to the libmemcached client API
----
MooseX-LogDispatch-1.1000
http://search.cpan.org/~ash/MooseX-LogDispatch-1.1000/
A Logging Role for Moose
----
Moxy-0.24
http://search.cpan.org/~tokuhirom/Moxy-0.24/
Mobile web development proxy
----
Net-Flickr-Geo-0.5
http://search.cpan.org/~ascope/Net-Flickr-Geo-0.5/
tools for working with geotagged Flickr photos
----
Net-Halo-Status-0.02
http://search.cpan.org/~link/Net-Halo-Status-0.02/
Query Halo game servers for status.
----
Net-Oping-1.01
http://search.cpan.org/~octo/Net-Oping-1.01/
ICMP latency measurement module using the oping library.
----
POE-Component-IRC-5.54
http://search.cpan.org/~bingos/POE-Component-IRC-5.54/
a fully event-driven IRC client module.
----
POE-Component-IRC-Plugin-YouTube-MovieFindStore-0.01
http://search.cpan.org/~zoffix/POE-Component-IRC-Plugin-YouTube-MovieFindStore-0.01/
plugin for finding, resolving .FLV, and optionally storing YouTube URIs.
----
POE-Component-WWW-YouTube-VideoURI-0.04
http://search.cpan.org/~zoffix/POE-Component-WWW-YouTube-VideoURI-0.04/
Non-blocking POE wrapper around WWW::YouTube::VideoURI with download abilities.
----
POE-Component-WebService-Validator-HTML-W3C-0.03
http://search.cpan.org/~zoffix/POE-Component-WebService-Validator-HTML-W3C-0.03/
a non-blocking POE wrapper around WebService::Validator::HTML::W3C
----
POEIKCdaemon-0.00_05
http://search.cpan.org/~suzuki/POEIKCdaemon-0.00_05/
POE IKC daemon
----
QtCore-4.000
http://search.cpan.org/~vadiml/QtCore-4.000/
----
QtGui-4.000
http://search.cpan.org/~vadiml/QtGui-4.000/
----
Term-Menu-0.09
http://search.cpan.org/~dazjorz/Term-Menu-0.09/
Perl extension for asking questions and printing menus at the terminal
----
Test-Deep-0.100
http://search.cpan.org/~fdaly/Test-Deep-0.100/
Extremely flexible deep comparison
----
Tk-Wizard-Sizer-2.224
http://search.cpan.org/~mthurn/Tk-Wizard-Sizer-2.224/
Interactively determine the best size for your Wizard
----
Tripletail-0.41
http://search.cpan.org/~hio/Tripletail-0.41/
Tripletail, Framework for Japanese Web Application
----
Video-Xine-0.16
http://search.cpan.org/~stephen/Video-Xine-0.16/
Perl interface to libxine
----
Video-Xine-0.17
http://search.cpan.org/~stephen/Video-Xine-0.17/
Perl interface to libxine
----
WWW-CPAN-0.006
http://search.cpan.org/~ferreira/WWW-CPAN-0.006/
CPAN as a web service
----
Weather-NWS-0.02
http://search.cpan.org/~jmcada/Weather-NWS-0.02/
----
ack-1.77_01
http://search.cpan.org/~petdance/ack-1.77_01/
grep-like text finder
----
forks-0.27
http://search.cpan.org/~rybskej/forks-0.27/
drop-in replacement for Perl threads using fork()
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Mon, 28 Jan 2008 19:31:53 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Regexp to search over several lines in one string
Message-Id: <fnlami.1fg.1@news.isolution.nl>
Gunnar Hjalmarsson schreef:
> Petr Vileta:
>> $string =~ s/^([^>]*>).*$/$1/s;
>
> The '$' character is redundant after .*
Yes, in this case (because of the s-modfier) it is.
$ echo "abcd" |perl -pe 's/(.*)$/"<".++$i."=$1:".length($1).">\n"/ge'
<1=abcd:4>
<2=:0>
<3=:0>
$ echo "abcd" |perl -pe 's/(.*)$/"<".++$i."=$1:".length($1).">\n"/sge'
<1=abcd
:5>
<2=:0>
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Mon, 28 Jan 2008 18:53:42 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: regular expression negate a word (not character)
Message-Id: <13ps95mg8am3l37@corp.supernews.com>
The code below at least passes your tests.
Hope it helps,
Greg
#! /usr/bin/perl
use warnings;
use strict;
use constant {
MATCH => 1,
NO_MATCH => 0,
};
my @tests = (
[ "winter tire", => MATCH ],
[ "tire", => MATCH ],
[ "retire", => MATCH ],
[ "tired", => MATCH ],
[ "snowbird tire", => MATCH ],
[ "tired on a snow day", => MATCH ],
[ "snow tire and regular tire", => MATCH ],
[ " tire" => MATCH ],
[ "snow tire" => NO_MATCH ],
[ "snow tire" => NO_MATCH ],
[ "some snowtires" => NO_MATCH ],
);
my $not_snow_tire = qr/
^ \s* tire |
([^w\s]|[^o]w|[^n]ow|[^s]now)\s*tire
/xi;
my $fail;
for (@tests) {
my($str,$want) = @$_;
my $got = $str =~ /$not_snow_tire/;
my $pass = !!$want == !!$got;
print "$str: ", ($pass ? "PASS" : "FAIL"), "\n";
++$fail unless $pass;
}
print "\n", (!$fail ? "PASS" : "FAIL"), "\n";
__END__
--
... all these cries of having 'abolished slavery,' of having 'preserved the
union,' of establishing a 'government by consent,' and of 'maintaining the
national honor' are all gross, shameless, transparent cheats -- so trans-
parent that they ought to deceive no one. -- Lysander Spooner, "No Treason"
------------------------------
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 V11 Issue 1238
***************************************