[26012] in Perl-Users-Digest
Perl-Users Digest, Issue: 8229 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 8 16:20:36 2005
Date: Tue, 5 Jul 2005 18:05:04 -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, 5 Jul 2005 Volume: 10 Number: 8229
Today's topics:
Re: Help With Pattern Matching <programmer16@earthlink.net>
Re: Help With Pattern Matching <jgibson@mail.arc.nasa.gov>
local bin perl path hope@hope.com
Re: local bin perl path <1usa@llenroc.ude.invalid>
Re: local bin perl path <noreply@gunnar.cc>
making alternation clearer in regular expressions <joe@example.com>
Re: making alternation clearer in regular expressions <1usa@llenroc.ude.invalid>
Re: making alternation clearer in regular expressions <tadmc@augustmail.com>
Re: OT: keeping track of time when programming <No_4@dsl.pipex.com>
Re: OT: keeping track of time when programming <abigail@abigail.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 05 Jul 2005 23:49:11 GMT
From: "Brandon" <programmer16@earthlink.net>
Subject: Re: Help With Pattern Matching
Message-Id: <X%Eye.16776$pa3.8342@newsread2.news.atl.earthlink.net>
hi,
Try this?
#!/usr/bin/perl
while (<>)
{
chomp;
print "$_\n" if m/p/i;
}
Thanks,
Brandon
"Craig" <NOSPAMcarvinabuser@highstream.net> wrote in message
news:11cj6p7k3vuvb32@corp.supernews.com...
> Hello and happy 4th,
>
> I'm trying to write a Perl script that processes each word in a file and
> prints only the words that contain the letter p (case insensitive). I'm
> not
> getting the correct output. Any help would be appreciated. My script is
> below.
>
> #!/usr/local/bin/perl
>
> $file = $ARGV[0];
> open (DATA, "+<$file");
>
> while (<DATA>)
> {
> foreach $word (m/\w+p/gi)
> {
> print "$word\n";
> }
> }
>
> close(DATA);
>
>
------------------------------
Date: Tue, 05 Jul 2005 17:49:34 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Help With Pattern Matching
Message-Id: <050720051749345858%jgibson@mail.arc.nasa.gov>
[top-posting fixed - please do not top-post]
In article <X%Eye.16776$pa3.8342@newsread2.news.atl.earthlink.net>,
Brandon <programmer16@earthlink.net> wrote:
> "Craig" <NOSPAMcarvinabuser@highstream.net> wrote in message
> news:11cj6p7k3vuvb32@corp.supernews.com...
> > Hello and happy 4th,
> >
> > I'm trying to write a Perl script that processes each word in a file and
> > prints only the words that contain the letter p (case insensitive). I'm
> > not
> > getting the correct output. Any help would be appreciated. My script is
> > below.
> >
> > #!/usr/local/bin/perl
> >
> > $file = $ARGV[0];
> > open (DATA, "+<$file");
> >
> > while (<DATA>)
> > {
> > foreach $word (m/\w+p/gi)
> > {
> > print "$word\n";
> > }
> > }
> >
> > close(DATA);
> >
> >
>
> hi,
>
> Try this?
>
> #!/usr/bin/perl
>
> while (<>)
> {
> chomp;
> print "$_\n" if m/p/i;
> }
>
>
> Thanks,
> Brandon
That will print the entire line if it contains a p. The OP wanted to
check for a 'p' in each word.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
------------------------------
Date: Tue, 05 Jul 2005 19:17:57 GMT
From: hope@hope.com
Subject: local bin perl path
Message-Id: <6lmlc1hp610nn6rhr0k8ksq65ftokf8n7l@4ax.com>
Hi all
I read some time ago that instead of keep changing the path to perl in the script from
#!/user/local/perl for unix #!c:\perl\bin\perl.exe to use on windows
You could put in a statement some where so you did not have to do this to every dam script
that you have.
BUT at the time I did not think that would be any use to me .
Now having searched and searched with google I cannot find the dam thing
Hope some one can help me
Thanks
------------------------------
Date: Tue, 05 Jul 2005 20:06:27 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: local bin perl path
Message-Id: <Xns968AA3DA7D31Basu1cornelledu@127.0.0.1>
hope@hope.com wrote in news:6lmlc1hp610nn6rhr0k8ksq65ftokf8n7l@4ax.com:
> I read some time ago that instead of keep changing the path to perl in
> the script from #!/user/local/perl for unix #!c:\perl\bin\perl.exe
> to use on windows
As Paul Lalli pointed out, for regular usage, you never have to worry
about this.
> You could put in a statement some where so you did not have to do this
> to every dam script that you have.
If you are going to curse, at least use the correct spelling. Otherwise,
you come across as being very silly.
> Now having searched and searched with google I cannot find the dam
> thing
Well, dams are hard to miss. But your question seems to be an Apache
configuration question in disguise. For that, instead of using Google,
you would be better server by spending a few minutes browsing the Apache
documentation:
<URL:http://httpd.apache.org/docs-
2.0/mod/core.html#scriptinterpretersource>
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: Tue, 05 Jul 2005 22:46:59 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: local bin perl path
Message-Id: <3j09u6Fngoi8U1@individual.net>
hope@hope.com wrote:
> I read some time ago that instead of keep changing the path to perl in the script from
> #!/user/local/perl for unix #!c:\perl\bin\perl.exe to use on windows
Assuming that
1) you are talking about invoking Perl programs as CGI scripts, and
2) the dam Unix shebang line typically is #!/usr/bin/perl
you can simply put a copy of perl.exe in C:\usr\bin
HTH
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 05 Jul 2005 17:13:39 -0400
From: joe <joe@example.com>
Subject: making alternation clearer in regular expressions
Message-Id: <joSdneRyE40LZFffRVn-uQ@rcn.net>
#!perl -w
$_ = 'acd';
sub matched($) {return "pattern @{[shift]} matched\n" }
print matched(1) if /^(?:ab|cd)$/;
print matched(2) if /^(?:ab|cd)/;
print matched(3) if /^(?:ab)|(?:cd)$/;
print matched(4) if /^(?:ab)|(?:cd)/;
print matched(5) if /(?:ab|cd)$/;
print matched(6) if /(?:ab|cd)/;
print matched(7) if /^ab|cd$/;
print matched(8) if /^ab|cd/;
print matched(9) if /ab|cd$/;
print matched(10) if /ab|cd/;
The above will of course print the following:
pattern 3 matched
pattern 4 matched
pattern 5 matched
pattern 6 matched
pattern 7 matched
pattern 8 matched
It doesn't appear so obvious why the first two patterns do not match,
but 3 and 4 do. There is an 'a' at the beginning of the string to which
the pattern is tested against, followed by a 'b' or 'c', followed by a
'd', and finally, the end of string. I know what the documentation
says; but how *you* would explain why the first two patterns do not work
and the others do not?
-J
------------------------------
Date: Tue, 05 Jul 2005 21:33:15 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: making alternation clearer in regular expressions
Message-Id: <Xns968AB29218D0Basu1cornelledu@127.0.0.1>
joe <joe@example.com> wrote in news:joSdneRyE40LZFffRVn-uQ@rcn.net:
> #!perl -w
>
> $_ = 'acd';
I would say assigning to $_ without localizing *_ is not a good idea.
> sub matched($) {return "pattern @{[shift]} matched\n" }
I would argue that this is a completely unnecessary use of prototypes.
The only use of the prototype here would be to allow you to omit the
parantheses in the function call, but you do not seem to be using that
feature anyway. I think the following version is clearer:
sub matched { "pattern @_ matched\n" }
Anyway ...
> print matched(1) if /^(?:ab|cd)$/;
> print matched(2) if /^(?:ab|cd)/;
> print matched(3) if /^(?:ab)|(?:cd)$/;
> print matched(4) if /^(?:ab)|(?:cd)/;
> print matched(5) if /(?:ab|cd)$/;
> print matched(6) if /(?:ab|cd)/;
> print matched(7) if /^ab|cd$/;
> print matched(8) if /^ab|cd/;
> print matched(9) if /ab|cd$/;
> print matched(10) if /ab|cd/;
...
> It doesn't appear so obvious why the first two patterns do not match,
Pattern 1: Matches if the string is either 'ab' or 'cd'
Pattern 2: Matches if the string begins with 'ab' or 'cd'
'acd' does not satisfy either of the conditions. I think this *is*
obvious.
> but 3 and 4 do. There is an 'a' at the beginning of the string to
> which the pattern is tested against, followed by a 'b' or 'c',
> followed by a 'd', and finally, the end of string.
Pattern 3: Matches if the string starts with 'ab' or ends with 'cd'
Pattern 4: Matches if the string starts with 'ab' or contains 'cd'
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: Tue, 5 Jul 2005 18:56:08 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: making alternation clearer in regular expressions
Message-Id: <slrndcm7go.9rl.tadmc@magna.augustmail.com>
joe <joe@example.com> wrote:
> Ugh... Nevermind. Brain malfunction. Something was causing me to
> (subconsciously) treat the beginning and end of string characters
There is no such thing as "end of string characters".
Anchors are "zero width", they match _positions_ in a string,
not characters in a string.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 05 Jul 2005 22:55:38 +0100
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: OT: keeping track of time when programming
Message-Id: <U6CdnSf44N9HnFbfRVnysw@pipex.net>
Dave wrote:
>
> Is it an accurate assumption that this is a common tendency among
> programmers when writing or debugging code?
I think its a temdency of males, and programmers tend to be male?
> If so, what strategies have
> you found effective for dealing with it?
Acceptance of reality. Although getting others to accept it isn't
always so easy.
--
Just because I've written it doesn't mean that
either you or I have to believe it.
------------------------------
Date: 05 Jul 2005 23:08:18 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: OT: keeping track of time when programming
Message-Id: <slrndcm4n1.7ev.abigail@alexandra.abigail.nl>
Dave (dave@nospam.com) wrote on MMMMCCCXXVI September MCMXCIII in
<URL:news:FtCdncP9Z_cyS1TfRVn-1g@rcn.net>:
:) <frustrated>
:)
:) Sorry, this mostly doesn't belong here, but I just became very
:) frustrated when I looked at the clock and noticed yet again that hours
:) had passed in what seemed like minutes!
:)
:) Is it an accurate assumption that this is a common tendency among
:) programmers when writing or debugging code? If so, what strategies have
:) you found effective for dealing with it?
$ grep FvwmButtons ~/.fvwm2rc
*FvwmButtonsGeometry +0+0
*FvwmButtons(1x1, Size 80 80, Swallow (UseOld) XClock 'Exec xclock -update 1')
Abigail
--
perl -wle'print"Κυστ αξοτθες Πεςμ Θαγλες"^"\x80"x24'
------------------------------
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 8229
***************************************