[7385] in Perl-Users-Digest
Perl-Users Digest, Issue: 1010 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 11 08:09:21 1997
Date: Thu, 11 Sep 97 05:00:47 -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 Thu, 11 Sep 1997 Volume: 8 Number: 1010
Today's topics:
Re: backreferences and /i in regex (Tom Grydeland)
Re: Computing How Much time has past between two times (Martien Verbruggen)
Re: Computing How Much time has past between two times <rovf@earthling.net>
Deleting temp files with perl (Matt Weber)
Re: Deleting temp files with perl (Martien Verbruggen)
Re: Deleting temp files with perl (Bart Lateur)
Re: Difference between a link() and File::Copy (Kitty Smith)
Re: divide by zero problem in reports. (Tom Grydeland)
Easy installation of IlyaZ's Perl in DOS (Steffen Beyer)
Re: flock() time (David Goh)
Flushing STDOUT? ckc@dmi.min.dk
Net::FTP progress indicator ? (Guido Wimmel)
Re: Newbie Needs help! <rovf@earthling.net>
NT 4.0 <webadmin@prestel.net>
Re: Perl on win32 book <wd@uebemc.siemens.de>
Re: Perl script question for gurus (Bart Lateur)
Perl5.003 and NT4SP3 - memory leaks <tsoakell@appliednet.co.uk>
Please help - using a target with the Location cmd (Cecil)
Re: Please help - using a target with the Location cmd (Martien Verbruggen)
Please help me with locking! Using NDBM! (Jason Hazzard)
Re: Recursive sorting (Andrew M. Langmead)
Saving array in Object <kistler@inf.ethz.ch>
Re: saving reg expressions <rovf@earthling.net>
Re: shell command "more" <mobrien@cello.hp.hpl.com>
Re: Split operator (Tom Grydeland)
strict-module problem <anke@pan.ncrome.romesc.ibm.com>
Re: What does "regexp *+ operand could be empty" mean? (Bart Lateur)
win95 install question <holiday@allmed.net>
Re: win95 install question (Martien Verbruggen)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 11 Sep 1997 09:08:12 GMT
From: tom@mitra.phys.uit.no (Tom Grydeland)
Subject: Re: backreferences and /i in regex
Message-Id: <slrn61fd7s.itu.tom@mitra.phys.uit.no>
On 10 Sep 1997 18:07:06 GMT, Ilya Zakharevich
<ilya@math.ohio-state.edu> wrote:
> You can have both with the RE jumbo patch (should be merged in some
> numbered Perl version some time very soon).
> /(?i)(friend)\s+\1/; # Gives 2 now and later
> /((?i)friend)\s+\1/; # Undefined now (and gives 2),
> # later will give 1
Are you telling me that ((?i)re) means/will mean case insensitivity for
just a part of a pattern? Interesting. Will the same apply to
((?m)re), ((?s)re) etc?
> Ilya
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: 11 Sep 1997 03:28:02 GMT
From: mgjv@mali.comdyn.com.au (Martien Verbruggen)
Subject: Re: Computing How Much time has past between two times
Message-Id: <5v7og2$o4k$1@comdyn.comdyn.com.au>
In article <341727F9.4AFA@airmail.net>,
carenry1@airmail.net (Ryan Moore) writes:
> I am wanting a simple algorithm (if there is one) to compute how much
> time has past since one time till another time. For example, I am
> needing to write a program that will tell me that 22 Hours and 10
> minutes have past between 2:50 and 1:00. I have looked through all the
> Date and Time Libraies and if they cover this I can't find it.
Not even Date::DateCalc?
The package provides a Perl interface to a C library which offers a wide
variety of date calculations based on the Gregorian calendar (the one
used in all western countries today), complying with the ISO/R 2015-1971
and DIN 1355 standards which specify things as what leap years are, when
they occur, how the week numbers are defined, what's the first day of the
week, how many weeks (52 or 53) a given year has, and so on.
or Date::Manip?
This is a set of routines designed to make any common date/time
manipulation easy to do. Operations such as comparing two times,
calculating a time a given amount of time from another, or parsing
international times are all easily done.
I suspect one of these will have what you're looking for.
Alternatively, you could use one of the Date parsing modules that
convert a string to a number of seconds since epoch, subtract the two,
and work back to seconds, minutes, hours and days.
If all you need to do is compare times within the same day, it's even
easier. (realise that you will need to have 24 hour time, or an AM/PM
qualifier).
Change the times to minutes since midnight:
e.g. 1:20 becomes 1 * 60 + 20
15:40 becomes 15 * 60 + 40
subtract the two, and the difference in minutes is there. I'll leave
it to you to rework that in hours and minutes.
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: 11 Sep 1997 13:48:45 +0200
From: Ronald Fischer <rovf@earthling.net>
Subject: Re: Computing How Much time has past between two times
Message-Id: <xz2afhkf4v6.fsf@uebemc.siemens.de>
>>>>> On 10 Sep 1997 16:30:18 -0700
>>>>> "RM" == Ryan Moore <carenry1@airmail.net> wrote:
RM> I am wanting a simple algorithm (if there is one) to compute how much
RM> time has past since one time till another time. For example, I am
RM> needing to write a program that will tell me that 22 Hours and 10
RM> minutes have past between 2:50 and 1:00. I have looked through all the
RM> Date and Time Libraies and if they cover this I can't find it.
Just an idea: If you do a
use Time::Local;
you'll have the function
$time1=timelocal($sec,$min,$hours,$mday,$mon,$year)
that puts into $time1 the number of seconds past the beginning of the
epoch. Having two such timevalues, you could either build the
difference
$time2-$time1
or, if you want to stay portable, do a
use POSIX;
difftime($time2,$time1)
to get the interval in seconds. From this, it is trivial to convert
back to hours and minutes (you could also use the function localtime
to do this).
--
Ronald Fischer (rovf@Earthling.net) (PGP public key available)
http://ourworld.compuserve.com/homepages/ronald_fischer/
[When posting a followup, mailing a courtesy copy is fine, provided it is
clearly marked as such.]
------------------------------
Date: 11 Sep 1997 04:12:26 GMT
From: mweber@vt.edu (Matt Weber)
Subject: Deleting temp files with perl
Message-Id: <5v7r3a$8ta$2@solaris.cc.vt.edu>
What commands do I use in a perl script to delete a temporary file?
Thanks,
M Weber
http://weberworld.com
------------------------------
Date: 11 Sep 1997 06:45:35 GMT
From: mgjv@mali.comdyn.com.au (Martien Verbruggen)
Subject: Re: Deleting temp files with perl
Message-Id: <5v842f$os6$2@comdyn.comdyn.com.au>
In article <5v7r3a$8ta$2@solaris.cc.vt.edu>,
mweber@vt.edu (Matt Weber) writes:
>
> What commands do I use in a perl script to delete a temporary file?
The same as what you would use to delete any other file:
unlink($some_path_to_some_temp_file);
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Thu, 11 Sep 1997 12:36:50 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Deleting temp files with perl
Message-Id: <341ebacd.7174358@news.tornado.be>
mweber@vt.edu (Matt Weber) wrote:
>What commands do I use in a perl script to delete a temporary file?
unlink
Yeah, it's a non-intuitive name for non-Unix programmers. We'll have to
live with it.
HTH,
Bart.
------------------------------
Date: Wed, 10 Sep 1997 09:01:33 -0500
From: smith@twsuvm.uc.twsu.edu (Kitty Smith)
Subject: Re: Difference between a link() and File::Copy
Message-Id: <19970910.090133.353730.NETNEWS@TWSUVM.UC.TWSU.EDU>
Allen Choy <achoy@us.oracle.com> wrote:
>Can anyone tell me what's the difference of creating a new file via
>link() versus using the
>File::Copy module?
Is this module available for Win32? If so, where can I find it?
------------------------------
Date: 11 Sep 1997 09:16:52 GMT
From: tom@mitra.phys.uit.no (Tom Grydeland)
Subject: Re: divide by zero problem in reports.
Message-Id: <slrn61fdo4.itu.tom@mitra.phys.uit.no>
On 10 Sep 1997 18:11:32 GMT, Nigel Reed <nigelr@convex.hp.com> wrote:
> I've come across a problem and I wonder if anyone has a better solution.
>
> I have a report which basically looks like
>
> Computer name Hours Available Hours uses Percent used
> @>>>>>>>>>>>> @##### @##### @###.##
> $name,$avail,$used,(($used/avail)*100)
^ missing a $ here
> .
>
> Now, if I have 0 hours used, I'm getting the following error...
>
> Illegal division by zero at weekly line 267, <IN> chunk 123.
> main::STDOUT called at weekly line 67
Dividing zero into something isn't illegal. Dividing *by* zero is.
Look to the *right* of the slash for the clue.
What you have there is 'avail', which is a bareword (and if you used -w
like you should, you would've gotten the error:
Unquoted string "avail" may clash with future reserved word at ...
Argument "avail" isn't numeric in divide at ...
... and that is pretty clear, isn't it?
> I could use an extra variable and something like
>
> if ($used = 0) {
> $percent = 0
> } else {
> $percent = (($used/avail)*100)
^ again missing a $
> }
>
> But I could do without the extra 'if' section. Anyone got
> any clever ideas for me please?
$r = $b && $a/$b;
> Nigel
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: 11 Sep 1997 08:57:30 GMT
From: sb@en.muc.de (Steffen Beyer)
Subject: Easy installation of IlyaZ's Perl in DOS
Message-Id: <5v8bpq$nlp$1@en1.engelschall.com>
Petr Prikryl <prikryl@dcse.fee.vutbr.cz> wrote:
> If you are interested in the extremely easy installation of the latest
> Ilya Zakharevich's port of Perl 5.004 under DOS or Windows, check the
> following URL:
> http://www.fee.vutbr.cz/~prikryl/tools.html
Does this port support Perl modules from CPAN?
I.e., is it possible to install modules from CPAN without modification
using the usual "perl Makefile.PL; make; make test; make install" scheme?
Or is some modification needed? Is it possible at all?
Thank you for any clarification!
Yours,
--
Steffen Beyer <sb@sdm.de> http://www.engelschall.com/u/sb/
"There is enough for the need of everyone in this world,
but not for the greed of everyone." - Mahatma Gandhi
>> Unsolicited commercial email goes directly to /dev/null <<
------------------------------
Date: 11 Sep 1997 05:54:19 GMT
From: david@unico.com.au (David Goh)
Subject: Re: flock() time
Message-Id: <5v812b$5pd@padre.unico.com.au>
In comp.lang.perl.misc, on Sat, 06 Sep 1997 18:26:47 -0500
Jerry <jfitz@oaktree.net> wrote:
>How long does a second process keep attempting to access a file that has
>been flocked by a previous process?
If you call flock() on a file descriptor *without* bit-oring LOCK_NB
(which stands for LOCK_NonBlocking ) into the operation code, the call
will block indefinitely.
If you *do* bit-or LOCK_NB into the operation code for the flock() call,
the call will return immediately.
Oh, and be *sure* that flock() is being called on a local file. If you
try to do this on a file available via NFS or some other networked file
system, it will fail dismally. You need to use fcntl() instead.
If you want some other condition to be able to interrupt the flock()
call, (such as time elapsed since first trying to lock the file, or
somesuch), then you should use LOCK_NB and combine it with sleep() in a
while loop...
WARNING: Untested code which anyone may copy and use follows:
# Just for completeness' sake. :)
$LOCK_SH = 1;
$LOCK_EX = 2;
$LOCK_NB = 4;
$LOCK_UN = 8;
# Check this value on your system, it may *not* be 11.
# Have a look at /usr/include/sys/errno.h (that's the usual place,
# anyway), for EWOULDBLOCK. This may be an alias for EAGAIN. If so
# then use the number for EAGAIN.
#
$EWOULDBLOCK = 11;
# Maximum number of times to try flock()
$max_tries = 10;
# time to sleep,
$time_to_sleep = 5;
$retry = 1;
$tries = 0;
while ( $retry &&
( $tries < $max_tries ) ) {
if (flock(FOO_FILE, $LOCK_EX | $LOCK_NB)) {
#
# We have locked the file, we're fine, stop retrying.
#
$retry = 0;
} elsif ( $! != $EWOULDBLOCK ) {
#
# flock returned an error, and $! (errno) was *not* $EWOULDBLOCK.
# This means the syscall died horribly.
#
$retry = 0; # Don't really need this, we're about to die.
die "Error trying to lock file: $!\n";
} else {
#
# flock failed with errno == $EWOULDBLOCK
# Sleep for a bit, then 'round we go again.
# Note, you could do something else here, like ask the user a
# question, or test some other condition, etc.
#
sleep($time_to_sleep);
$tries++;
}
}
if ($tries >= $max_tries) {
# NB: Careful, this might be an off-by-one error, I haven't
# tested it. Please do so before using this code.
#
# We tried ten times, and still couldn't get a lock.
die ("Could not obtain lock on file in ",
$max_tries * $time_to_sleep, " seconds\n");
}
End of untested code. No guarantees are made of exact correctness.
Use at own risk. "Warning Warning! Danger Will Robinson, Danger!" :)
What you *probably* should do is put all the above crap into a
subroutine, with parameters for time to wait, and all that junk.
Later,
David
--
Unico Computer Systems Pty Ltd
David Goh Software Engineer
david@unico.com.au (03) 9866 5688
------------------------------
Date: Thu, 11 Sep 1997 06:51:04 -0600
From: ckc@dmi.min.dk
Subject: Flushing STDOUT?
Message-Id: <873976943.12036@dejanews.com>
A relatively simple question (I presume). I have attempted to find the
answer in the Camel book, but to no avail. Here goes:
I am currently refining a script which goes through a file and extracts
certain data. Once every 50th line I change the window- and icon-titles
with ($i being incremented each time I read a line, and thus containing
the line-number):
print "ESC]0;$i^G";
This, however, does not work, since print() needs a "\n" to flush the
output buffer. Sending a "\n" at the end of this string sort of disrupts
my output, though, so I was wondering if there was a different way of
flushing STDOUT. Alternatively, another method of changing the window-
and icon-titles would be equally appreciated. Note, however, that this
also has to work in Perl v4 (the script is running on a supercomputer
which I can't change the installation on).
I would be extremely thankful if you could cc any suggestions to
ckc@dmi.min.dk, as I can't read the group from this account (I am hoping
to remedy this situation, and do read the group from another account).
TIA,
Kvan <ckc@dmi.min.dk>
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 11 Sep 1997 08:33:00 GMT
From: wimmel@sdm.de (Guido Wimmel)
Subject: Net::FTP progress indicator ?
Message-Id: <5v8abs$3ps@sunti1.sdm.de>
Hi,
is it possible to display a progress indicator
(e.g. hash marks or percentage) when downloading
or uploading files with Net::FTP? This would
be nice to inform the user when large files
are involved, like in the usual ftp or ncftp.
TIA & Cheers,
-- Guido
------------------------------
Date: 11 Sep 1997 13:08:03 +0200
From: Ronald Fischer <rovf@earthling.net>
To: "Larry G. Dunn" <dunn.l.g@wcsmail.com>
Subject: Re: Newbie Needs help!
Message-Id: <xz2en6wf6r0.fsf@uebemc.siemens.de>
>>>>> On Wed, 10 Sep 1997 12:47:22 GMT
>>>>> "LGD" == Larry G Dunn <circuitrdr@geocities.com> wrote:
LGD> In other words, I want to be able to do something like:
LGD>
LGD> cd newdirectory*
LGD>
LGD> The directory is a composition of the date and time of day that
LGD> the directory is created.
To change to a new directory, you do a
chdir(newdirectory);
This mimics the cd of the shell, except that $ENV{PWD} is not kept in
sync. If you want to have this as well, do a
use Cwd 'chdir';
before, which will overide the default chdir by a more clever one.
--
Ronald Fischer (rovf@Earthling.net) (PGP public key available)
http://ourworld.compuserve.com/homepages/ronald_fischer/
[When posting a followup, mailing a courtesy copy is fine, provided it is
clearly marked as such.]
------------------------------
Date: Thu, 11 Sep 1997 11:46:32 +0100
From: webadmin <webadmin@prestel.net>
Subject: NT 4.0
Message-Id: <3417CC08.658661BE@prestel.net>
Hi
Is there perl for NT 4.0 on the web somewhere.
Also are there any helpful guides. i can do perl on unix, I just need to
know if theres anything special/different that I should know about
Iqbal
------------------------------
Date: 11 Sep 1997 06:11:53 GMT
From: Wolfgang Denk <wd@uebemc.siemens.de>
Subject: Re: Perl on win32 book
Message-Id: <5v8239$1jj$1@galaxy.mchh.siemens.de>
danny@lennon.postino.com (Danny Aldham) writes:
>This book is co-authored by Tom Christiansen, know for posts to
>win32 threads that one should get a real OS, a web page that slams
>any browser running on a win32 platform, and frequent posts of his
>kill file that includes anything to do with win32 or NT . Give it a miss.
Give it a miss? win32 and NT? Right you are!
[Sorry, couldn't resist.]
Wolfgang Denk
Office: (+49)-89-722-27328, Fax -36703 wd@uebemc.siemens.de
Private: (+49)-89-95720-110, Fax -112 wd@denx.muc.de
"You're just jealous." "What, of an overgrown puppy with a single-
figure IQ?" - Terry Pratchett, _Moving Pictures_
------------------------------
Date: Thu, 11 Sep 1997 12:36:44 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Perl script question for gurus
Message-Id: <341db6ec.6181589@news.tornado.be>
lparillo@newshost.li.net (Parillo) wrote:
>Will you have to do a printf in order to get the leading zeros?
What's wrong with sprintf (not printf)? Except that it's cryptic for
non-C programmers! ;-)
You can also use this:
$_ = substr("0" x $count . $number, -$count);
>BTW, the perldoc on printf and sprintf is not helpful to non-c
>programmners. Is there a better source (other than deja news?)
The POD's used to be crap for this. They referred to the documentation
for "C"! Aaaarghh!!!
But, I must say, the latest updates for PERLFUNC.POD have improved a
lot. Now they do contain all the basic info. Thanks guys!
Bart.
------------------------------
Date: Thu, 11 Sep 1997 11:29:27 +0100
From: Tim Soakell <tsoakell@appliednet.co.uk>
Subject: Perl5.003 and NT4SP3 - memory leaks
Message-Id: <3417C723.4248DDF8@appliednet.co.uk>
I've got a non-terminating process in the above combo. It seems to be
leaking memory like mad (upto 15MB in 2 days).
Anyone out there with similar experience and/or recommendations?
TIA
--
Tim Soakell Tel: +44 (0) 1483 295 806
AppliedNet Ltd. Fax: +44 (0) 1483 573 704
Mob: +44 (0) 468 904 862
Visit us at http://www.appliednet.co.uk
------------------------------
Date: Thu, 11 Sep 1997 06:27:15 GMT
From: aarons@mindspring.com (Cecil)
Subject: Please help - using a target with the Location cmd
Message-Id: <34178ec3.10704278@nntp3.mindspring.com>
Does anyone know how to use a location drop-down with frames.
I would like to do something like:
Location: $FORM{gopage} target=_top
but of course that does not work.
Any help much appreciated - please email asago@harbinger.net
because I can't usually get to a news server
Thanks!!!!
------------------------------
Date: 11 Sep 1997 06:44:31 GMT
From: mgjv@mali.comdyn.com.au (Martien Verbruggen)
Subject: Re: Please help - using a target with the Location cmd
Message-Id: <5v840f$os6$1@comdyn.comdyn.com.au>
In article <34178ec3.10704278@nntp3.mindspring.com>,
aarons@mindspring.com (Cecil) writes:
> Does anyone know how to use a location drop-down with frames.
location drop down? frames? What sort of perl thingies are that?
> I would like to do something like:
> Location: $FORM{gopage} target=_top
Oh.. wait.. HTML?
comp.infosystems.www.* are probably groups where people are more
likely to know about these sort of things.
> Any help much appreciated - please email asago@harbinger.net
sorry.
> because I can't usually get to a news server
well.. Since you have to come back to post to the appropriate group,
you might as well pick up the answer here.
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Thu, 11 Sep 1997 10:00:06 GMT
From: hazzard@usa.net (Jason Hazzard)
Subject: Please help me with locking! Using NDBM!
Message-Id: <5v8ffo$8cl$1@brie.direct.ca>
Hello Perlers,
I am using Tie() with NDBM_File, and I am very confused about locking.
How can I make sure that the DBM is locked properly? When using a tie, how
can I make sure it is locked, if another tie() is being tried. Basically, on
a webpage, if a CGI opens the DBM, and another user runs the same cgi, how can
I make sure the first is closed, before the other is allowed to run?
Just a basic explanation would help me a LOT!
Thanks,
Jay
------------------------------
Date: Thu, 11 Sep 1997 05:01:28 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Recursive sorting
Message-Id: <EGBvAH.An8@world.std.com>
snapfisher@worldnet.att.net (Paul Fisher) writes:
>Can the sort function be called resursively?
Not according to the perlfunc man page.
>I have a gouup of strings of the form xxxxx.#:xxxxx.#:xxxxx.#
>where xxx are alphabetic characters and # is an ascii numerical
>representation (i.e. a number).
>I wrote a sort subroutine to be used by the sort function, as in "sort
>by_myfunc()". This routine breaks off the first chunnk of the string and
>evaluates it. If the two substrings are equal, I want it to recursively
>call itself with the remaining string portions.
How about something like this:
while(<>) {
push @data, $_;
$sort{$_} = [ split /[:.]/ ];
}
print map "$_\n", sort by_myfunc, @data;
sub by_mysort {
$sort{$a}[0] cmp $sort{$b}[0] ||
$sort{$a}[1] <=> $sort{$b}[1] ||
$sort{$a}[2] cmp $sort{$b}[2] ||
$sort{$a}[3] <=> $sort{$b}[3] ||
$sort{$a}[4] cmp $sort{$b}[4] ||
$sort{$a}[5] <=> $sort{$b}[5];
}
Pieces of this solution comes from various places. The suggestion to
break up the data ahead of time. (requiring only N splits instead of
N*Log(N) splits) comes from the first edition camel and the
FAQ. Sorting on the first non-equal field by using the logical-or
operator is shown in "Learning Perl", among other places.
--
Andrew Langmead
------------------------------
Date: Thu, 11 Sep 1997 09:53:28 -0700
From: Per Kistler <kistler@inf.ethz.ch>
Subject: Saving array in Object
Message-Id: <34182208.FD540C03@inf.ethz.ch>
Hi All
How do I save an array within an object? If I do:
$self->{'data'} = \@myarray;
then I loose the contents of myarray after the method
returns. Of course I could return the array and save
it from above like:
@arr = $obj->someMethod();
but I'd like to have the array withing the object for
further use.
Thanks for help, Per.
--
Per Kistler, Unix Systems Administrator, kistler@inf.ethz.ch
http://www.cs.inf.ethz.ch/~kistler/
Swiss Federal Institute of Technology, Zuerich, Switzerland
---------------------------------------------------------------------
------------------------------
Date: 11 Sep 1997 13:22:00 +0200
From: Ronald Fischer <rovf@earthling.net>
Subject: Re: saving reg expressions
Message-Id: <xz2bu20f63r.fsf@uebemc.siemens.de>
>>>>> On Wed, 10 Sep 1997 17:40:54 GMT
>>>>> "AK" == Alex Krohn <alex@gossamer-threads.com> wrote:
AK> What I have is a search routine that can have several different
AK> options (match case, match whole word, use reg expression, or a
AK> combination of those). This same options are used throughout the
AK> search and I'm not sure if it's possible to save those options?
AK>
AK> The way my routine is running now, I have something like:
AK>
AK> foreach $field (@fields) {
AK>
AK> if ($case) {
AK> if ($reg) {
AK> $match =~ /$field/;
AK> }
AK> else {
AK> $match =~ /\Q$field\E/;
AK> }
AK> }
AK> else ...
AK>
AK> You get the idea. (In the full source, I do look for bad reg
AK> expressions etc., but the idea is the same). Now instead of going
AK> through this series of if statements (which is 3 levels deep on the
AK> full routine), to find out which options to use, is it possible to
AK> save those options somehow so I can just do:
AK>
AK> foreach $field (@fields) {
AK> $match =~ something here.. not sure what
AK> }
AK>
AK> If anyone has any ideas, how I could structure this, I'd really
AK> appreciate it!
You could, for example, write a subroutine that takes a pattern (like
your $field) and returns a modified pattern, according to your global
option settings, so you use this pattern in turn. Let's call this
sub modifiedPattern:
$modField=modifiedPattern($field);
$match =~ /$modField/;
so you have to write your cases only once. Note that this also covers
the case where you want optionally set the i-, m- or x-modifier, since
the expression
$match =~ /foo/i; # match foo case insensitive
could also be written as
$match =~ /(?i)foo/; # same as above.
--
Ronald Fischer (rovf@Earthling.net) (PGP public key available)
http://ourworld.compuserve.com/homepages/ronald_fischer/
[When posting a followup, mailing a courtesy copy is fine, provided it is
clearly marked as such.]
------------------------------
Date: Wed, 10 Sep 1997 17:46:33 -0700
From: Marty O'Brien <mobrien@cello.hp.hpl.com>
Subject: Re: shell command "more"
Message-Id: <34173F69.7FB1@cello.hp.hpl.com>
Lorenzo Pesce wrote:
>
> I have a question about how to send the output through
> more | less |whatever a pager is.
>
> I know how to:
> open (FILEHANDLE,"|more ...)
>
> but I'd like:
> open (FILEHANDLE,"|xterm ....)
> ^^^^^
> Because I'd like to send the report to an xterm.
> Hope it's not a faq.
>
> thanks in advance,
> lrnz
Well, there's always
open(FILEHANDLE,">foo");
print FILEHANDLE @report;
close FILEHANDLE;
system "xterm -e more foo";
I don't think xterm has does any (useful) processing
of standard input.
If you need to display the report at the same time
you're generating it, maybe there's some funky
mknod(1) thing you can do. (See the part in the FAQ
about determining if there's a character waiting to
be read on a file handle)
That's about the limit of my expertise, but I hope
it helped.
Marty O'Brien
HP Labs-Palo Alto
------------------------------
Date: 11 Sep 1997 09:24:15 GMT
From: tom@mitra.phys.uit.no (Tom Grydeland)
Subject: Re: Split operator
Message-Id: <slrn61fe5v.itu.tom@mitra.phys.uit.no>
On Wed, 10 Sep 1997 13:25:30 -0700, Ramesh Nagarajan <ran@sgi.com> wrote:
> Hi,
> P.S I tried to split on '\n' but the resulting array is all jumbled up.
Did you say (this is wrong!)
split '\n', $string;
Try this instead:
split /\n/, $string;
> -Ramesh
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: Thu, 11 Sep 1997 09:46:42 +0200
From: Anke Thede <anke@pan.ncrome.romesc.ibm.com>
Subject: strict-module problem
Message-Id: <34179F17.41C6@pan.ncrome.romesc.ibm.com>
To all Perl Freaks!
I have a common set of variables to be shared by different source files
in perl 5.004.
If I do the following all is OK :
perl.inc
--------
$myvar1 = "abcdef";
$myvar2 = 12345;
perlprog.pl
-----------
do 'perl.inc';
print "My include variable \$myvar1 holds $myvar1\n";
but if I want to use the 'use strict;' clause in my perlprog.pl I
correctly get an error "$myvar1 requires explicit package name ..."
because I cannot apply the my() function.
How should I correctly employ "C-like includes" in my programs without
having to cancel the "use strict" construct ???
Thank you very much. Anke.
------------------------------
Date: Thu, 11 Sep 1997 12:36:39 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: What does "regexp *+ operand could be empty" mean?
Message-Id: <341cb4f0.5674082@news.tornado.be>
bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to
"kf8nh") wrote:
>| s<\b(abc \s* = \s*) (\d* \s*)*><$1 20>x;
>> ( . . . )
>| /(abc = )(\d*\s*,?)*/: regexp *+ operand could be empty at (eval 5) line
>| 2, <IN> chunk 2.
>It's complaining about
> (\d*\s*)*
>I'd use something along the lines of:
>
> /^\s*(\w+)\s*=\s*((\d+\s+)*\d+)\s*$/
This doesn't do exactly what the original is supposed to do, relating to
backreferences. I'd simply replace
(\d*\s*)*
by
(\d+\s*)*
HTH,
Bart.
------------------------------
Date: Wed, 10 Sep 1997 09:37:02 -0500
From: Holly Sample <holiday@allmed.net>
Subject: win95 install question
Message-Id: <3416B08D.76FD7273@allmed.net>
I'm have used perl before, but always remotely, and I am now attempting
to install it on a (local) win95 machine in order to test scripts before
uploading to the win NT 4.0 server.
I've downloaded perl version 5.003_07 for win32 build 307, it's
apparently installed fine, however when I run any scripts, all my output
goes to a dos window. So how do I somehow redirect the output to appear
in my browser?
Thanks for any help someone can offer,
Nathan Stitt
nate@wavecomputers.net
------------------------------
Date: 11 Sep 1997 06:47:18 GMT
From: mgjv@mali.comdyn.com.au (Martien Verbruggen)
Subject: Re: win95 install question
Message-Id: <5v845m$os6$3@comdyn.comdyn.com.au>
In article <3416B08D.76FD7273@allmed.net>,
Holly Sample <holiday@allmed.net> writes:
> I've downloaded perl version 5.003_07 for win32 build 307, it's
> apparently installed fine, however when I run any scripts, all my output
> goes to a dos window. So how do I somehow redirect the output to appear
> in my browser?
If you want to test CGI scripts on your local machine, you will also need to
install a local web server. There are a few available, with installation
instructions from the web (try www.windows95.com). I wouldn't know which ones
are good or bad.
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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". 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 1010
**************************************