[9287] in Perl-Users-Digest
Perl-Users Digest, Issue: 2882 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 16 10:09:36 1998
Date: Tue, 16 Jun 98 07:01:05 -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 Tue, 16 Jun 1998 Volume: 8 Number: 2882
Today's topics:
[Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
Re: CGI Perl Programming Problem. s_emery@my-dejanews.com
Re: Curly braces in if elsif contructs <jefpin@bergen.org>
Re: ending a foreach loop (Chris Hamilton)
Re: Have we got a good free Perl manual? <jdporter@min.net>
HELP : Socket Problems with NT 4 Perl <a.n.farrow@cranfield.ac.uk>
Re: How can I run Perl in Microsoft Access ? <perlguy@inlink.com>
Re: I have looked everywhere! <perlguy@inlink.com>
Re: Newbie question <quednauf@nortel.co.uk>
Re: Newbie question <quednauf@nortel.co.uk>
Parse exception <gmorgan@photographics.co.uk>
Re: Parse exception <gmorgan@photographics.co.uk>
Re: Perl Contract Programmer Available (Michael Fuhr)
Re: Read a filename from a file and open it (Allan M. Due)
Re: Read a filename from a file and open it <quednauf@nortel.co.uk>
Re: Read the last record in a file (M.J.T. Guy)
REGEX HELP <bob@b-tech.net>
Re: REVIEW: Perl CGI Programming - No Experience Requir (Chris Nandor)
Re: REVIEW: Perl CGI Programming - No Experience Requir <tchrist@mox.perl.com>
simple expression matching problem gulam.faruque@csfp.co.uk
Re: simple expression matching problem <jdf@pobox.com>
Re: Simple pattern matching problem (Tom Grydeland)
Re: Simple pattern matching problem (Patrick Timmins)
Re: strange error message .. "value of <handle> ..." (Allan M. Due)
substitute backslash <Ole.Jensen@cern.ch>
Re: substitute backslash (Allan M. Due)
Re: substitute backslash <guillaume@deepend.co.uk>
Re: Use cgi (Michael J Gebis)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 16 Jun 1998 10:24:01 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage897992641.26251@news.teleport.com>
Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 18 May 1998
[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last major update of the Perl FAQ was in Spring of
1997; of course, ongoing updates are made as needed. ]
For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).
http://cpan.perl.org/doc/FAQs/
Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.
perldoc perlfaq
man perlfaq
If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.
If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
403_662_481 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.
http://cpan.perl.org/
http://www.perl.com/CPAN/
http://cpan.perl.org/doc/FAQs/FAQ/html/perlfaq.html
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/perlfaq.html
You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)
California ftp://ftp.cdrom.com/pub/perl/CPAN/
Texas ftp://ftp.metronet.com/pub/perl/
South Africa ftp://ftp.is.co.za/programming/perl/CPAN/
Japan ftp://ftp.dti.ad.jp/pub/lang/CPAN/
Australia ftp://cpan.topend.com.au/pub/CPAN/
Netherlands ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
Switzerland ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
Chile ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/
If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.
Another possibility is to use one of the FTP-via-email services; for
more information on doing that, send mail to <mail-server@rtfm.mit.edu>
(not to me!) with these lines in the body of the message, flush left:
setdir usenet-by-group/news.announce.newusers
send Anonymous_FTP:_Frequently_Asked_Questions_(FAQ)_List
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.
Have fun with Perl!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 16 Jun 1998 13:31:25 GMT
From: s_emery@my-dejanews.com
Subject: Re: CGI Perl Programming Problem.
Message-Id: <6m5s3d$3p9$1@nnrp1.dejanews.com>
In article <3585EC4E.30FA0D5A@gti.com>,
David Wasserstrum <zeos@gti.com> wrote:
>
> I'm a little confused... lets say two users log on at the same time... one
> named Adam and the other named Bob...
>
> Lets say that you have two forms... the first is where you pick what kind
> of fruit you want to buy and the second is how you will pay
> (Visa,Mastercard, etc.)
>
> Lets say Adam decideds he wants to buy apples... you now return him a web
> form for a payment method with his selection (apples) in a hidden form..
>
> Then Bob logs in and decides he wants to buy bananas, so you return him a
> web form for a payment method with his selection (bananas) in a hidden
> form...
>
> Now when Adam or Bob submit their credit card information you will have the
> type of fruit that they want to buy already in their form (hidden from
> their view of course...)
>
> So exactly where is your problem???
>
> -Dave
>
>
I got mixedup for a bit, but you're right. All I needed to do is put ALL
the pertinent information into the hidden input and all works well!
Thanks for your time.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Tue, 16 Jun 1998 09:12:10 -0400
From: Any more mini-dilemmas I should know about? <jefpin@bergen.org>
Subject: Re: Curly braces in if elsif contructs
Message-Id: <Pine.SGI.3.95.980616091004.26150A-100000@vangogh.bergen.org>
>> if ($gnuffelig eq "1" ) {
>> print "test";
>> my $tblasd = "232";
>> }
>> elsif ($testset eq "esfs") {
>> print "lbsd!";
>> }
>> else {
>> print "fum!";
>> }
I definitely agree. This DOES help readability (I code like this), and it
doesn't matter that it's a "waste of space". In fact (oh, I'm evil), if I
have if elsif else statements that are short enough, I even do:
if ($this){ print "This"; }
elsif ($that){ print "That"; }
else{ print "The other thing"; }
So maybe I'm evil too :)
--
I'm not laughing at you, I'm laughing with you... You're just not
laughing.
- Jeff Pinyan
-- Jeff Pinyan | users.bergen.org/%7Ejefpin | techmaster@bergen.org --
NYPM | ICQ# 10222129 | 10222129@pager.mirabilis.com | qw[jeff] on EFnet
&jp('"($``','','$)EDF8```','$*52J4```','$+E1G4```','#J``@','#2__`');sub
jp{for$w(@_){$_=unpack('B48',unpack('u',$w));$c=~tr/10/# /;print;}}
------------------------------
Date: 16 Jun 1998 13:07:24 GMT
From: chrish@squonk.net (Chris Hamilton)
Subject: Re: ending a foreach loop
Message-Id: <6m5qmc$bkp$1@duke.squonk.net>
Kevin Thorley (kthor@idt.net) wrote:
: I'm using the following lines of code to search an array line by line
: for a given string. When I find the string though, I don't want to
: continue searchin (it will only appear once). Can I break out of a
: foreach loop, or should I be using another type of loop.
Use 'last' .. example:
#
# Print planet names up to Earth (then break out)
#
for(qw(mer ven ear mar jup sat ura nep plu))
{
print "$_\n";
last if(/^ear/);
}
---
Chris Hamilton C7 F9 1E FF 4F D8 F8 87
chrish(at)squonk.net F8 13 5F 69 63 B5 EB A8
"You're just jealous because the 'voices' talk to me."
------------------------------
Date: Tue, 16 Jun 1998 13:51:15 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Have we got a good free Perl manual?
Message-Id: <35867A11.77A3@min.net>
Todd Lehman wrote:
>
> Is it RMS's place/business at all to tell Perl folks what to do when he
> hasn't even taken the time to learn the language? No wonder he hasn't
> succeeded in motivating anyone to write a free book for Perl -- no fire
> in his belly w.r.t. Perl. He would rather frump than put some actual
> effort into it.
Of course: he is contra-interested; don't forget about Guile.
John Porter
------------------------------
Date: Tue, 16 Jun 1998 12:23:16 +0100
From: "Anthony farrow" <a.n.farrow@cranfield.ac.uk>
Subject: HELP : Socket Problems with NT 4 Perl
Message-Id: <35865591.0@news.cranfield.ac.uk>
Hi,
I am having trouble getting the following Socket code to work. It's running
on NT4.
It works fine on version 5.001, but if I use the latest perl version
5.003_07 from www.activestate.com it does not work!!
I need to use this version to interact with our current Web Server (IIS).
All the following scripts do is establish socket communication and send a
short request.
If anyone can shed any light on the subject I would really appreciate it.
Regards,
Anthony Farrow
a.n.farrow@cranfield.ac.uk
##############################################
Here is the Client :
#NT Requires these
$PF_INET = 2;
$SOCK_STREAM = 1;
#Remote Port
$port = 2345;
$pattern = 'S n C4 x8';
#get local port
$this_addr = pack ($pattern, $PF_INET, 0, 0,0,0,0);
#remote address
$serv_addr = pack($pattern, $PF_INET, $port, 138, 250, 24, 103);
#use TCP
$proto = getprotobyname("tcp");
socket(SOCKET, $PF_INET, $SOCK_STREAM, $proto) || die "Can't create socket :
$!";
bind(SOCKET, $this_addr) || die "Can't bind: $!";
connect(SOCKET, $serv_addr) || die "Can't connect : $!";
#print SOCKET "$ARGV[0];$ARGV[1];$ARGV[2];$ARGV[3];$ARGV[4]";
print SOCKET "ccaf;test1;Test Account;\\\\ccanf\\ccanf;CCC Staff";
close (SOCKET);
#############################
And this is the server :
# Necessary as WINNT PERL has no Socket module
$PF_INET = 2;
$SOCK_STREAM = 1;
# Use an arbitary port number
$port = 2345;
# pack pattern with localhost IP Address
$pattern = 'S n C4 x8';
$this_addr = pack($pattern,$PF_INET, $port, 0,0,0,0);
# Set Protocol to TCP (Can be UDP)
$proto = getprotobyname("tcp");
# Create Socket
socket(SERVER, $PF_INET, $SOCK_STREAM, $proto)
|| die "Can't create socket : $!";
# Bind Socket to File Handle SERVER
bind(SERVER, $this_addr)
|| die "Can't bind: $!";
# Listen Forever, 10 connections max
listen(SERVER,10)
|| die "Can't listen : $!";
print "Add User Server listening on port $port\n";
for ( ; $paddr = accept(CLIENT, SERVER); close(CLIENT) )
{
while (<CLIENT>) {
($username, $whatever, $fullname, $homdir, $initial_group) = split(/;/);
print "Request : $username $whatever $fullname $homdir $initial_group\n";
}
}
# pw_serv.pl
------------------------------
Date: Tue, 16 Jun 1998 11:27:08 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: How can I run Perl in Microsoft Access ?
Message-Id: <3586568C.E959C96F@inlink.com>
You can't run Perl IN MS Access! I assume you mean "How do I use an MS
Access Database with Perl?"
Go to: http://www.roth.net/odbc and you'll find what you need.
HTH,
Brent
------------------------------
Date: Tue, 16 Jun 1998 11:41:07 GMT
From: Brent Michalski <perlguy@inlink.com>
To: Chris Denman <chris@microdeal.co.uk>
Subject: Re: I have looked everywhere!
Message-Id: <358659D3.199F8F5B@inlink.com>
Try:
http://www.roth.net/odbc
HTH,
Brent
------------------------------
Date: Tue, 16 Jun 1998 12:10:17 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
To: Freek <freek@writeme.com>
Subject: Re: Newbie question
Message-Id: <35865299.BC8334AE@nortel.co.uk>
Freek wrote:
>
> I am a newbie in the perl world. i curently have a simple problem, i
> hope.
> I need to display the images in a directory, directly on a web page,
> without having to hardcode the files into html, this would take to long
> to add pics. i have been unable to do this in javascript, and now, am
> having probs with perl doing it. the directory will only have images,
> and there will be a limited number of images per directory, but they
> will change periodically.
Be happy that I was slightly bored, so here you go:
#!/blba/perl5.00404 -w
$cbdir = "your/imagedir";
$boundary = "thisMIMEbusineSZsUcKZ";
print "Content-type: multipart/mixed;boundary=$boundary\n\n";
opendir(CB,"$cbdir") || die "Cannot open $cbdir:$!";
foreach $file (sort readdir(CB)) {
output(0) if $file =~ /gif/;
output(1) if $file =~ /jpg/;
}
closedir(CB);
sub output {
my $whatsit = shift;
$whatsit == 0 && print "--$boundary\nContent-type: image/gif\n\n";
$whatsit == 1 && print "--$boundary\nContent-type: image/jpg\n\n";
open (THEFILE, $cbdir."/".$file) || die "can't open $file: $!";
while (<THEFILE>) {
print $_;
}
print "\n";
close (THEFILE);
}
the content-type image/jpg might be slightly wrong, as it fires up my external
jpg viewer. Hmmm, but otherwise working nicely!!!
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: Tue, 16 Jun 1998 12:52:53 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
To: freek@writeme.com
Subject: Re: Newbie question
Message-Id: <35865C95.3B7E2477@nortel.co.uk>
F.Quednau wrote:
> print "Content-type: multipart/mixed;boundary=$boundary\n\n";
>
> the content-type image/jpg might be slightly wrong, as it fires up my external
> jpg viewer. Hmmm, but otherwise working nicely!!!
> --
Of course, problems arise later. That script doesn't manage to display the stuff
one underneath the other, but will rather display them sequentially on the same
spot. It makes sense in a way, and is quite funny, 'cos I could do an animation
like that, but somehow it's disconcerting and obnoxious behaviour !:)
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: Tue, 16 Jun 1998 13:25:33 +0100
From: "Glenn Morgan" <gmorgan@photographics.co.uk>
Subject: Parse exception
Message-Id: <6m5nrh$biv$1@news.u-net.com>
Can anyone tell me what the following message actually means and what might
be causing the problem
Error: Parse exception
I am running Activeware's Perl for Win32 version 5.003_07 Build 316 under NT
v4.0 service pack 3
Thanks in a advance
Glenn
------------------------------
Date: Tue, 16 Jun 1998 13:43:18 +0100
From: "Glenn Morgan" <gmorgan@photographics.co.uk>
Subject: Re: Parse exception
Message-Id: <6m5osk$dkr$1@news.u-net.com>
Please ignore this post, I've sorted it out
Cheers
------------------------------
Date: Tue, 16 Jun 1998 13:35:33 GMT
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Perl Contract Programmer Available
Message-Id: <6m5sau$7u8@flatland.dimensional.com>
Mr James <71022.3700@CompuServe.COM> writes:
> (P.S. Yes, I've already tried posting this in the jobs groups.)
That's no excuse for posting in a group where it doesn't belong.
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
Date: 16 Jun 1998 13:00:40 GMT
From: due@murray.fordham.edu (Allan M. Due)
Subject: Re: Read a filename from a file and open it
Message-Id: <6m5q9o$n04$0@206.165.146.44>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <35864D5D.6BC1@cs.pitt.edu>, Yasir Khalifa
(khalifa@cs.pitt.edu) posted...
|Hi:
|
|Can anyone help! I have a file called lastname.html (which changes
|according to the last name of the user using the system). The name
|of this file is stred in a temp file (HTMLFILE), which includes only
|one line (the filename lastname.html).
|
|The Perl code below, reads the contents of the file HTMLFILE
|and assigns it to a variable $htmldatafile. Now, I want Perl/CGI
|to display the file $htmldatafile but it complains. No file is
|displayed. Any help is appreciated.
|-------------------
|#!/usr/local/bin/perl
|
|require "read_tools.pl";
|
|print "Location: $htmldatafile"," \n\n";
|
|$tmpfile="HTMLFILE"; #this file includes a filename called username.html
|
|
|if (open(HTFILE, "<".$tmpfile)){
| select(HTFILE);
| $htmldatafile = <HTFILE>; #read the the contents of HTFILE
| close(HTFILE); #and assign it to $htmldatafile,
| #which is now username.html
|}else {
| print "Cannot read from file: $tmpfile","\n";
| }
|
Hmm, what is that select doing there? To my way of thinking you are
setting the default output filehandle to HTFILE, which I don't believe
is your intent. Try removing that select and see if that helps.
HTH
--
Allan M. Due
Due@Murray.Fordham.edu
The beginning of wisdom is the definitions of terms.
- Socrates
------------------------------
Date: Tue, 16 Jun 1998 14:07:44 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: Read a filename from a file and open it
Message-Id: <35866E20.28CD61E7@nortel.co.uk>
Yasir Khalifa wrote:
>
> Hi:
>
> Can anyone help!
> #!/usr/local/bin/perl
>
> require "read_tools.pl";
>
> print "Location: $htmldatafile"," \n\n";
>
> $tmpfile="HTMLFILE"; #this file includes a filename called username.html
>
> if (open(HTFILE, "<".$tmpfile)){
> select(HTFILE);
> $htmldatafile = <HTFILE>; #read the the contents of HTFILE
> close(HTFILE); #and assign it to $htmldatafile,
> #which is now username.html
> }else {
> print "Cannot read from file: $tmpfile","\n";
> }
1) Reduce the if/else conditional to something like open (FOO, "< $foo") or
print "Cannot read from file: $tmpfile, $!\n"; which is a bit easier on the eye
:)
2) Yep, you might have to chomp $htmldatafile
3) put the print statement after the opening of the file and the reading of
<HTFILE>, as in that order $htmldatafile should be 'undef' in your
location statement, as you haven't assigned anything to that.
HTH!
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: 16 Jun 1998 13:02:43 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Read the last record in a file
Message-Id: <6m5qdj$sd6$1@pegasus.csx.cam.ac.uk>
In article <6m0r44$pn7$1@monet.op.net>, Mark-Jason Dominus <mjd@op.net> wrote:
> last if $lastline =~ s#.*$/##o; # omit `o' if you plan to change $/
If you change $/, you'll be in deeper trouble than just needing to
remove the `o' - $/ will match `.' unless it has the default value of
"\n". And the `.' won't match any embedded newlines in the last line.
Mike Guy
------------------------------
Date: Tue, 16 Jun 1998 22:37:41 +1000
From: "Bob Reynolds" <bob@b-tech.net>
Subject: REGEX HELP
Message-Id: <35866700.0@139.134.5.33>
Hi guys,
Still getting my head about regex's, just when i think ive got it i
aint.....
there was an app someone told me about that was a regex generator, does
anyone know what it was and where its living at the moment?
alternatively, can anyone suggest some good regex help pages??
ta...
------------------------------
Date: Tue, 16 Jun 1998 12:57:06 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: REVIEW: Perl CGI Programming - No Experience Required
Message-Id: <pudge-1606980854110001@dynamic404.ply.adelphia.net>
In article <6m5fvt$j4f$1@samba.rahul.net>, c.c.eiftj@54.usenet.us.com
(Rahul Dhesi) wrote:
# In <pudge-1406982115300001@192.168.0.3> pudge@pobox.com (Chris Nandor) writes:
#
# >In article <6lspgm$ikt$1@samba.rahul.net>, c.c.eiftj@54.usenet.us.com
# >(Rahul Dhesi) wrote:
#
# ># The only difference between a list and an array that I can think of is
# ># that we call a list an array if we use subscript notation on it at least
# ># once in a program. So the difference appears to be what we do, not what
# ># it is.
#
# >No, a subscripted list is still a list.
#
# > print join("",
# > (split
# > (//, (`perl -v`)[1])
# > )[11,19,14,15]
# > );
#
# >Here we put a subscript on the contents of `perl -v`, split that line into
# >a list, and subscript that list, and neither is an array.
#
# By my definition it is.
Your logic escapes me. If ('a' .. 'z') is an array, then why is $a
different in this two situations?
$a = ('a' .. 'z'); print $a;
@a = ('a' .. 'z'); $a = @a; print $a;
Because a list and an array are not interchangable. If they were, then $a
would be the same in both lines, right? Of course right.
In article <6m5gcl$j78$1@samba.rahul.net>, c.c.eiftj@54.usenet.us.com
(Rahul Dhesi) wrote:
# To show that lists and arrays are different, you would have to (a) have
# a good unambiguous definitions of 'list' and 'array', and *then* show
# that they behave differently. Until you have such definitions no amount
# of perl code will prove anything.
You have been given a completely unambiguous definition. You just don't
understand it. An array has an AV allocated, and a list is just some
values on a stack somewhere. Think of it like this: an array is accessed
through symbols like $ and @, and a list is not. A list cannot be changed
or altered in any way, an array can be. These are all unambiguous.
Now you have gotten lots of examples of how they behave differently,
including mine above. You can push/pop/shift/unshift/slice an array, not a
list. You can make a reference to an array, but not to a list. You can
tie an array, and you cannot tie a list.
And, of course, they behave differently in different contexts. In
particular, in scalar context (above) and in 1multidimensional array
emulation context:
$; = '|';
$a{'a', 'b'} = 'z'; # $a{'a|b'} == 'z'
@a = ('a', 'b');
$a{@a} = 'y'; # $a{2} == 'y'
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: 16 Jun 1998 12:57:16 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: REVIEW: Perl CGI Programming - No Experience Required
Message-Id: <6m5q3c$60m$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
c.c.eiftj@54.usenet.us.com (Rahul Dhesi) writes:
:>Here we put a subscript on the contents of `perl -v`, split that line into
:>a list, and subscript that list, and neither is an array.
:
:By my definition it is.
Since we're speaking in the context of Perl, *your* definition
of an array is immaterial: only Perl's definition counts. If
there's no AV, there's no array. It's quite that simple.
--tom
--
There's some side effect based on the fact that SIGCHLD isn't sent by
anyone, but is fabricated by the kernel when a child dies. It's a huge
kludge. But then, it _is_ SysV. --Chip Salzenberg, aka <chs@nando.net>
------------------------------
Date: Tue, 16 Jun 1998 12:25:03 GMT
From: gulam.faruque@csfp.co.uk
Subject: simple expression matching problem
Message-Id: <6m5o6v$vfk$1@nnrp1.dejanews.com>
Hi..
I'm trying to write a replace script in perl.
for example. scriptname filename string1 string2
This will search for string1 in filename and replace it with
string2 and print the results to the console.
The problem is string1 and string2 can contain any characters such as \.*[]{}
I dont want the person running the script to enter a \ before each special
character.
How is this done?
Will I have to scan the strings first to insert a \ in front of any special
characters before I do the replacement ?
I am using win32-perl v5.004 on NT4
Thanks
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 16 Jun 1998 09:39:55 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: gulam.faruque@csfp.co.uk
Subject: Re: simple expression matching problem
Message-Id: <btrtcsw4.fsf@mailhost.panix.com>
gulam.faruque@csfp.co.uk writes:
> I'm trying to write a replace script in perl.
> for example. scriptname filename string1 string2
>
> This will search for string1 in filename and replace it with
> string2 and print the results to the console.
You don't need to write a script for that.
C:\> perl -pe "s/string1/string2/g" filename
> The problem is string1 and string2 can contain any characters such as \.*[]{}
> I dont want the person running the script to enter a \ before each special
> character.
You want the quotemeta operator.
C:\> perldoc -f quotemeta
C:\> perldoc perlre
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf/
------------------------------
Date: 16 Jun 1998 12:53:41 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: Simple pattern matching problem
Message-Id: <slrn6ocqml.5ja.Tom.Grydeland@mitra.phys.uit.no>
On Tue, 16 Jun 1998 09:47:34 +0100,
F.Quednau <quednauf@nortel.co.uk> wrote:
> Try this (untested):
> $string =~ s/<!--(.*?)-->//g . If wrong, check the docs.
It is wrong. This subject has been beaten to death about a million
times already.
<!-- -- -->
This is still inside a valid HTML comment
<!-- -- -->
> > Please tell me, how can I remove all comments tags from a HTML and
> > display it
> You might try html::parser from CPAN.
Attaboy. For full HTML parsing, you need a full HTML::Parser.
Under some simplifying assumptions (such as `the string "<!--" does not
appear in an argument to a tag), stripping comment tags and nothing
more *can* be done in a single regex. This is from striphtml by Tom
Christiansen:
#########################################################
# first we'll shoot all the <!-- comments -->
#########################################################
s{ <! # comments begin with a `<!'
# followed by 0 or more comments;
(.*?) # this is actually to eat up comments in non
# random places
( # not suppose to have any white space here
# just a quick start;
-- # each comment starts with a `--'
.*? # and includes all text up to and including
-- # the *next* occurrence of `--'
\s* # and may have trailing while space
# (albeit not leading white space XXX)
)+ # repetire ad libitum XXX should be * not +
(.*?) # trailing non comment text
> # up to a `>'
}{
if ($1 || $3) { # this silliness for embedded comments in tags
"<!$1 $3>";
}
}gesx; # mutate into nada, nothing, and niente
Now, for silliness like
<img src="foo<!--bar">
this *will* break. Caveat emptor.
> Frank Quednau
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
- Do radioactive cats have 18 half-lives? -
------------------------------
Date: Tue, 16 Jun 1998 13:25:32 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Simple pattern matching problem
Message-Id: <6m5roc$3a7$1@nnrp1.dejanews.com>
In article <6m55n2$8g2$1@nnrp1.dejanews.com>,
whizswift@my-dejanews.com wrote:
>
> I have string which looks like this:
> <!--something 10--><li>xyz</li><!--someotherthing 20-->somewords
> when i use
> $string =~ s/<!--(.*)-->//g
>
> it returns only "somewords"
> but what happened to <li>xyz</li> ?
> My hunch is the pattern match occurs from
> <!--something 10--> to <!someotherthing 20-->
> everything between it is replaced with nothing.
>
> Please tell me, how can I remove all comments tags from a HTML and display it
> (i don't want to save it)
>
> please reply as email.....
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/ Now offering spam-free web-based newsreading
>
1. Your problem is greediness.
2. Your problem is greediness.
Read perlre for a start. But you won't likely ever read this, since I'm not
emailing you (see #2 above). Modules exist, but did you try throwing some ?'s
in there to try to solve your problem in a non-greedy manner?
$string =~ s/<!--.*?-->(.*?)<!--.*/$1/g;
Patrick Timmins
U. Nebraska Medical Center
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 16 Jun 1998 11:24:52 GMT
From: due@murray.fordham.edu (Allan M. Due)
Subject: Re: strange error message .. "value of <handle> ..."
Message-Id: <6m5km4$a2o$0@206.165.146.44>
In article <Pine.GSO.3.96.980615194533.17943P-
100000@user2.teleport.com>, Tom Phoenix (rootbeer@teleport.com)
posted...
|On 15 Jun 1998, Allan M. Due wrote:
|
|> while ($tmp = defined <TMP>)
|
|I do not think that that is what you meant.... :-)
Doh! It was kind of early, meant
while (defined ($tmp = <TMP>))
thanks for catching that.
--
Allan M. Due
Due@Murray.Fordham.edu
The beginning of wisdom is the definitions of terms.
- Socrates
------------------------------
Date: Tue, 16 Jun 1998 13:54:36 +0200
From: "Ole E. JENSEN" <Ole.Jensen@cern.ch>
Subject: substitute backslash
Message-Id: <35865CFC.3CF9CFCE@cern.ch>
I'm stuck.
Can anybody tell me how to substitute backslash characters like:
$mystr =~ s/\//g; # Off course this does not work
Thanks in advance,
- Ole -
--
Ole.Jensen@cern.ch
------------------------------
Date: 16 Jun 1998 13:23:39 GMT
From: due@murray.fordham.edu (Allan M. Due)
Subject: Re: substitute backslash
Message-Id: <6m5rkr$n04$1@206.165.146.44>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <35865CFC.3CF9CFCE@cern.ch>, Ole E. JENSEN
(Ole.Jensen@cern.ch) posted...
|I'm stuck.
|
|Can anybody tell me how to substitute backslash characters like:
|
|$mystr =~ s/\//g; # Off course this does not work
|
I must be missing something, sorry. Why not just escape it?
$mystr =~ s/\\//g;
--
Allan M. Due
Due@Murray.Fordham.edu
The beginning of wisdom is the definitions of terms.
- Socrates
------------------------------
Date: Tue, 16 Jun 1998 14:23:43 +0100
From: Guillaume Buat-Menard <guillaume@deepend.co.uk>
To: "Ole E. JENSEN" <Ole.Jensen@cern.ch>
Subject: Re: substitute backslash
Message-Id: <358671DF.A091A609@deepend.co.uk>
Ole E. JENSEN wrote:
> I'm stuck.
>
> Can anybody tell me how to substitute backslash characters like:
>
> $mystr =~ s/\//g; # Off course this does not work
>
> Thanks in advance,
> - Ole -
>
> --
> Ole.Jensen@cern.ch
Just do $mysrt =~ s/\\//g, as for any charracter...
good luck,
Guillaume.
--
----------------------------------------------
Guillaume Buat-Menard
guillaume@deepend.co.uk
Deep End Design Ltd
40-42 Scrutton Street, London EC2A 4QL
+44 (0) 171 247 2999
http://www.deepend.co.uk
----------------------------------------------
------------------------------
Date: 16 Jun 1998 07:04:16 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Use cgi
Message-Id: <6m55dg$pe@mozo.cc.purdue.edu>
Jim Bowlin <bowlin@sirius.com> writes:
}Patrick Lanphier wrote:
}> When the below is run the following error occurs "Undefined subroutine
}> &main::param called at script line 3." How do I correct this problem?
}>
}> #!D:\Perl\perl5\bin\perl
}> use cgi qw(:standard);
}> my $contact = param("contact") ;
}s/cgi/CGI/; In other words the CGI module is called "CGI"
}not "cgi".
In other words...
While Perl can parse cgi, perl can only parse CGI.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
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 2882
**************************************