[7255] in Perl-Users-Digest
Perl-Users Digest, Issue: 880 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 16 21:07:17 1997
Date: Sat, 16 Aug 97 18:00:22 -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 Sat, 16 Aug 1997 Volume: 8 Number: 880
Today's topics:
Re: "Powered by Perl" logo found. Details inside. (Viper)
Re: Chomp and chop <rootbeer@teleport.com>
Content-Type: "JAVASCRIPT"??? <msears@cnnet.com>
Help with Perl Regular Expressions jaltuve@ibm.net
How do I create a directory and then create a directory (Drake Raft)
Re: How do I create a directory and then create a direc <rootbeer@teleport.com>
Re: How do you determine program runtime? (Scott Houck)
Re: HTML Help For All (Joe McCaughan)
Installing external modules (Eric Penn)
Re: Installing external modules <eekim@eekim.com>
Re: Is this a permissions problem? <rootbeer@teleport.com>
Re: newbie cgi question. <rootbeer@teleport.com>
Re: Passing an argument to a Perl SSI problem <henrywolff@hatsoftnevada.lovelock.nv.us.nospam>
Re: Pattern matching problem <rootbeer@teleport.com>
Perl 5.004 and dbmopen <marv@home.dwave.net>
Re: Perl 5.004 and dbmopen <rootbeer@teleport.com>
Perl works... <rootbeer@teleport.com>
Re: proxy problem in perl <rootbeer@teleport.com>
Re: Q: find my own IP address, not 127.0.0.1 <rootbeer@teleport.com>
Re: splice (Scott Houck)
Substitution string problem (EboshiMan)
Re: Substitution string problem (Mike Stok)
Re: Substitution string problem <justinb@springer.cray.com>
Re: TMTOWTDI-- can you find another? (Ken Fox)
What is this EOF error? (Hedin Meitil)
Re: What is this EOF error? (Eric Bohlman)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 16 Aug 1997 20:35:41 GMT
From: lord_viper@mailrunner.net (Viper)
Subject: Re: "Powered by Perl" logo found. Details inside.
Message-Id: <33f60ed4.63157076@news.accesscom.net>
On Thu, 14 Aug 1997 17:11:55 GMT, danew@enterprise.net (Matthew
Burnham) scribbled these simple words:
|"Richard K. Downer" <rkd7949@ballard.ca.boeing.com> wrote:
|
|>Hmmmm.... It says on this web site that "O'Reilly said we can't use
|>camels on this site... So we use Rhinos." How many people think of Perl
|>when they see a Rhino?
|How many people WANT to think of Perl when they're on Safari, whatever
|animal it is they can see? ;)
Funny thing about owing a trademark, you get to control it. The idea
is not to associate the image with Perl, just something to put in it's
place. Sorry you couldn't think that far...
----------------------------------------------------------------------
Note: Remove underscores from email addresses when replying via email.
------------------------------
Date: Sat, 16 Aug 1997 08:37:14 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Nadim <nrana@aludra.usc.edu>
Subject: Re: Chomp and chop
Message-Id: <Pine.GSO.3.96.970816083423.29772G-100000@julie.teleport.com>
On 15 Aug 1997, Nadim wrote:
> Could anyone let me know the difference between chomp and chop?
Is the perlfunc(1) manpage somehow lacking for you? If you need more than
what it says, please ask again.
> I am trying to use chomp in my script but it is not getting compiled.
> Why?
Because you're doing something wrong. :-) If you can show us a short
script (say, half a dozen lines) which doesn't do what you expect, we can
try to realign your expectations. :-)
$foo = "12345\n";
chomp($foo);
print "It's now only ", length($foo), " characters long.\n";
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 16 Aug 1997 15:34:36 -0600
From: Mark Sears <msears@cnnet.com>
Subject: Content-Type: "JAVASCRIPT"???
Message-Id: <33F61CEC.54D23F7@cnnet.com>
I am doing a bit of game/contest thing here and I am using Perl to keep
a record of the entrants. If they have already played today then they
are unable to again.
After I determine this I want to:
- open a new window with the game (if they havent' played yet today)
- send them a reject html page (if they have)
Is there something like Content-Type: javascript?!?!
Or can my problem be solved a better way?
Thanks,
Mark Sears
------------------------------
Date: Sat, 16 Aug 1997 17:35:54 -0600
From: jaltuve@ibm.net
Subject: Help with Perl Regular Expressions
Message-Id: <871769793.23010@dejanews.com>
Given the following expression:
if ($A =~ /$Keyword/i)
the /i flag will ignore Upper Case, so it doesn't matter if $Keyword is
BUs or bus, my question is: it is posible to use a search string like
'cancion' but make it match 'cancisn' in my Database File?
Input: cancion
Output: cancion (But make it MATCH string 'cancisn'
I'm asking you this because if it is possible to make Bus an BUS match
with just a flag maybe there's another flag for making "cancion" and
"cancisn" match.
TIA,
Jesus Altuve
EMSCA, Caracas - Venezuela
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 16 Aug 1997 21:28:16 GMT
From: drake-@email.unc.edu (Drake Raft)
Subject: How do I create a directory and then create a directory within that directory?
Message-Id: <5t561g$psq$1@fddinewz.oit.unc.edu>
#!/usr/local/bin/perl
mkdir(etc,"/etc1/etc2")
I'm looking to create a directory named etc2 within a directory named
etc1, but this doesn't seem to work. How would I go about doing this?
Do I create one, and then somehow switch into it?
Please email me at mcgucken@physics.unc.edu if you know how I might do
this. Thanks a lot, Elliot
------------------------------
Date: Sat, 16 Aug 1997 16:07:27 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Drake Raft <drake-@email.unc.edu>
Subject: Re: How do I create a directory and then create a directory within that directory?
Message-Id: <Pine.GSO.3.96.970816160305.7583I-100000@julie.teleport.com>
On 16 Aug 1997, Drake Raft wrote:
> I'm looking to create a directory named etc2 within a directory named
> etc1, but this doesn't seem to work. How would I go about doing this?
Create them one at a time. Be sure to check for an error return from
mkdir. The message explaining failure will be in the magical $! variable.
See the perlfunc and perlvar manpages for more details. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 16 Aug 1997 22:17:56 GMT
From: scott@radix.net (Scott Houck)
Subject: Re: How do you determine program runtime?
Message-Id: <33f726cd.81547078@news1.radix.net>
danew@enterprise.net (Matthew Burnham) wrote:
>In a similar vein, is there a way to stop a program after x minutes (or
>seconds).
Use Expect. It includes a script called timed-run that does just
that.
------------------------------
Date: 16 Aug 1997 19:21:26 GMT
From: shiloh@best.com (Joe McCaughan)
Subject: Re: HTML Help For All
Message-Id: <5t4ujm$q4v$1@nntp2.ba.best.com>
This is a nice service. I really like your helpful,
friendly attitude too! It seems to be rare around here
sometimes...
thanks for doing this!
--Joe McCaughan | The fear of the Lord is the beginning of knowledge,
shiloh@best.com | But fools despise wisdom and instruction. Proverbs 1:7
Kay and Chris Richards (rubyo@access.usa.net) wrote:
: Hi Everyone,
: If you need help with any Net related problem (eg: CGI,
: Java, JScript, Perl, C++, browser problems, web page problems - anything
: at all) - HTML Help For All (HHFA) - is sure to be of help to you. We
: offer a mailing list, help form, help forum, resources and much more. HHFA
: caters to ALL user levels so no matter how new or old you are to the Net
: we can still help you.
: You can find all the above at -
: http://rdz.stjohns.edu/~hhfa/
: I hope you enjoy the free service. Enjoy!.
: Regards,
: Chris Richards
: (mailto:MrFixIt@WriteMe.Com)
------------------------------
Date: Fri, 15 Aug 1997 00:40:29 GMT
From: stupid@wco.com (Eric Penn)
Subject: Installing external modules
Message-Id: <33f292f7.251152915@news.wco.com>
On 08 Aug 1997 11:34:32 -0700, Eugene Kim <eekim@eekim.com> wrote:
>stupid@wco.com (Eric Penn) writes:
>
>> 4. How can I install third party Perl modules?
>
>Create two subdirectories: arch and lib (or whatever you want to call
>them). Put the C modules in the arch subdirectory, and the Perl
>modules in the lib directory. Then add both subdirectories to the
>@INC variable (or use "use libs").
>
>If you are installing a module from CPAN, you can modify the
>Makefile.PL to install in your local directory for you. For example,
>if your home directory is /home1/s/stupid, create the following
>subdirectories:
>
> perl/arch
> perl/bin
> perl/man1
> perl/man3
> perl/lib
>
>In the class MakeMakeFile in Makefile.PL, add the following variables:
>
> INSTALLDIRS => 'perl',
> INSTALLARCHLIB => '/home1/s/stupid/perl/arch',
> INSTALLBIN => '/home1/s/stupid/perl/bin',
> INSTALLMAN1DIR => '/home1/s/stupid/perl/man1',
> INSTALLMAN3DIR => '/home1/s/stupid/perl/man3',
> INSTALLPRIVLIB => '/home1/s/stupid/perl/lib'
>
>Then just go through the installation process. For some modules, you
>might have to do some additional tweaking.
In the interest of making things a bit more general, I added
use Config;
to the top of the Makefile.PL (for access to the various configuration
stuff) and then insterted the following into the class definition:
INSTALLDIRS => 'perl',
INSTALLARCHLIB => "$ENV{HOME}/MODULES/$Config{archname}",
INSTALLBIN => '"$ENV{HOME}/MODULES",
INSTALLMAN1DIR => "$ENV{HOME}/MODULES/man1",
INSTALLMAN3DIR => '$ENV{HOME}/MODULES/man3",
INSTALLPRIVLIB => '$ENV{HOME}/MODULES"
That way, both module and the auto-load stuff end up getting seen with a
simple
use lib "$ENV{HOME}/MODULES";
However, when I install MLDBM (which requires Data::Dumper to be previously
installed) it fails on the 'make test' step. Looking that the rather
cryptic error message it appears that it is trying to use the Data::Dumper
in the test process. And since Data::Dumper is installed in a non-system
library location (ie: it lives in $ENV{HOME}/MODULES) the test fails. How
can I tell the Makefile to use this "extra" library path?
--
Eric Penn STUPID's three rules to life:
stupid@wco.com Stick with what you're good at,
http://www.wco.com/~stupid/ Learn from your mistakes, and
"stoo" When in doubt, act stupid!
------------------------------
Date: 15 Aug 1997 00:47:52 -0700
From: Eugene Kim <eekim@eekim.com>
Subject: Re: Installing external modules
Message-Id: <xt0pvrf28gn.fsf@shell.wco.com>
stupid@wco.com (Eric Penn) writes:
> However, when I install MLDBM (which requires Data::Dumper to be previously
> installed) it fails on the 'make test' step. Looking that the rather
> cryptic error message it appears that it is trying to use the Data::Dumper
> in the test process. And since Data::Dumper is installed in a non-system
> library location (ie: it lives in $ENV{HOME}/MODULES) the test fails. How
> can I tell the Makefile to use this "extra" library path?
The tests are just perl scripts -- usually either a file called
test.pl, or a bunch of tests in the t subdirectory. If you add the
proper 'use lib' line to these test scripts, the tests should work.
-Eugene
--
Eugene Eric Kim | "There is nothing new in the world except the history
eekim@eekim.com | you do not know." --Harry S Truman
------------------------------
Date: Sat, 16 Aug 1997 08:42:29 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Henry Wolff <henrywolff@hatsoftnevada.lovelock.nv.us.nospam>
Subject: Re: Is this a permissions problem?
Message-Id: <Pine.GSO.3.96.970816084022.29772H-100000@julie.teleport.com>
On 15 Aug 1997, Henry Wolff wrote:
> But when I call it from the HTML page like
> <!--#exec cgi="cgi/ad.cgi?pege" -->
> it gives me an error processing this directive.
It looks as if you have an invalid SSI tag. To find out, check with your
server's docs and FAQs, or those of a newsgroup about servers. Hope this
helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 16 Aug 1997 08:30:13 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: ray <raymond@sj.bigger.net>
Subject: Re: newbie cgi question.
Message-Id: <Pine.GSO.3.96.970816082915.29772F-100000@julie.teleport.com>
On Fri, 15 Aug 1997, ray wrote:
> I am having problems in trying to use cgi.pm to get the selected list of
> items from a list created in a form for html. The list was created as a
> scrolling list with MULTIPLE added to its tag. However, when I call
>
> $query = new CGI();
> $x = $query->param($listName);
>
> then $x only contains the first selected item from the list.
How could it have more than one? It's only a single scalar, not a list.
(Hint, hint!) If you need more information, the docs for CGI.pm are
astoundingly complete. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 16 Aug 1997 23:30:12 GMT
From: "Henry Wolff" <henrywolff@hatsoftnevada.lovelock.nv.us.nospam>
Subject: Re: Passing an argument to a Perl SSI problem
Message-Id: <01bcaa9b$db30ea00$b11de4cf@hatsoftnevada.lovelock.nv.us>
Tom Phoenix wrote in article
> On 15 Aug 1997, Henry Wolff wrote:
>
> > But when I call it from the HTML page like
> > <!--#exec cgi="cgi/ad.cgi?pege" -->
> > it gives me an error processing this directive.
>
> It looks as if you have an invalid SSI tag. To find out, check with your
> server's docs and FAQs, or those of a newsgroup about servers. Hope this
> helps!
I am not sure on what you mean by the invalid SSI tag. If I leave off the
?pege the script runs just fine as an SSI and from all I have been able to
find out on this through many FAQ's and docs, it has something to do with
the server not being set up to or allowing variables on SSI URI/URL command
lines. If I do it as an HTML link, <a href="cgi/ad.cgi?pege">Click me</a>,
it works just fine and parses correctly. But when I try to run it as an
SSI, it doesn't work (unable to process this directive error).
Unfortunately the people I have talked to at my ISP don't know anything
about it either and the ONE person who might is on vacation for the next 2
weeks :(. I have to find out myself how they need to fix it and then tell
them, the price for living in the boonies I guess.
Is there any other way to pass an argument to an SSI Perl Script? Any help
or suggestions would be appreciated.
Thanks,
Henry Wolff
Star Trek Collectibles Trading Post
Free4All Classifieds, Clipart, Animations, Sounds, Fonts, Pictures and
more...
http://www.hatsoft.com/newtrek/index.html
------------------------------
Date: Sat, 16 Aug 1997 08:28:24 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Aaron Sherman <ajs@lorien.ajs.com>
Subject: Re: Pattern matching problem
Message-Id: <Pine.GSO.3.96.970816082039.29772E-100000@julie.teleport.com>
On 15 Aug 1997, Aaron Sherman wrote:
> Tom Phoenix <rootbeer@teleport.com> wrote:
> >On 12 Aug 1997, CPT wrote:
> >
> >> if ($_ =~ /$dept/) {
> >
> > A badly-formed regular expression could crash your program.
> I should point out that "crash" is probably the wrong word. Perl will
> give you an error, and exit, but it does nto crash per se, if you, say,
> have unbalanced parens in the regex.
Okay, I should have said that it could make Perl bail, or exit early, or
upchuck. :-)
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 16 Aug 1997 22:09:02 GMT
From: Marvin Malkowski Jr. <marv@home.dwave.net>
Subject: Perl 5.004 and dbmopen
Message-Id: <5t58du$gm9$1@darla.visi.com>
I was writing this program under perl 5.004 and was forced to updrade to 5.004.
Now my scripts when I do the dbmopen creates two files links.dbm.dir and links.dbm.pag
and I have no clue why.
Listed below is my code:
$database="/home/halogen/scripts/links.dbm";
$textfile="/home/halogen/scripts/database";
#///////////////////////////////////////////////////////////////////////////////////
sub createdatabase
{
#//Assign variables names
open(FILEHANDLE, $textfile);
dbmopen (%links, $database, 0666) or die;
$count=1;
while(<FILEHANDLE>)
{
($sitename,$linkname,$desc,$name,$emailcontact,$location,$valid) = split(/\|/, $_);
print "$sitename,$linkname,$desc,$name$emailcontact,$location,$valid\n";
$links{$count} = "${sitename}|${linkname}|${desc}|${name}|${emailcontact}|${location}|${valid}";
$count++;
}
close %links;
}
Anyone have a clue, what I should do different or what is wrong?
Please respond to marv@dwave.net, thanks
------------------------------
Date: Sat, 16 Aug 1997 16:10:18 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Marvin Malkowski Jr." <marv@home.dwave.net>
Subject: Re: Perl 5.004 and dbmopen
Message-Id: <Pine.GSO.3.96.970816160752.7583J-100000@julie.teleport.com>
On 16 Aug 1997, Marvin Malkowski Jr. wrote:
> I was writing this program under perl 5.004 and was forced to updrade to
> 5.004.
That's the least painful upgrade to version 5.004 that there is. :-)
> Now my scripts when I do the dbmopen creates two files links.dbm.dir and
> links.dbm.pag and I have no clue why.
I think the entry on dbmopen in the perlfunc(1) manpage will explain why
that happens. But maybe you want to use tie (documented in the same
manpage) to open a different kind of database file.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 16 Aug 1997 15:52:21 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Zenin <zenin@best.com>
Subject: Perl works...
Message-Id: <Pine.GSO.3.96.970816155141.7583H-100000@julie.teleport.com>
On 16 Aug 1997, Zenin wrote:
> Perl works under Win32, but it doesn't like it.
Me too!
:-)
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 16 Aug 1997 08:12:12 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Xu Chu <xuchu@iscs.nus.edu.sg>
Subject: Re: proxy problem in perl
Message-Id: <Pine.GSO.3.96.970816081100.29772D-100000@julie.teleport.com>
On 16 Aug 1997, Xu Chu wrote:
> The university uses a proxy and everything has to pass thru it... i
> think there must be a way in the CPAN LWP module to handle it but i cant
> find it out:(
Don't you find the answer in the LWP docs? Look for the word 'proxy' and I
think you'll see the answer soon. (If not, maybe you have a very old
version of LWP.) Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 16 Aug 1997 15:24:31 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Michael W. J. West" <mwest@nyx.cs.du.edu>
Subject: Re: Q: find my own IP address, not 127.0.0.1
Message-Id: <Pine.GSO.3.96.970816152024.7583E-100000@julie.teleport.com>
On 15 Aug 1997, Michael W. J. West wrote:
> How can I use perl to figure out my (single session ISP-assigned PPP)
> IP address as known to the outside world? (This is needed so that the
> outside world can contact my Apache server when I am on-line.)
If you're writing a CGI script, you may wish to check out what the CGI
specification says about the SERVER_NAME environment variable.
http://hoohoo.ncsa.uiuc.edu/cgi/env.html
(Not to get on your case, but this may not be, strictly speaking, a Perl
question. It's not Perl-specific, at least, since the same techniques
would be used with other languages.) Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 16 Aug 1997 22:10:15 GMT
From: scott@radix.net (Scott Houck)
Subject: Re: splice
Message-Id: <33f624cf.81037455@news1.radix.net>
Um, why not just use grep?
@aliasfile = grep !/test/, @aliasfile;
------------------------------
Date: Sat, 16 Aug 1997 20:16:21 GMT
From: jkhowes@mindspring.com (EboshiMan)
Subject: Substitution string problem
Message-Id: <33f609c0.18624396@news.mindspring.com>
I have a slight problem. Here is the code in question:
$html =~ s/"/\"/g;
What I want this code to do is search a string for a double-quote (")
character and replace it with a double-quote character (") preceded by
a backslash (\). I haven't tried it out yet, but I have the feeling
this isn't the right way to do it. What needs to be escaped, if
anything, and how will I go about doing that? Please help!
#####################################################
EboshiMan - J.K. Howes
Eboshi, the best Square town on the Net!
http://www.dragonfire.net/~Chocobo/
#####################################################
------------------------------
Date: 16 Aug 1997 20:31:32 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Substitution string problem
Message-Id: <5t52n4$nia@news-central.tiac.net>
In article <33f609c0.18624396@news.mindspring.com>,
EboshiMan <jkhowes@mindspring.com> wrote:
>I have a slight problem. Here is the code in question:
>
>$html =~ s/"/\"/g;
>
>What I want this code to do is search a string for a double-quote (")
>character and replace it with a double-quote character (") preceded by
>a backslash (\). I haven't tried it out yet, but I have the feeling
>this isn't the right way to do it. What needs to be escaped, if
>anything, and how will I go about doing that? Please help!
Close, you probably want
$html =~ s/"/\\"/g;
as the \ in your example is considered an escape for the " in the right
hand side of the s/// command.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 16 Aug 1997 18:26:29 -0500
From: Justin Banks <justinb@springer.cray.com>
Subject: Re: Substitution string problem
Message-Id: <o8nzpqhzp3u.fsf@springer.cray.com>
jkhowes@mindspring.com (EboshiMan) writes:
> I have a slight problem. Here is the code in question:
>
> $html =~ s/"/\"/g;
>
> What I want this code to do is search a string for a double-quote (")
> character and replace it with a double-quote character (") preceded by
> a backslash (\). I haven't tried it out yet, but I have the feeling
> this isn't the right way to do it. What needs to be escaped, if
> anything, and how will I go about doing that? Please help!
>
Try $html =~ s/"/\\"/g; (note the extra backslash)
You can try things like this out on the command line, BTW :
springer<justinb>215% perl5
$html = "\"bleen\"";
$html =~ s/"/\\"/g;
print $html;
(^D)
\"bleen\"
--
Justin Banks \ I ignore spam from the following domains
Silicon Graphics \ mail.t-net.com nevwest.com
Eagan, Minnesota \ worldnet.att.net, glenfinnan.com,
612.683.7356 \ hotmail, jobspc, 1stfamily, email-man
\ savetrees, primenet, t-1net, m-group.com
------------------------------
Date: 16 Aug 1997 23:26:37 GMT
From: fox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: TMTOWTDI-- can you find another?
Message-Id: <5t5cvd$rqo1@eccws1.dearborn.ford.com>
twheeler@m-net.arbornet.org (T. Wheeler) writes:
> Perl's motto is 'There's more than one way to do it,' and I am sure I
> haven't found the best way.
I'd rather do it in a way that doesn't require reading through the
whole file just to get to the tip of the day. Probably the best way
to do this is with a lightweight persistent hash table, i.e. one of
the dbm modules. Another decent solution is just to store each tip
in its own file. Something like this:
> # Tip of the day script (perl_win32)
> #
> # Tom Wheeler 8/5/97
> #
> # Pull a tip from the file tips.txt
> # based on the current date and put
> # that tip on a Web page.
> #
> # Thus we need at least 31 tips.
> #
> # Also, we must replace tiplist.txt
> # each month
> # ---------------------------------------------
> # Start printing HTTP header to client
> #
> print "Content-type: text/html\n\n";
> print "<HTML><HEAD><TITLE>Tip of the day</TITLE></HEAD>\n";
Everything up to this next section is fine.
> open (TIPLIST, "$fpath") || die "can't open tiplist.txt: $! \n";
> while ($line = <TIPLIST>)
> {
...
> }
Replace that whole block with something like:
my $filename = "c:\\perl\\tiplist\\" . $mday;
if (open(TIP, $filename)) {
my $name = <TIP>; chomp($name);
my $version = <TIP>; chomp($version);
print "<FONT SIZE=3>\n";
print "<B>$name, Version(s) $version:</B><P>\n";
print "<FONT SIZE=2>\n";
while (<TIP>) {
print $_;
}
close(TIP);
}
else {
print "<B>Sorry, we're fresh out of tips today.</B>\n";
}
If you time the script, you should find that this one runs a lot
faster because it does less work to accomplish the same job. This
will make a *huge* difference on a busy web server.
One other thing to watch out for when writing CGI scripts is to
make sure that the script always returns something useful to the
reader. In your case, if the tip file isn't found, the script
just dies. This leaves your reader with a partial document and
she doesn't know what happened.
By the way, why so Windows-centric? Do you care that much that
the font type is 'Arial'? Don't you know that's just a Microsoft
ploy to keep people from realizing that they're really just using
a poor copy of Helvetica? :-)
Hope this helps.
P.S. I replied to the author a couple days back, but it bounced (twice).
--
Ken Fox (kfox@ford.com) | My opinions or statements do
| not represent those of, nor are
Ford Motor Company, Powertrain | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section | "Is this some sort of trick
| question or what?" -- Calvin
------------------------------
Date: Fri, 15 Aug 1997 11:43:39 GMT
From: hm@royal.net (Hedin Meitil)
Subject: What is this EOF error?
Message-Id: <33f43fd1.12497543@news.dknet.dk>
When I run the script below, I get the error message "EOF in string at
hellow.pl line 5." Why?
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print <<endHTML; # This is line 5
<html><head></head>
<body>
<p>
Hello World!
</body>
</html>
endHTML
------------------------------
Date: Sat, 16 Aug 1997 18:34:15 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: What is this EOF error?
Message-Id: <ebohlmanEF0rL3.3C1@netcom.com>
Hedin Meitil (hm@royal.net) wrote:
: When I run the script below, I get the error message "EOF in string at
: hellow.pl line 5." Why?
: #!/usr/bin/perl
: print "Content-type: text/html\n\n";
: print <<endHTML; # This is line 5
: <html><head></head>
: <body>
: <p>
: Hello World!
: </body>
: </html>
: endHTML
Make sure that the last line consists *exactly* of "endHTML" followed
immediately by a newline. What Perl is trying to tell you is that it ran
into the end of the file before it found the terminating line of your
"here document."
Is it possible that you created your script using a DOS or Windows editor
and FTPd it to a Unix server in binary mode? If that's the case, you've
got a carriage return (\r) before each newline (\n) in your script, and
Perl is reading the last line as "endHTML\r" which isn't the same thing
as "endHTML". The solution: always use text mode rather than binary mode
when using FTP to transfer scripts; the FTP client and server will then
take care of using the right convention for line endings.
------------------------------
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 880
*************************************