[13043] in Perl-Users-Digest
Perl-Users Digest, Issue: 453 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 10 20:17:19 1999
Date: Tue, 10 Aug 1999 17:10:12 -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, 10 Aug 1999 Volume: 9 Number: 453
Today's topics:
Running perl through a wrapper script... (Jim Matzdorff)
Re: Running perl through a wrapper script... <elaine@chaos.wustl.edu>
Re: search and match (Larry Rosler)
Re: Simple Perl Parsing? (Larry Rosler)
Re: Simple Perl Parsing? <panakal@bigfoot.com>
Re: Simple Perl Parsing? (Matthew David Zimmerman)
Re: Simple write routine (Martien Verbruggen)
Re: Some (tricky?) regexp questions (Larry Rosler)
Re: spelling of foobar (was Re: Reading the Online Docu <jbc@shell2.la.best.com>
Re: suggestions for CRAP (Lou Hevly)
Re: suggestions for CRAP <jeffp@crusoe.net>
Re: turn $6 into $6000 <uri@sysarch.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 10 Aug 1999 15:09:15 -0700
From: syran@best.com (Jim Matzdorff)
Subject: Running perl through a wrapper script...
Message-Id: <7oq7ub$dd5$1@shell18.ba.best.com>
Perhaps i am missing something, but I have a shell script that,
depending on the architecture of the machine running it, launches one
version of perl vs. the other, such as:
#!/bin/sh -f
case `uname -s` in
NetBSD)
ECHO=echo
PERL=/i386-netbsd/perl/bin/perl
;;
SunOS)
ECHO=/usr/ucb/echo
PERL=/sun4-solaris/perl/bin/perl
;;
esac
cmd="${PERL} $*"
$cmd
So, my perl script would look like:
#!/run/perl -w
print "hello\n";
(/run/perl is the shell script listed above). It tries to execute the
perl script as a shell script. I want to execute it with the version of
perl that is correct with the machine type.
So, my question, is there a way I can have a specific version of perl
run depending on the architecture and be able to run it without having
to type "perl <script name>"? Or is this a limitation of the operating
system(s)?
I can actually understand why it's not working, as the OS is guessing
it's a shell script by the fact of the #!/bin/sh -f line, but I want to
be able to run the same script with different version of perl depending
on the type of machine.
Thanks if you can help (or even if you can't),
--jim
--
--
If life is a waste of time, and time is a waste of life,
then let's all get wasted together and have the time of our lives.
------------------------------
Date: Tue, 10 Aug 1999 18:33:09 -0400
From: Elaine -HFB- Ashton <elaine@chaos.wustl.edu>
Subject: Re: Running perl through a wrapper script...
Message-Id: <37B0A846.34998DE1@chaos.wustl.edu>
Jim Matzdorff wrote:
> I can actually understand why it's not working, as the OS is guessing
> it's a shell script by the fact of the #!/bin/sh -f line, but I want to
> be able to run the same script with different version of perl depending
> on the type of machine.
right...sh is sh, perl is perl :)
depending on who or what this script is running as, you can set global
defaults in your system cshrc or .login
but probably what I would do would be to mount /OS/yadda/yadda/bin as
/usr/local/bin either with lofs or a straight hard mount or even a soft
link depending on what your site architecture is. This way, you can just
use #!/usr/local/bin/perl and be done with it. Pick one standard and
stick with it if you can as it will save you days of work.
e.
------------------------------
Date: Tue, 10 Aug 1999 15:20:16 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: search and match
Message-Id: <MPG.121a457da3919884989e22@nntp.hpl.hp.com>
In article <730qx@questionexchange.com> on 10 Aug 1999 21:47:28 GMT,
QuestionExchange <USENET@questionexchange.com> says...
> > I have a module in a perl script that allows users to search
> > for a record with a field that matches a desired date. The
> > dates are in the format with the first three letter of the
> > month (i.e. Jan) followed by one OR two spaces, and the day of
> > the month. How can I write the script to search for all
> > possible records. I have tried many different possible choices
> > and can't seem to get any of them to work. It seems as though
> > when I search, my script will match all records with a field
> > with a given month, but I can't seem to match the month and the
> > date at the same time. Thanks
>
> You should be doing something like this: (starting with the
> month in $month and day in $day): $month = "Nov"; $day =
> "23"; while(<>) { # or whatever if(/$month ?$day/) { #
> got a match. } }
I restored the sig stuff that my newsreader properly clipped.
--
This answer is courtesy of QuestionExchange.com
http://www.questionexchange.com/servlet1/showUsenetGuest?ans_id=2496&c
us_id=USENET&qtn_id=1669
A first look at that site shows some sort of a pay-if-you-wish Q&A
forum. The question and answer shown there were reasonably (i.e., not
totally bogusly) formatted, unlike this and the previous post from that
source, which seem to be totally unaware of line breaks or paragraphs.
The HTML page source is sprinkled with "<BR>\n"s, which get lost somehow
instead of translated properly.
On the theory that many readers won't bother to read it as posted, I'll
clip and reformat the snippet proposed as an answer, which is wrong.
$month = "Nov";
$day = "23";
while(<>) { # or whatever
if (/$month ?$day/) { # got a match. }
}
Try matching
$day = '2';
aginst a line containing 'Nov 23' and you will see why it is wrong. Did
anyone test it?
I offer to pay $0.00 for this answer, not even my $0.02 worth. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 10 Aug 1999 15:23:47 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Simple Perl Parsing?
Message-Id: <MPG.121a4651244fc684989e23@nntp.hpl.hp.com>
In article <7oq30g$1mt$1@murdoch.acc.Virginia.EDU> on 10 Aug 1999
20:45:04 GMT, Matthew David Zimmerman <mdz4c@node2.unix.Virginia.EDU>
says...
> In article <7optnf$2ov$1@macaw.cyberport.com>,
> Linux GNUBEE <dchurch@kabana.net> wrote:
> >my $line = "fasdjfhkdfhaksdfhSTARThello worldENDaskjkdfljkdfjls";
> >
> >How can I parse out only the text between the two tags, including the tags
> >in their respective positions within the string.
>
> $line =~ /(START.*?END)/;
> print $1;
Do you know what happens if:
a. the pattern match fails?
b. the START and END tags are on different lines within the string?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 10 Aug 1999 15:31:40 -0700
From: "ADP" <panakal@bigfoot.com>
Subject: Re: Simple Perl Parsing?
Message-Id: <7oq9f6$9nh$1@news.fm.intel.com>
Dan,
Try:
$line =~ /(START(.+)END)/; # assumes only 1 START/END pair per line
After the match:
$1-->STARThello worldEND
$2-->hello world
--A
Linux GNUBEE wrote in message <7optnf$2ov$1@macaw.cyberport.com>...
>Could someone please show me how to grab ONLY certain text from a string,
>such as the following:
>
>my $line = "fasdjfhkdfhaksdfhSTARThello worldENDaskjkdfljkdfjls";
>
>How can I parse out only the text between the two tags, including the tags
>in their respective positions within the string. In other words, I want
>toend up with
>
>STARThello worldEND
------------------------------
Date: 10 Aug 1999 23:44:27 GMT
From: mdz4c@node8.unix.Virginia.EDU (Matthew David Zimmerman)
Subject: Re: Simple Perl Parsing?
Message-Id: <7oqdgr$6h7$1@murdoch.acc.Virginia.EDU>
In article <MPG.121a4651244fc684989e23@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>In article <7oq30g$1mt$1@murdoch.acc.Virginia.EDU> on 10 Aug 1999
>20:45:04 GMT, Matthew David Zimmerman <mdz4c@node2.unix.Virginia.EDU>
>says...
>> In article <7optnf$2ov$1@macaw.cyberport.com>,
>> Linux GNUBEE <dchurch@kabana.net> wrote:
>> >my $line = "fasdjfhkdfhaksdfhSTARThello worldENDaskjkdfljkdfjls";
>> >
>> >How can I parse out only the text between the two tags, including the tags
>> >in their respective positions within the string.
>>
>> $line =~ /(START.*?END)/;
>> print $1;
>
>Do you know what happens if:
>a. the pattern match fails?
>b. the START and END tags are on different lines within the string?
###
#!/uva/bin/perl5 -w
use strict;
my $line =
"whateverBEGINyadayad
ayadaENDanything";
print $line, "\n";
print $1 . "\n" if $line =~ /(BEGIN.*?END)/s;
###
So did I pass? What's my grade, Mr. Rosler? :)
Matt
print "Just Another Perl Beginner";
--
Matthew Zimmerman ------------ http://www.people.virginia.edu/~mdz4c
Interdisciplinary Biophysics Program --------- University of Virginia
| "You got to be very careful if you don't know where you're going, |
| because you might not get there." -- Yogi Berra |
------------------------------
Date: Tue, 10 Aug 1999 22:49:15 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Simple write routine
Message-Id: <L%1s3.14$O21.2516@nsw.nnrp.telstra.net>
In article <7oolhk$mge$1@lublin.zrz.tu-berlin.de>,
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> Uri Guttman <uri@sysarch.com> wrote in comp.lang.perl.misc:
>> close( DATE ) || die "can't close file $date_file $!" ;
>
> I have rarely seen a check on close of an ordinary file. Is there
> any particular reason why you include it here? Or just general
> tidiness?
It can be a very important thing, especially if you want to make sure
that all the data you wrote actually ended up in that file. A file
system full condition is the most common problem that would cause a
close to fail. Others are interruption of close by a signal, closing a
file on an NFS mounted file system, which is no longer there, or disk
errors.
Martien
--
Martien Verbruggen | My friend has a baby. I'm writing down
Interactive Media Division | all the noises the baby makes so later
Commercial Dynamics Pty. Ltd. | I can ask him what he meant - Steven
NSW, Australia | Wright
------------------------------
Date: Tue, 10 Aug 1999 15:40:01 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Some (tricky?) regexp questions
Message-Id: <MPG.121a4a192f0d13b0989e25@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7oq23i$teh$1@nnrp1.deja.com> on Tue, 10 Aug 1999 20:29:53
GMT, marcza@my-deja.com <marcza@my-deja.com> says...
+ 1.) Assume the follwing lines:
+ X 1999 blubb...
+ X 1999/2000 blubb...
+ X blubb...
+
+ How do I match only those lines which have a 4-digit year or a
+ 4-digit-year-slash-4-digit-year on second position (delimited by
+ space(s)) AND put the result in a $1 variable ? The following doesn't
+ work:
+
+ if ($var =~ /^S ([0-9]{4}{\/[0-9]{4}}{0,1})/) {
+ ... matched
+
+ if ($var =~ /^S ([0-9]{4}||[0-9]{4}\/[0-9]{4})/) {
+ ... matched
m%^\S+\s+(\d{4}(?:/\d{4})?)\s%
+ 2.) Assume the follwing lines:
+ X sdhsdfh F one two three ...
+ X asgsg W one two three ...
+ X blubb C one two three ...
+
+ How do I match only those lines which have a F or W on third position
+ position (delimited by space(s)) AND put the result in a $2 variable
+ and the rest (trailer) into $3 ? The following doesn't work:
+
+ if ($var =~ /^X ([_a-zA-Z0-9]) +([FW]) +([_a-zA-Z0-9]*)/) {
+ ...matched
/^(\S+\s+){2}([FW])\s+(.*)/s
You didn't state what you wanted in $1, or why.
Do read perlre, as has been suggested, several times if need be.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 10 Aug 1999 23:37:00 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: spelling of foobar (was Re: Reading the Online Documentation?)
Message-Id: <37b0b79c$0$228@nntp1.ba.best.com>
Dan Wilga <dwilgaREMOVE@mtholyoke.edu> wrote:
> In article <37B08B35.58916CC@chaos.wustl.edu>, elaine@chaos.wustl.edu wrote:
>> Metasyntactic variable :)
>>
>> http://www.netmeg.net/jargon/terms/m/metasyntactic_variable.html
> Interesting list. I have always used the sequence "foo, bar, baz, boop".
> Don't know where I picked up "boop" from.
In writing tutorial material for non-programmer newbies, I've taken to
using 'walnuts' and 'rutabagas'. For some reason they strike me as
funny, and they seem less likely to produce the unintended result of
sending newbies scurrying frantically through the index to find the
meaning of this mysterious 'foo' thing they keep reading about.
And yes, I realize that the failure to recognize 'foo' and 'bar' as
nonsense words (as distinct from such self-evidently-meaningful terms
as 'ioctl' or 'getpwent') is a clear sign of severe mental retardation,
and the unsuitability of said retard for initiation into the deeper
mysteries.
--
John Callender
jbc@west.net
http://www.west.net/~jbc/
------------------------------
Date: Tue, 10 Aug 1999 22:52:17 GMT
From: lou@visca.com (Lou Hevly)
Subject: Re: suggestions for CRAP
Message-Id: <37b0ac45.42209289@news.uni-stuttgart.de>
Uri Guttman <uri@sysarch.com> wrote:
>
>why are all the free cgi sites full of crappy code? doesn't anyone who
>knows how to use a module publish scripts on the web? is it a requirement
>to have a site of free code to have a room temp iq?
<snip>
>oh, well, i am sick of this. does someone know of a decently written
>free cgi script of any sort out there? let alone a repository of them?
This is precisely what my chief interest is: I want to write good CGI
scripts in Perl, using what I've learned by lurking here the last
couple years. But every time I get one ready to publish, by the time I
get the docs done, I've learned a bit more Perl and realize the script
isn't as good as it could be. So I put it off.
However, since you've asked, I do have some scripts that, though not
optimized by clpm standards, are at least, I hope, heading in the
right direction (-w, use strict, modules, etc.). You can see them in a
tmp directory at http://www.visca.com/tmp/scripts/
>bet it is because all the decent perl hackers have plenty of real work
>to do or they focus on cpan and the core rather than cgi apps.
>
>maybe we should form a little project to create a web site with quality
>cgi (and other) scripts. if tom can raise support for the power tools
>project, this should be doable too. then we can finally direct folks to
>examples of cgi code we can be proud of. this crap is embarrassing to
>the perl community.
Though only a novice, I'd be happy to volunteer time and energy.
--
Lou Hevly (JAPHW)
lou@visca.com
http://www.visca.com
------------------------------
Date: Tue, 10 Aug 1999 18:37:24 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: suggestions for CRAP
Message-Id: <Pine.GSO.4.10.9908101833130.19643-100000@crusoe.crusoe.net>
[posted & mailed]
THE AUTHOR SPEAKS! :)
On Aug 10, Uri Guttman blah blah blah:
> possibly. let's see where this goes.
If you ask me, and perhaps you should, I would be thrilled to have a
section of CRAP's web site (soon to be at http://www.mattright.com/) to be
a CGI Repository. The CRAP project is beginning to pick up speed -- I'm
waiting for a couple articles to be written -- and this site should become
a well-tapped resource.
I'd be thrilled if people want to help the CRAP project. This crappy (no
pun inten... aw, hell, of course it was) CGI disease has caused millions
to use and write real shit for code.
And CRAP needs more than just articles on bad programs and their
replacements. It will need replacements for common subjects of CGI
programs (voting, guestbook, imagemapping (I got that one covered), form
parsers, etc).
--
jeff pinyan japhy@pobox.com japhy+perl@pobox.com japhy+crap@pobox.com
japhy's little hole in the (fire) wall: http://www.pobox.com/~japhy/
japhy's perl supposit^Wrepository: http://www.pobox.com/~japhy/perl/
The "CRAP" Project: http://www.pobox.com/~japhy/perl/crap/
CPAN ID: PINYAN http://www.perl.com/CPAN/authors/id/P/PI/PINYAN/
------------------------------
Date: 10 Aug 1999 19:33:12 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: turn $6 into $6000
Message-Id: <x73dxrb493.fsf@home.sysarch.com>
>>>>> "MM" == Mark Mielke <markm@nortelnetworks.com> writes:
MM> And we don't have transparent necks or polygonic faces as South Park
MM> would have you believe... :-)
yeah, prove it, you canadian MF!!
:-)
that movie turned me into a potty mouth. yeah!!
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu.
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 V9 Issue 453
*************************************