[10934] in Perl-Users-Digest
Perl-Users Digest, Issue: 4535 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 3 05:07:23 1999
Date: Sun, 3 Jan 99 02:00:21 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 3 Jan 1999 Volume: 8 Number: 4535
Today's topics:
Re: "Malform Multipart Post" <tavi367@ibm.net>
Re: Adding a path to the @INC variable <uri@home.sysarch.com>
Re: Adding a path to the @INC variable <dgris@moiraine.dimensional.com>
Re: Bug in Modulo Operator? <tchrist@mox.perl.com>
Re: Create virtual directory <design@raincloud-studios.com>
Dynamic Image Generation <alexb@ipwiz.com>
Re: Dynamic Image Generation <design@raincloud-studios.com>
faking the referer in HTTP::Request::Form <webmaster@link-maker.com>
Re: Finding elements between 2 arrays <jdf@pobox.com>
Re: Finding elements between 2 arrays <design@raincloud-studios.com>
Formatting Dates (Searching for date + 30) webmaster@entrepreneur-online.com
IIS METABASE Error during install <smiths@erols.com>
Is mod_perl an option? <smiths@erols.com>
need short delay <jupp@media-point.de>
noop <engineer@noorg.org>
Re: noop (David Formosa)
Re: noop (Tad McClellan)
Re: noop (David Formosa)
Official Perl Movie beable@my-dejanews.com
Re: Official Perl Movie <uri@home.sysarch.com>
Re: Path under windows (Ethan H. Poole)
Re: Perl Cookbook <design@raincloud-studios.com>
Re: PERL OO: Function overloading (Tony Cook)
Problem with read and eof (TheLaser)
Reading comma delimited files (Simon Fairall)
Re: regexp <grimes@waste.org>
Re: regexp <mds-resource@mediaone.net>
Re: Syntactical weirdness? Or is it just me? <tchrist@mox.perl.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 3 Jan 1999 01:16:05 -0600
From: "walter" <tavi367@ibm.net>
Subject: Re: "Malform Multipart Post"
Message-Id: <368f1932.0@news1.ibm.net>
Tony Curtis wrote in message <83vhiqrffe.fsf@vcpc.univie.ac.at>...
>Re: "Malform Multipart Post", tavi <tavi367@ibm.net>
>said:
>
>tavi> I created a script on NT p5 iis4. It seems to
>tavi> work fine but I get this error every 6 to 8
>tavi> uploads.
>tavi> Even if the file is the same or different.
>tavi> I used CGI.pm in my script.
>tavi> Any ideas?
>
>Provide some information that would help to identify
>the problem?
>
Well, I'd love to, but I don't have any more info.
My script works 80% of the time, then it fails for a time or 2 and works
again.
Even if I use the same file to send, or change files, makes no difference.
I just get this error, and I have no idea why or how to replicate it without
running the scripts several times.
Walter
------------------------------
Date: 02 Jan 1999 23:36:58 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: Adding a path to the @INC variable
Message-Id: <x7u2y9dlat.fsf@home.sysarch.com>
>>>>> "PLB" == Peter L Berghold <peter@berghold.net> writes:
PLB> BEGIN {
PLB> push(@INC,"/some/path/some/where");
PLB> }
PLB> that will work as well. I still use that method over the use
PLB> library '/some/where/over/the/rainbow' method because everything
PLB> between BEGIN{ and } gets executed before the interpreter
PLB> executes the rest of the code. I use this especially where I
so does use lib. it is basically the same thing as use lines are
executed at compile time just as BEGIN blocks are.
but use lib is more compact and descriptive so it wins over the BEGIN
method.
as a side point, you should use single quotes on fixed strings,
i.e. ones that don't need interpolation like the path above. what you
did is not syntactically wrong, just not semantically precise.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 03 Jan 1999 01:44:56 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Adding a path to the @INC variable
Message-Id: <m33e5shhiv.fsf@moiraine.dimensional.com>
"Peter L. Berghold" <peter@berghold.net> writes:
> douglas de vine wrote:
>
> > How do I add a path to the @INC variable which contains all the paths to
> > look for *pm files?
>
> Having read the answers that other folks gave on how to do this, let me also
> add one more method. If you set up something like:
>
> BEGIN {
> push(@INC,"/some/path/some/where");
> }
>
> that will work as well. I still use that method over the use library
> '/some/where/over/the/rainbow' method because everything between BEGIN{ and
> } gets executed before the interpreter executes the rest of the code.
use is a compile time effect, similar to begin. Actually
use lib '/some/path/some/where';
is almost exactly equivalent to the begin block you posted above.
They do differ semantically, though. Your method pushes the
additional directory on the end of your search path, use lib shifts
the directory onto the front of the path. A minor difference, but
hell to debug if you get bitten.
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: 3 Jan 1999 05:49:20 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Bug in Modulo Operator?
Message-Id: <76n0d0$pd4$1@csnews.cs.colorado.edu>
In comp.lang.perl.misc,
"Samuel Kilchenmann" <skilchen@swissonline.ch> writes:
:If this is "normal" Perl behavior: where can i find a
:description/specification of the differences in the precision limits
:between the modulo operator and "normal" arithmetic operations?
So long as you restrict yourself to integers whose abosulute
values are no greater than 2**31, you shouldn't have any surprises.
Beyond that, and you get get to deal with the flakinesses of floating
point numbers, which by and large, only those who took a numerical
analysis class and bothered to pay attention seem to understand.
I'm sure you'd like infinite precision arithmetic. That's remarkably
expensive, and it's not what Perl normally does.
Remember: computers don't do mathematics, and barely manage arithmetic
for very limited forms. The fault, by dear Samuel, lies not in Perl,
but in your computers.
--tom
--
PS/2 -- Half a computer
OS/2 -- Half an operating system
PS/2: Yesterday's hardware today. OS/2: Yesterday's software tomorrow
------------------------------
Date: 3 Jan 1999 04:52:50 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Create virtual directory
Message-Id: <76mt32$dt6@bgtnsc02.worldnet.att.net>
>I want to create (using a script) a virtual directory where
>/home/mydirectory/something/
>can also be read from:
>/home/mydirectory/cgi-bin/something/
>
>That way, I can call up the contents of:
>http://www.blah.com/cgi-bin/something/
>From:
>http://www.blah.com/something/
>(If anyone has a cgi-bin/cgiwrap, you may understand why I am doing
>this.
bout 27 of um.. and have no idea why you want to do this.
If you have access to the guts of the server you can just do a path alias
for Apache and be done with it. With a script... no clue. Sounds like alot
of trouble for something undefined, not to mention the security risk of
'pushing' something from the outside world into your cgi-bin.
What exactly are you trying to accomplish? Not having to type cgi-bin?
CT
------------------------------
Date: Sun, 3 Jan 1999 01:09:47 -0500
From: "Alex Blyumenkrants" <alexb@ipwiz.com>
Subject: Dynamic Image Generation
Message-Id: <76n1g6$mu2$1@winter.news.rcn.net>
Hi!
I have the following problem:
i need to create a page that dynamically generates images, like
LinkExchange,
when i put in the page
<IMG SRC="http://www.foo.com/foo.cgi?foo" > i need it to produce an image
chosen from the database based on what the query string is.
Can anyone tell me what foo.cgi should look like, can it simply print out
the name of the image?
Thank Your for Your help,
Alex
------------------------------
Date: 3 Jan 1999 09:19:30 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Dynamic Image Generation
Message-Id: <76ncn2$gn1@bgtnsc01.worldnet.att.net>
> i need it to produce an image
>chosen from the database based on what the query string is.
>Can anyone tell me what foo.cgi should look like, can it simply print out
>the name of the image?
It will be round, fuzzy and respond to the name Grimble. Seriously... you
might check out www.extropia.com and see if Selena still has his random
banner script for free. You should be able to modify that to suit your
needs.
CT
------------------------------
Date: Sun, 03 Jan 1999 02:27:00 -0700
From: jim <webmaster@link-maker.com>
Subject: faking the referer in HTTP::Request::Form
Message-Id: <368F37DD.743529DB@link-maker.com>
hi,
I need to set the http_referer in a script that uses HTTP::Request::Form.
When I dump() the script returns the base as the correct referer but
when I check the referer on the recieving end there is nothing...
I tried using HTTP::Headers, but had no luck...
Any help would be great! Thanks!!!!!
------------------------------
Date: 03 Jan 1999 09:11:29 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Finding elements between 2 arrays
Message-Id: <m3iueo7p3i.fsf@joshua.panix.com>
"Charles R. Thompson" <design@raincloud-studios.com> writes:
> for ($j=0; $j <= (@db_user_definable_field_order-1); $j++){
> if (@db_user_definable_field_order[$j] eq $index){
> $can_write = 1;
> last;
> }
> }
You have "C-programmer-converting-to-Perl-itis".
To answer your main question,
$ perldoc -f grep
If, under other circumstances, you need to iterate over the elements
of a list,
foreach my $field (@fields) {
# do something with $field
}
See
$ perldoc perlsyn
HTH, HNY.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 3 Jan 1999 08:54:37 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Finding elements between 2 arrays
Message-Id: <76nb8d$m3s@bgtnsc03.worldnet.att.net>
>You have "C-programmer-converting-to-Perl-itis".
Hehe.. never touched C... somebody else did.. copied that code... at least I
was smart enough to know something wasn't quite right. :)
>To answer your main question,
> $ perldoc -f grep
>If, under other circumstances, you need to iterate over the elements
>of a list,
> foreach my $field (@fields) {
> # do something with $field
> }
> $ perldoc perlsyn
Thanks... will take a look at them in the AM. Lots to do!
CT
------------------------------
Date: Sun, 03 Jan 1999 07:16:12 GMT
From: webmaster@entrepreneur-online.com
Subject: Formatting Dates (Searching for date + 30)
Message-Id: <76n5fs$65k$1@nnrp1.dejanews.com>
Scenario: Using the code below, I pieced together a date reminder script that
supposed to allow a visitor to enter a date and store it into a flat file
database. The third field is the $dateStamp and the line in the db looks like
this:
|1|19990101|Jan. 1, 1999|New Year's Day|
Each time the script loads, it is required to SEARCH the date.txt and see if
any particular date is within future 30 days of the current date and PRINT
that date on the resulting html in the form of a checkbox.
Problem: The script has/will print to screen dates which are from 1998 but not
from 1999. Where did I make the error and/or where can I locate information on
formatting dates?
Code:
if ($dateStamp %10000 <200)
{ $startDate = $dateStamp -8500;
}
if ($dateStamp %10000 >200)
{ $endDate = $dateStamp +8800;
}
open (Event,"<$event") || &endIt;
while ($LINE = <Event>)
{ @terms = split(/\|/,$LINE);
if ($startDate <= $terms[2] && $endDate >=$terms[2])
{ print "<LI> <INPUT TYPE=CHECKBOX NAME=\"$terms[1]\"><INPUT TYPE=hidden
NAME=\"$terms[2]\">";
print "$terms[3] -- $terms[4]";
}
}
close (Event);
Please email questions/comments to webmaster@entrepreneur-online.com.
Thank you in advance.
Sincerely,
April
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Sun, 3 Jan 1999 00:22:10 -0500
From: "The Smiths" <smiths@erols.com>
Subject: IIS METABASE Error during install
Message-Id: <76mua5$klg$1@winter.news.rcn.net>
I just installed ActiveState build 508 on Win95 with PWS but received the
IIS METABASE error during setup. Anyone have any suggestions or
work-arounds (besides switch web servers)?
Thanks,
Tim Smith
CDS Web Services, Inc.
------------------------------
Date: Sun, 3 Jan 1999 00:25:58 -0500
From: "The Smiths" <smiths@erols.com>
Subject: Is mod_perl an option?
Message-Id: <76muh8$mp2$1@winter.news.rcn.net>
I am running ActivePerl build 508 and Apache 1.3.3 on Win95. Is mod_perl an
option in this configuration? I didn't see it available as a module for
this flavor of Perl but wasn't sure.
Thanks,
Tim Smith
CDS Web Services, Inc.
------------------------------
Date: 3 Jan 1999 09:24:15 GMT
From: "jupp" <jupp@media-point.de>
Subject: need short delay
Message-Id: <01be36fa$a8c41820$b7eb63c1@dietmar>
Hi, does anybody know a short delay, so around 200-500 ms instead of the
unprecise Sleep 1 ?
Or has anybody a better idea how to deal with the fast networks ?
Thanks Dietmar
------------------------------
Date: Sun, 03 Jan 1999 00:34:40 -0500
From: EVILjosh <engineer@noorg.org>
Subject: noop
Message-Id: <368F0170.715D6D96@noorg.org>
Hi folks,
Is there any kind of a noop keyword in Perl?
Thank you.
Yours,
Josh...
_/_/_/ _/ _/ _/ _/
_/_/ _/ _/ _/ _/
_/_/_/ _/ _/ _/_/
------------------------------
Date: 3 Jan 1999 07:22:08 GMT
From: dformosa@zeta.org.au (David Formosa)
Subject: Re: noop
Message-Id: <slrn78u6l0.56d.dformosa@godzilla.zeta.org.au>
In article <368F0170.715D6D96@noorg.org>, EVILjosh wrote:
>Hi folks,
>
>Is there any kind of a noop keyword in Perl?
>Thank you.
Well this (untested) module would help. Neat thing, if you tie it to a file
handel its sort out like /dev/null
package Noop;
require Exporter;
@ISA=qw(Exporter);
@EXPORT = qw (noop);
sub noop {};
sub AUTOLOAD {
my $proto=shift;
if (not ref $proto) {
my $class=$proto;
my $self=undef;
return bless \$self,$class;
}
};
--
Please excuse my spelling as I suffer from agraphia. See
http://www.zeta.org.au/~dformosa/Spelling.html to find out more.
How to win arguments on usenet http://www.zeta.org.au/~dformosa/usenet.html
------------------------------
Date: Sun, 3 Jan 1999 01:39:20 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: noop
Message-Id: <8r6n67.9vj.ln@magna.metronet.com>
EVILjosh (engineer@noorg.org) wrote:
: Is there any kind of a noop keyword in Perl?
Perl is a high level language, I cannot imagine why you need
a do-nothing placeholder like NOOP is in assembler.
What is it that you want to accomplish?
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 3 Jan 1999 08:28:52 GMT
From: dformosa@zeta.org.au (David Formosa)
Subject: Re: noop
Message-Id: <slrn78uai4.56d.dformosa@godzilla.zeta.org.au>
In article <8r6n67.9vj.ln@magna.metronet.com>, Tad McClellan wrote:
>EVILjosh (engineer@noorg.org) wrote:
>
>: Is there any kind of a noop keyword in Perl?
>
>
> Perl is a high level language, I cannot imagine why you need
> a do-nothing placeholder like NOOP is in assembler.
Sometimes noop is usefull to say "I'm going to code this but not yet."
when testing stubbly code.
--
Please excuse my spelling as I suffer from agraphia. See
http://www.zeta.org.au/~dformosa/Spelling.html to find out more.
How to win arguments on usenet http://www.zeta.org.au/~dformosa/usenet.html
------------------------------
Date: Sun, 03 Jan 1999 06:27:57 GMT
From: beable@my-dejanews.com
Subject: Official Perl Movie
Message-Id: <76n2lc$3vg$1@nnrp1.dejanews.com>
I was watching "Lawrence of Arabia" the other day. I think
this should be the official movie for Perl. I NEVER SAW SO
MANY BLLEDIN' CAMELS! It seems that camels are slower than
horses in a cavalry charge. But they can go nearly three
weeks without any water. REMEMBER TO WATER YOUR CAMEL AT
LEAST EVERY THREE WEEKS OR IT WILL DIE!!!1! Also, does
everybody agree that Laurence Olivier put in his finest
movie performance EVER as Lawrence of Arabia in this
movie? I think he really deserved that Oscar he won for
this screen gem.
cheers
beable van beable
--
Beable, you moron. That was a FAKE Captain Picard you were arguing with
before. -- Riboflavin
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 03 Jan 1999 01:54:40 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: Official Perl Movie
Message-Id: <x7ogogethr.fsf@home.sysarch.com>
followups set to c.l.p.misc (what did this have to do with kibology?)
>>>>> "b" == beable <beable@my-dejanews.com> writes:
b> everybody agree that Laurence Olivier put in his finest
b> movie performance EVER as Lawrence of Arabia in this
b> movie? I think he really deserved that Oscar he won for
b> this screen gem.
s/laurence olivier/peter o'toole/ ;
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Sun, 03 Jan 1999 04:18:30 GMT
From: ehpoole@ingress.com (Ethan H. Poole)
Subject: Re: Path under windows
Message-Id: <qcCj2.3811$P52.19398@news15.ispnews.com>
In article <76lciq$vi$1@gellyfish.btinternet.com>,
gellyfish@btinternet.com says...
>
>On Sat, 02 Jan 1999 08:13:30 GMT Ethan H. Poole wrote:
>>
>Of course some object that CGI.pm is a little oversized for some purposes
>but there are alternatives in the various CGI::* modules available.
>I thought that the purpose of CPAN was to promote code reuse on the
>grand scale.
Speaking personally, I tend to prefer to use my own code (and be responsible
for its maintenance and any future bugs... I hate depending on an external
module only to have a new version released with a bug that makes it look like
bad programming on my part <g>). It gives me total revision control (and a
singular point of responsibility).
As for my own avoidance of CGI.pm, the bloating is reason #1. I used the
CGI.pm module back in my earlier days of learning Perl and found that
virtually all my scripts spent more time loading and compiling just the
CGI.pm module than they did compiling and executing my code, the performance
hit just wasn't acceptable to me.
But I do strongly encourage reuse of tested code for beginners, it saves
people from a lot of "shooting oneself in the foot" scenerios! Even I use
*some* CPAN modules, it really depends on whether I like the way they were
implemented, their features, etc. If I don't like something, I just write my
own.
--
Ethan H. Poole | Website Design and Hosting,
| CGI Programming (Perl & C)..
========Personal=========== | ============================
* ehpoole @ ingress . com * | --Interact2Day--
| http://www.interact2day.com/
------------------------------
Date: 3 Jan 1999 04:37:48 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Perl Cookbook
Message-Id: <76ms6s$8ps@bgtnsc02.worldnet.att.net>
>Hey, I dont even have a shelf for them, they're just creeping up the side
>of the chair and now I've got the 'sendmail' book back from the office
>they're threatening to take over the whole room.
If I was a semi-intelligent being I would see a business opportunity here.
"Ergonomic Reclining Computer Chair"
made from 100% post-high-tech systems manuals, how-to books & computer
catalogs.
:)
CT
------------------------------
Date: 3 Jan 1999 07:10:12 GMT
From: tony@ns.cook.ml.org (Tony Cook)
Subject: Re: PERL OO: Function overloading
Message-Id: <76n54k$71l$1@ns.cook.ml.org>
Zenin (zenin@bawdycaste.org) wrote:
: [posted & mailed]
: hoangngo@usa.net wrote:
: : Can anyone out here tell me if PERL offers function overloading?
: No. There is no need for it in Perl (and it's not "PERL" btw, it's
: not an acronym. Would you call it "JAVA" too?).
Hmm, I though it was an acronym...
bash$ perldoc -t perl | head -2
NAME
perl - Practical Extraction and Report Language
bash$ perldoc -t perl | tail
Perl actually stands for Pathologically Eclectic Rubbish Lister, but
don't tell anyone I said that.
NOTES
The Perl motto is "There's more than one way to do it." Divining how
many more is left as an exercise to the reader.
The three principal virtues of a programmer are Laziness, Impatience,
and Hubris. See the Camel Book for why.
bash$
------------------------------
Date: Sun, 03 Jan 1999 08:15:53 GMT
From: prjohnsonat@utahlinxdot.com (TheLaser)
Subject: Problem with read and eof
Message-Id: <368f2603.10493424@209.66.79.182>
I'm very new to perl and am having trouble with the read function. I seem
to be hitting eof too early (only 131 bytes in for a 430 byte file, 155
bytes in for a 20473 byte file). I'm using read(SOURCE,$in,1); to get the
file one byte at a time inside a while loop. If if matters I'm running
perl under win95. Anybody seen this before?
--
TheLaser <prjohnson at utahlinx dot com>
------------------------------
Date: Sun, 03 Jan 1999 08:59:17 GMT
From: Simon.Fairall@hpa.com.au (Simon Fairall)
Subject: Reading comma delimited files
Message-Id: <368f3036.2927802145@news>
I was wondering whether anyone had written a script to parse comma
delimited files (csv format) as from Microsoft Excel (yuk!).
The problem of using :-
while ($Line = <INFILE>) {
@FieldList = split (/,/, $line);
}
to seperate the fields is that a text field (delimited by "") could
legally contain a comma.
I would appreciate some insight from all you Perl guru's and hackers
on how to solve this problem.
------------------------------
Date: Sat, 2 Jan 1999 23:47:10 -0600
From: Peter Grimes <grimes@waste.org>
Subject: Re: regexp
Message-Id: <Pine.LNX.3.96.990102234359.11563E-100000@waste.org>
On Sat, 2 Jan 1999, Staffan Liljas wrote:
> If you have
>
> $path = "c:\whatever\whatever\whatever\image.gif";
>
> do
>
> $path = ( $path =~ /([^\\]+)$/ );
There is a problem with this though. If
$path = "c:\whatever\whatever\image.gif\n";
This it will also match the newline (or anything else after .gif for that
matter).
I'd suggest modifying it a bit to be
$path = ( $path =~ /([^\\\s]+)$/ );
which excludes all the whitespace characters as well. Of course if your
filesystem supports spaces in file names that's a problem so you could do
$path = ( $path =~ /([^\\\n\r]+)$/ );
And probably be pretty safe on any filesystem that uses backslashes (that
I know of, at least).
-Dave
------------------------------
Date: Sun, 03 Jan 1999 01:15:00 -0600
From: "Michael D. Schleif" <mds-resource@mediaone.net>
Subject: Re: regexp
Message-Id: <368F18F4.58510E62@mediaone.net>
I fail to see how that is simpler than:
my $path = 'c:\whatever\whatever\whatever\image.gif';
$path =~ s!.*\\!!;
print $path, "\n";
Peter Grimes wrote:
>
> I'd suggest modifying it a bit to be
>
> $path = ( $path =~ /([^\\\s]+)$/ );
>
> which excludes all the whitespace characters as well. Of course if your
> filesystem supports spaces in file names that's a problem so you could do
>
> $path = ( $path =~ /([^\\\n\r]+)$/ );
--
Best Regards,
mds
mds resource
888.250.3987
"Dare to fix things before they break . . . "
"Our capacity for understanding is inversely proportional to how much we
think we know. The more I know, the more I know I don't know . . . "
------------------------------
Date: 3 Jan 1999 05:31:13 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Syntactical weirdness? Or is it just me?
Message-Id: <76mvb1$p29$1@csnews.cs.colorado.edu>
In comp.lang.perl.misc, tadmc@metronet.com (Tad McClellan) writes:
: The lesson is to understand the difference between
: scalar and list context.
: print scalar reverse($string);
In this case, you're ok. But there's still more to learn.
I present this from the perl quiz.
--tom
Question: How do you print out the next line from a filehandle
with all its bytes reversed?
Type: I/O, Built-in Functions, Context
Difficulty: 5/7
Answer: print reverse <FH>
Correct: No.
Why: That reads all lines in FH, then reverses that list of
lines and passes the resulting reversed list off to print.
This is actually a very useful thing, and simulates
`tail -r' behavior but without the annoying buffer
limitations of that utility. Nonetheless, it's not
what we want for an answer to this question.
Answer: print reverse scalar <FH>
Correct: No.
Why: Although `scalar <FH>' did retrieve just the next line,
the reverse is still in the list context imposed on it by
print, so it takes its list of one element and reverses
the order of the list, producing exactly the next line.
An expensive way of writing `print scalar <FH>'.
Answer: print scalar reverse <FH>
Correct: No.
Why: Although the first use of scalar inhibits the list context
being imposed on reverse by print, it doesn't carry through
to change the list context that reverse is imposing on <FH>.
So reverse catenates all its arguments
and does a byte-for-byte flip on the resulting string.
Answer: print scalar reverse scalar <FH>
Correct: Yes.
Why: Surprisingly enough, you have to put both the reverse and
the <FH> into scalar context separately for this to work.
--
X-Windows: Warn your friends about it.
--Jamie Zawinski
------------------------------
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 4535
**************************************