[12312] in Perl-Users-Digest
Perl-Users Digest, Issue: 5912 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 7 13:07:27 1999
Date: Mon, 7 Jun 99 10:00:20 -0700
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, 7 Jun 1999 Volume: 8 Number: 5912
Today's topics:
a problem with open( ,system()) <zeng@haas.Berkeley.EDU>
Re: Afraid to ask about Y2K! <upsetter@ziplink.net>
Re: CGI and SSI in perl (Hasanuddin Tamir)
Re: CGI and SSI in perl (Hasanuddin Tamir)
Choosing a time module and working with it <james@britlinks.co.uk>
Re: Choosing a time module and working with it (Larry Rosler)
DBD::ODBC <eyounes@aol.com>
Re: Determining height and with of uploaded Graphic fil <fruffet@kaptech.com>
Re: Determining height and with of uploaded Graphic fil (brian d foy)
Re: doppelte Werte in einem Array? (Larry Rosler)
Re: Help needed and much appreciated (Tad McClellan)
Help urgently needed - Cookie & Perl <norbert_schmidt@hotmail.com>
Re: Help urgently needed - Cookie & Perl <perlguy@technologist.com>
Help with date function... <portboy@home.com>
Re: Howto substitute contiguous lines (Tad McClellan)
Re: know Perl to maintain Perl (was: Re: I pass an arra (Greg Bacon)
Re: Local filehandles (Mark-Jason Dominus)
Log Reader Utility <megrimes@flash.net>
more... jknoll@my-deja.com
nested interpolation kgentes@gentek.net
Re: Perl/RE savvy??? (Larry Rosler)
Re: Perl/RE savvy??? <garethr@cre.canon.co.uk>
Re: Probably a dumb question on "use strict;" (Eric Bohlman)
Re: Q: Auto-indent & colorize perl code? (Dan Wilga)
Re: Redirect ftp://...? (Graham Ashton)
Re: Regular Expressions (Andrea L. Spinelli)
Re: Regular Expressions (Larry Rosler)
Re: using sendmail with CGI.pm emarkert@my-deja.com
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 7 Jun 1999 09:51:06 -0700
From: ZENG <zeng@haas.Berkeley.EDU>
Subject: a problem with open( ,system())
Message-Id: <Pine.SOL.4.05.9906070945370.15086-100000@haas.Berkeley.EDU>
Hi,
I have problem for the following code:
#!/usr/local/bin/perl5
$temp = "\#\!\/usr\/bin\/csh \n who\n";
# open (PROG, "$temp |"); #this 'open' works fine.
open (PROG, "system(who) |"); #don't work. don't know why
while (<PROG>) {
push(@k,$_);
}
close (PROG);
print @k;
Please note that I have two lines in the code which use 'open'. The first
one works perfectly, but the second one which plugs the system call there,
it fails to compile (of course, every time I comment one 'open' out and
use only one. And if I use 'system(who)' separately (i.e., not a part of
the 'open'), it works fine too. What did I miss here?
Thank you for your comments.
Z.
------------------------------
Date: Mon, 07 Jun 1999 16:28:06 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Afraid to ask about Y2K!
Message-Id: <qqS63.2140$nn.662916@news.shore.net>
Steve Bean <sbean@iex.net> wrote:
: But i WILL anyway. I can't believe someof the flameout answers to good
: questions about Y2K in this section.
: ARE THERE PROBLEMS WITH Y2K AND PERL?
This is not a very creative troll.
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: 8 Jun 1999 06:45:58 GMT
From: hasant@trabas.co.id (Hasanuddin Tamir)
Subject: Re: CGI and SSI in perl
Message-Id: <slrn7lnde7.vph.hasant@borg.intern.trabas.co.id>
On Mon, 7 Jun 1999 12:40:45 +0200,
Vincent Vanbiervliet <vincent_vanbiervliet@be.ibm.com> wrote:
> Your server probably only looks for SSi for shtml files. This is for a
> faster response time, if every file (html, cgi, pl) would have to be parsed
> to look for SSI, this could slow down the server.
It's not what Apache says (well, don't know about
other servers). I could put the FAQ concerning this
matter but this is really not an appropriate place.
-hasan-
uhm, no more sig(h)
------------------------------
Date: 8 Jun 1999 06:46:09 GMT
From: hasant@trabas.co.id (Hasanuddin Tamir)
Subject: Re: CGI and SSI in perl
Message-Id: <slrn7lndkq.vph.hasant@borg.intern.trabas.co.id>
On Mon, 7 Jun 1999 12:21:23 +0100, James Stewart <james@britlinks.co.uk> wrote:
> Vincent Vanbiervliet <URL:mailto:vincent_vanbiervliet@be.ibm.com> wrote:
> > Your server probably only looks for SSi for shtml files. This is for a
> > faster response time, if every file (html, cgi, pl) would have to be parsed
> > to look for SSI, this could slow down the server.
> >
> > So the only solution I see is to use Perl variables instead of SSI
> > commands.
>
> If the situation allows, you could save out to a .shtml file and redirect
> to that.
What kind of situation that allows such overhead disk operation?
I agree with Vincent to stick with Perl, as I said in my earlier
posting.
-hasan-
uhm, no more sig(h)
------------------------------
Date: Mon, 7 Jun 1999 14:29:39 +0100
From: James Stewart <james@britlinks.co.uk>
Subject: Choosing a time module and working with it
Message-Id: <ant071339339Lh==@ch0128.charis.co.uk>
I have an array of arrays where $array[X][0] contains a date in
the format DD/MM/YYYY. I want to go through it and remove those entries
where that date has passed. I don't want to just delete $array[X][0]
but rather the whole of $array[X]
I've been looking at Date::Manip but I was wondering if there were a
smaller module that I should use instead.
Also, how is it best to go through the array deleting these entries?
I thought about some sort of loop, but if the numbering of the array
changed because I'd deleted an element, wouldn't that mess this up?
cheers. James.
--
James Stewart - james@britlinks.co.uk | "Telecom ignored us and
The Britlinks - http://www.britlinks.co.uk | democracy has died."
Phantom Tollbooth - http://www.tollbooth.org | -- Fat And Frantic
Sixpence None The Richer in the UK - http://www.britlinks.co.uk/sixpence/
------------------------------
Date: Mon, 7 Jun 1999 08:45:21 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Choosing a time module and working with it
Message-Id: <MPG.11c588e6dbeba463989b7f@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <ant071339339Lh==@ch0128.charis.co.uk> on Mon, 7 Jun 1999
14:29:39 +0100, James Stewart <james@britlinks.co.uk> says...
> I have an array of arrays where $array[X][0] contains a date in
> the format DD/MM/YYYY. I want to go through it and remove those entries
> where that date has passed. I don't want to just delete $array[X][0]
> but rather the whole of $array[X]
>
> I've been looking at Date::Manip but I was wondering if there were a
> smaller module that I should use instead.
Would one line of code satisfy your needs?
> Also, how is it best to go through the array deleting these entries?
> I thought about some sort of loop, but if the numbering of the array
> changed because I'd deleted an element, wouldn't that mess this up?
Yes, it would (unless you did it back-to-front). That's what the 'grep'
function is used for. `perldoc -f grep`
my $when = '19990601';
my @new = grep $_->[0] =~ m%(\d\d)/(\d\d)/(\d{4})% &&
"$3$2$1" ge $when, @array;
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 7 Jun 1999 18:08:44 +0200
From: "Ysteric's" <eyounes@aol.com>
Subject: DBD::ODBC
Message-Id: <7jgqb5$u92@news.vtcom.fr>
Is there anybody to help me ?
I use DBD::ODBC to manage an access table.
My problem is for the delete. When i do
$sql = qq{DELETE FROM TBL WHERE NAME=?};
if ( $dbh->do($sql, undef, $FORM{'name'})) {
print "OK, it works";
} else {
print "What ???";
}
it seem's to work quite well, but the line is still alive in my table !
Did i miss somthing ?
thanks everybody.
Eric From FRANCE
------------------------------
Date: Mon, 7 Jun 1999 16:45:50 +0200
From: "Fred Ruffet" <fruffet@kaptech.com>
Subject: Re: Determining height and with of uploaded Graphic files
Message-Id: <7jglv8$t1h$1@gatekeeper.ornano.kapt.com>
Jonathan Stowe a icrit dans le message <375b9379@newsread3.dircon.co.uk>...
>The format of the files is nothing to do with Perl though - the answer
>is either 'Use Image::Size' or it is off-topic (arguably). The same
>would be said of someone asking how to determine the fields in some
>database file - the answer would be 'use DBI' or the poster should
>be pointed in the direction of somewhere that they can discover the
>format of the file - of course once they have determined the format and
>tried some code that they thought should work it becomes an on-topic
>question again.
So, why not tell him now : "If you've got a GIF file, the width will be the
Nth byte of the file, and hegth the Mth, and, to read it, you can try this
(and here paste the perl code)." ? IMHO it will make things easier, and more
sympathetic. Don't you think so ? if the guy posts his question here, and
gets an answer like : "go away !", on some cases, he'll never come back (and
it's not good for the group), on others, he'll come back, and that'll make
one more subject in my newsreader :-)
I've recieved a more sympathic mail from Larry Rosler, who explains me that,
when he tells someone to get a lib, it's not to take the whole lib, but only
to see the source code, and to take interresting parts. And it's a better
argue, isn't it ? I've always thought than answers as "it's off-topic" or
"read the FAQS" without giving a chapter number is a bit agressiv. But, one
more time, it's only my opinion...
Regards,
Fridiric Ruffet - fruffet@kaptech.com
"Seach for perfection is all very well,
But to look for Heaven, is to leave here in hell." G.M.Summer
------------------------------
Date: Mon, 07 Jun 1999 11:54:26 -0400
From: brian@pm.org (brian d foy)
Subject: Re: Determining height and with of uploaded Graphic files
Message-Id: <brian-ya02408000R0706991154260001@news.panix.com>
In article <7jglv8$t1h$1@gatekeeper.ornano.kapt.com>, "Fred Ruffet" <fruffet@kaptech.com> posted:
> Jonathan Stowe a icrit dans le message <375b9379@newsread3.dircon.co.uk>...
> >The format of the files is nothing to do with Perl though - the answer
> >is either 'Use Image::Size' or it is off-topic (arguably). The same
> So, why not tell him now : "If you've got a GIF file, the width will be the
> Nth byte of the file, and hegth the Mth, and, to read it, you can try this
> (and here paste the perl code)." ? IMHO it will make things easier, and more
> sympathetic. Don't you think so ?
it's not easier. for someone to know that it's the nth byte, they
have to know how to get at the nth byte, decode what it means, and
translate it into a number.
using a module such as Image::Size requires only a function call and
no knowledge of the image format, *and* works for other image formats
as well. this way, the poster won't have to come back with additional
questions as he re-invents the wheel, although if he would like to try
it on his own, he has some code to look at.
however, instead of simply complaining about the community which you
have recently joined, why don't you answer the question in the way you
think it should be answered? when you do it for the hundredth time,
report back on how willing you are to do it for the hundredth and first
time.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>
------------------------------
Date: Mon, 7 Jun 1999 08:27:41 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: doppelte Werte in einem Array?
Message-Id: <MPG.11c584c03ffd6a0c989b7e@nntp.hpl.hp.com>
In article <MPG.11c5e8828a09613a989682@news.scm.de> on 7 Jun 1999
13:34:04 GMT, H. Camphausen <h.camp@scm.de> says...
+ In article <375A8E12.BF1F5981@t-online.de>,
+ christian.knebel@t-online.de says...
...
+ > ich schreibe verschiedene Strings in einen Array und es kann auch
+ > passieren, das einige der geschriebenen Strings gleich sind. Stehen
+ > diese Werte dann in diesem Array nur einmal, oder sooft wie ich sie
+ > reingeschrieben habe?
+ >
+ > Falls sie mehrmals drinstehen: gibt es Lvsungen, so das jeder String
+ > nur einmal im Array steht (soll sowas wie ein Stichwortindex
+ > werden...)?
...
+ Meine Vorredner haben das wesenzielle schon gesagt, hier
+ gleichwohl noch ein Tip:
+
+ # Strings merken und Vorkommen zdhlen:
+ while ($string = <datenquelle>) {
+ $hash { $string}++;
+ # mach sonstwas n|tzliches...
+ }
+
+ # Falls Array mit Strings gew|nscht:
+ @unique_strings = keys (%hash);
perlfaq4: "How can I extract just the unique elements of an array?"
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 7 Jun 1999 07:01:36 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help needed and much appreciated
Message-Id: <gq8gj7.khn.ln@magna.metronet.com>
Stuart Wright (stuw@dial.pipex.com.remove.everything.after.com) wrote:
: On 7 Jun 1999 14:22:12 +0100, Jonathan Stowe <gellyfish@gellyfish.com>
: wrote:
: I guess I don't really appreciate the difference between Perl and CGI.
One is a general purpose programming language and one is
an interface specification.
You can choose to use any programming language that you like,
as long as it complies with the interface specification.
Nearly everyone chooses to use Perl for such things, but they
don't have to.
: I
: assumed that CGI was a 'subsection' of Perl commands if you like.
You assumed wrong.
CGI has nothing to do with Perl, as you can use any programming
language that you like to write CGI-compliant applications.
: But I
: don't really care.
That is bad...
: I just want the scripts to work.
... because it helps you to get scripts to work to know where
the problem stems from.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 7 Jun 1999 17:27:50 +0200
From: "Norbert Schmidt" <norbert_schmidt@hotmail.com>
Subject: Help urgently needed - Cookie & Perl
Message-Id: <7jgob2$uh8$1@news4.muc.eurocyber.net>
Hi there!
I have serious trouble with a cookie in perl.
The problem is that i try to get a cookie with the command
$order=$query->cookie('multigraph');
(by using the CGI.pm)
but the cookie i get is not the actual one - it is the old one....
when i press the 'refresh' button in the browser the everything
works correct.
Why is it possible to receive a cached cookie and how can i
avoid this???
If you want take a look at it: www.overon.de
(Click "Warenkorb" after ordering)
Thanks very much for any answers
Norbert
------------------------------
Date: Mon, 07 Jun 1999 11:32:52 -0500
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: Help urgently needed - Cookie & Perl
Message-Id: <375BF434.50C69032@technologist.com>
Did you change the path where the script is located and then re-run the
script? I have found that setting the path/URL for the cookies is
imperative. If you don't set the path, and you start moving your
scripts around, you end up with problems like the one you are having...
Remove the old cookie, add the path information to the cookie you are
setting, and try it all again...
Brent
Norbert Schmidt wrote:
>
> Hi there!
>
> I have serious trouble with a cookie in perl.
> The problem is that i try to get a cookie with the command
>
> $order=$query->cookie('multigraph');
>
> (by using the CGI.pm)
> but the cookie i get is not the actual one - it is the old one....
> when i press the 'refresh' button in the browser the everything
> works correct.
> Why is it possible to receive a cached cookie and how can i
> avoid this???
> If you want take a look at it: www.overon.de
> (Click "Warenkorb" after ordering)
>
> Thanks very much for any answers
> Norbert
------------------------------
Date: Mon, 07 Jun 1999 16:56:49 GMT
From: Mitch <portboy@home.com>
Subject: Help with date function...
Message-Id: <375B89F9.9AD50241@home.com>
Okay, I'm working on a BSD 4.0.1 box, and I'm trying to setup a simple
little script that will set the date. Here's some code: The parameters
passed to the subroutine will be either "date set" or "date (shows the
date/time)". For some reason, none of my "do while" loops are working.
They all seem to pass through on any input. Can someone help me out and
tell me why? Also, is there an easier/cleaner way to do this?
BTW: Once the input has been gotten, the call I'm going to make to set
the time/date will be:
system('date YYMMDDhhmm');
Thanks a lot,
.Mitch
sub date
{
my $arg = shift;
my $year;
my $month;
my $day;
my $min;
my $moon;
if($arg =~ /set/i)
{
system('date');
my $ans = &get_it("Do you want to change the date?",
"y");
if ($ans =~ /y/i)
{
do
{
$year = &get_it("Enter the year: ",
"1999");
&show("Year is $year\n");
} while ($year >= 1999);
do
{
$month = &get_it("Enter the month: ",
"1");
} while ($month >= 1 && $month <= 12);
do
{
$day = &get_it("Enter the day: ", "1");
} while ($day >= 1 && $month <= 31);
do
{
$hour = &get_it("Enter the hour: ",
"12");
} while ($hour >= 1 && $hour <= 12);
do
{
$min = &get_it("Enter the minute: ",
"00");
} while ($min >= 0 && $min <= 59);
do
{
$moon = &get_it("Enter AM or PM: ",
"AM");
}while ($moon ne "am" or $moon ne "pm");
}
else
{
system('date');
}
}
------------------------------
Date: Mon, 7 Jun 1999 07:32:04 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Howto substitute contiguous lines
Message-Id: <kjagj7.khn.ln@magna.metronet.com>
Timpie (tim.schelfhout@alcatel.be) wrote:
: I'm looking at a way to substitute several lines at once.
That is toooo easy.
s!\Q<CENTER>
<FONT COLOR="#505050">
Cell Manager: bt0131.net.alcatel.be
<BR>
Creation Date: 06/03/99 06:00:16
</FONT>
</CENTER>
!!g;
See?
See quotemeta() in perlfunc.pod for the \Q bit.
The harder part is arranging to get the multiple lines into
$_ in the first place.
: I need only at the top of the page.
I don't understand that sentence...
: So every time I come accross these lines they need to be removed. Is
: there a way to do this. I recall
: some variable that needs to be reset to nothing ?
The $/ special variable is documented in the perlvar.pod man page.
--------------------------------------
#!/usr/bin/perl -w
use strict;
{ local $/; # undef is slurp mode
$_ = <DATA>; # slurp entire file
}
s!\Q<CENTER>
<FONT COLOR="#505050">
Cell Manager: bt0131.net.alcatel.be
<BR>
Creation Date: 06/03/99 06:00:16
</FONT>
</CENTER>
!!g;
print;
__DATA__
line one
<CENTER>
<FONT COLOR="#505050">
Cell Manager: bt0131.net.alcatel.be
<BR>
Creation Date: 06/03/99 06:00:16
</FONT>
</CENTER>
line two
<CENTER>
<FONT COLOR="#505050">
Cell Manager: bt0131.net.alcatel.be
<BR>
Creation Date: 06/03/99 06:00:16
</FONT>
</CENTER>
line three
--------------------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 7 Jun 1999 16:05:05 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: know Perl to maintain Perl (was: Re: I pass an array...)
Message-Id: <7jgqjh$9p8$1@info2.uah.edu>
In article <1dsxx9n.xzbbkf3h8s66N@[207.60.170.186]>,
rjk@linguist.dartmouth.edu (Ronald J Kimball) writes:
: Of course, "off-limits" is not the best term here. If you can explain
: all the Perl code/English speech/Liszt music such that the Visual
: BASIC/Polish/harmonica immigrants can understand it, then none of it is
: off-limits. If you can't explain it, you can still use it, as long as
: none of the immigrants are expected to understand it.
I believe you've built a straw man. If the very author of the code in
question can't explain it, it isn't likely to be maintainable anyway.
Down this path lies COBOL with reserved words in Esperanto.
Greg
--
Be warned that being an expert is more than understanding how a system is
supposed to work. Expertise is gained by investigating why a system doesn't
work.
-- Brian Redman
------------------------------
Date: Mon, 07 Jun 1999 16:46:44 GMT
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Local filehandles
Message-Id: <7jgt0i$s09$1@monet.op.net>
In article <7j9b1d$2at$1@nclient3-gui.server.ntli.net>,
Paul Wood <john.wood@diamond.co.uk> wrote:
>How much of a boon are they and should I be using them?
Do you use local variables or global variables? Why or why not?
The answers for local filehandles are exactly the same.
------------------------------
Date: Mon, 07 Jun 1999 16:29:52 GMT
From: "Mike Grimes" <megrimes@flash.net>
Subject: Log Reader Utility
Message-Id: <4sS63.295$up4.603@news.flash.net>
I have a number of (UNIX/AIX) applications which generate individual log
files. I am looking for a public domain tool which can be configured to read
multiple log files and send email or a page depending on text messages
entered in these log files. Ideally, it will be written in PERL so that it
might be easily ported/used with NT boxes also. A tool like this must exist
somewhere, does anyone have experience with such a utility?
Mike Grimes
megrimes@flash.net
------------------------------
Date: Mon, 07 Jun 1999 14:17:36 GMT
From: jknoll@my-deja.com
Subject: more...
Message-Id: <7jgk9m$om1$1@nnrp1.deja.com>
Also....
The network security system we have is supposed to catch this. (having
a directory the same name as a function) But this subdirectory PIPE is
so deep (like 6 directories) that our Novell system did not catch it.
thanks
jrk
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 07 Jun 1999 15:04:29 GMT
From: kgentes@gentek.net
Subject: nested interpolation
Message-Id: <7jgn1m$pnc$1@nnrp1.deja.com>
Perl mongers...
I tried the following, but it did not work:
$prvRec{$HEADERDEF[$col_num++]} = stripblanks($columndata);
By replacing it with a decomposed set of statements
and using temporary variables, it works like this
(as follows).. why??
$col_name = $HEADERDEF[$col_num];
$prvRec{$col_name} = stripblanks($columndata);
$col_num++;
Is it something about the nested-ness of the interpolation
or am I not "suggesting" proper context to Perl to interpolate
the $HEADERDEF list item (indexed array) as a string?
thanks for any help.
Kim Gentes
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 7 Jun 1999 08:16:39 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl/RE savvy???
Message-Id: <MPG.11c582307bb0900e989b7d@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7jfvfv$ias$1@nnrp1.deja.com> on Mon, 07 Jun 1999 08:22:27
GMT, keol@my-deja.com <keol@my-deja.com> says...
> Being a fair beginner on both Perl and RE's, I'm trying to figure out
> what is the most efficient way to write and use an RE for 'abbreviated'
> commands; ie, consider that my program accepts the command 'describe'.
>
> However, I'd like to accept abbreviations of that: 'des', 'desc',
> 'descr', 'descri', 'describ' and 'describe' should all be valid
> alongside. Is it at all possible to write an efficient RE to evaluate
> this?
>
> Obviously, I could write '/^(des|desc|descr|descri|describ|describe)$/'
> (which I guess is really the most efficient...) but shouldn't it be
> possible to write it in a more compact way?
The best I can do is factor it from the left. The '(?:' parentheses
stop the regex engine from doing unnecessary storing of the intermediate
matches.
/^des(?:c(?:r(?:i(?:be?)?)?)?)?$/i
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 7 Jun 1999 15:43:48 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: Perl/RE savvy???
Message-Id: <sipv38vwwb.fsf@cre.canon.co.uk>
keol@my-deja.com wrote:
> I could write /^(des|desc|descr|descri|describ|describe)$/ but
> shouldn't it be possible to write it in a more compact way?
Turn the match round and use the user input as the regexp:
"describe" =~ /^\Q$input/i
(This is recipe 6.20 in the Perl Cookbook). Or use Text::Abbrev from
CPAN.
--
Gareth Rees
------------------------------
Date: Mon, 7 Jun 1999 16:23:33 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Probably a dumb question on "use strict;"
Message-Id: <ebohlmanFCytJ9.AoD@netcom.com>
Josh Steadmon (steadmrd@cafes.net) wrote:
: What's confusing me is that I did declare all of my variables with "my".
: However, the error message still says:
: "Global symbol ___ requires explicit package name at ....."
That suggests that one or more of your variable names is misspelled, or
that you used inconsistent naming (e.g. declared $count, but referred to
$counter in your code). Another possibility is that you're referring to
a variable *before* you declared it.
------------------------------
Date: Mon, 07 Jun 1999 11:26:10 -0400
From: dwilgaREMOVE@mtholyoke.edu (Dan Wilga)
Subject: Re: Q: Auto-indent & colorize perl code?
Message-Id: <dwilgaREMOVE-0706991126100001@wilga.mtholyoke.edu>
In article <37582EF5.37EE412C@alumni.haas.org>, Andrew Vik
<andrew@alumni.haas.org> wrote:
> Is there any nifty method of taking perl code and automatically
> indenting and colorizing for loops, commands, etc.? MSIE does this
> nicely for HTML in its VIEW SOURCE command.
>
> Thanks in advance.
>
> Andrew
> San Francisco
Of course, you could just buy a Mac and use BBEdit :-)
Dan Wilga dwilgaREMOVE@mtholyoke.edu
** Remove the REMOVE in my address address to reply reply **
------------------------------
Date: 7 Jun 1999 15:03:14 GMT
From: billynospam@mirror.bt.co.uk (Graham Ashton)
Subject: Re: Redirect ftp://...?
Message-Id: <slrn7lnnpi.2p9.billynospam@wing.mirror.bt.co.uk>
>Steve Livingston <slivings@digitalriver.com> wrote:
>> Is it possible to redirect ftp-urls like http-urls?
no. but what's it got to do with Perl?
--
Graham
------------------------------
Date: Mon, 07 Jun 1999 16:01:20 GMT
From: aspinelli@ismes.it (Andrea L. Spinelli)
Subject: Re: Regular Expressions
Message-Id: <375bec06.273256686@news.inet.it>
On Mon, 7 Jun 1999 13:36:13 +0200, "Vincent Vanbiervliet"
<vincent_vanbiervliet@be.ibm.com> wrote:
>Try the following:
>
>.*?(/d*).*
/d is a typo! You really mean \d !
Also, remember that \D means non-digit. So, to test for numbers at the
very beginning of the line,
/^(\d+)/
or numbers after optional whitespace
/^\s*(\d+)/
Or the first number after any non-digit characters
/^\D*(\d+)/
or,...
HTH
A.
--
Andrea Spinelli, Ismes SpA, Via Pastrengo 9, 24068 Seriate BG, Italy
e-mail: aspinelli@ismes.it Phone: +39-035-307209 Fax: +39-035-302999
------------------------------
Date: Mon, 7 Jun 1999 09:28:38 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Regular Expressions
Message-Id: <MPG.11c593009f39c5f5989b80@nntp.hpl.hp.com>
In article <375bec06.273256686@news.inet.it> on Mon, 07 Jun 1999
16:01:20 GMT, Andrea L. Spinelli <aspinelli@ismes.it> says...
> On Mon, 7 Jun 1999 13:36:13 +0200, "Vincent Vanbiervliet"
> <vincent_vanbiervliet@be.ibm.com> wrote:
...
> or numbers after optional whitespace
>
> /^\s*(\d+)/
>
> Or the first number after any non-digit characters
>
> /^\D*(\d+)/
>
> or,...
/(\d+)/
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 07 Jun 1999 14:30:49 GMT
From: emarkert@my-deja.com
Subject: Re: using sendmail with CGI.pm
Message-Id: <7jgl2p$ovh$1@nnrp1.deja.com>
In article <7j8njq$e4i$1@nnrp1.deja.com>,
John Porter <jdporter@min.net> wrote:
> In article <7j8iem$c3c$1@nnrp1.deja.com>,
> landre@my-deja.com wrote:
> > Here is a script that works on its own:
> >
> > open(MAIL,"|$mailprog -t");
>
> Any particular reason you're utterly ignoring the wisdom of the ages,
> and not checking the result of open()?
>
> Any particular reason you're not using Net::SMTP?
>
> > within a much bigger script that uses CGI.pm and
>
> > if ( $action eq "process" ) {
> > &validData();
> > &writeLog();
> > &confemail();
> > print "Location: https://some.dir.com/etc...";
>
> What do those functions do? Specifically, do they die if any
> errors are found? I hope so, because otherwise you're going
> to drop through to the print "Location: " even on errors -- bad.
>
> If you're using CGI.pm, I would recommend using the redirect()
> method, rather than printing your own "Location: " header.
>
Get yourself the module Mail::Sendmail. This gives your program the
same functionality of sendmail and makes your code platform independent.
> > sub confemail {
> > # Next mail an order confirmation to the client:
> >
> > and you know the rest.
>
> I do? If it's that code you posted above, then I fault you for
> not checking for error conditions and dying on them.
>
> --
> John Porter
> Put it on a plate, son. You'll enjoy it more.
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". 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". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 5912
**************************************