[6516] in Perl-Users-Digest
Perl-Users Digest, Issue: 141 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 18 22:10:56 1997
Date: Tue, 18 Mar 97 19:00:23 -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 Tue, 18 Mar 1997 Volume: 8 Number: 141
Today's topics:
Re: /RE/ for Dummies - Match all caps (Eric Bohlman)
Re: Access to "my" variables from the debugger <tchrist@mox.perl.com>
Re: Assignment of string not working <rootbeer@teleport.com>
Re: Assignment of string not working <rra@cs.stanford.edu>
Re: BUG? Improper variable interpolation in patterns? <rra@cs.stanford.edu>
Re: BUG? Improper variable interpolation in patterns? (Michael Constant)
Re: CGI libraries won't compile in 5.003_93 <khera@kcilink.com>
Re: Cutting off the first letter. <khawkins@ncsa.uiuc.edu>
Re: Cutting off the first letter. <web435@ix.netcom.com>
Re: Directory access Denying <rootbeer@teleport.com>
Re: Help on Shopping Cart <rootbeer@teleport.com>
Help redirect STDOUT, STDERR under NT !!! <zach@aristotech.com>
How can I parameterize a package name? (Michael T Decerbo)
How To Pattern Match To The First Occurance Of A Charac (Rhadji P)
Re: Is it Possible? (Michael Fuhr)
Re: Multiple substitutions (Eric Bohlman)
Parsing html tag attributes & values in Perl (Dan Sumption)
Re: Regular Expressions Problem <rra@cs.stanford.edu>
Re: Reloading web pages <rootbeer@teleport.com>
San Diego Sybase Job Opportunity!!! <dglass@swpartners.com>
Re: simple glob fails under Linux (Sussex Silversmiths)
Re: Split <lewis@nexusint.com>
Re: term 'regular expressions' considered undesirable <sfink@cs.berkeley.edu>
text to HTML <lewis@nexusint.com>
Re: text to HTML (Eric Bohlman)
Re: Unix vs WIN95 equivalents (Malcolm Cifuentes)
Windows 3.11 and Perl (Zac)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 18 Mar 1997 23:24:56 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: /RE/ for Dummies - Match all caps
Message-Id: <ebohlmanE79IDK.CFD@netcom.com>
Robert Schuldenfrei (sailboat@tiac.net) wrote:
: Thus I would like the following line:
: THIS IS ALL CAPS
: To be converted into:
: This Is All Caps
s/\b([A-Z])([A-Z]+)/$1\L$2/g
does the trick for me. Let's walk through the pattern and replacement:
\b matches a word boundary, since we only want to do this at the
beginning of a word.
([A-Z]) matches a single capital letter and sticks it into $1.
([A-Z]+) matches one or more capital letters (after the first one) and
sticks them into $2.
Now for the replacement:
$1 inserts the initial capital letter unchanged (remember that in the
replacement part, you have to write $1, not \1).
\L says to translate everything after it into lower case.
$2 inserts the rest of the word.
Note that this scheme needs to be modified if "words" can contain embedded
non-alphanumerics (it's rather annoying to read "Tim Berners-LEE
Wrote..."); dealing with this is left as an exercise to the reader.
------------------------------
Date: 18 Mar 1997 23:13:26 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Access to "my" variables from the debugger
Message-Id: <5gn7im$n9g$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Mark Andrew <mark.andrew@fr.bosch.de> writes:
:How do I use the X command to print a "my" variable
:in the perl debugger ?
You do not.
You use the 'x' command instead.
DBG> x $privar
DBG> x \@privar
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
Every program has at least one bug and can be shortened by at least one
instruction --from which, by induction, one can deduce that every
program can be reduced to one instruction which doesn't work.
------------------------------
Date: Tue, 18 Mar 1997 15:44:20 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Philip Ives <st94zm5g@dunx1.ocs.drexel.edu>
Subject: Re: Assignment of string not working
Message-Id: <Pine.GSO.3.96.970318154223.6855I-100000@kelly.teleport.com>
On 18 Mar 1997, Philip Ives wrote:
> In my script I am assigning a string variable to the $to variable
> It does not seem to be working and I cannot figure out why.
> $to= "$contents('outAddress')";
If the value of $contents is "FOO", that will assign to $to the value
q#FOO('outAddress')# . Is that what you wanted? :-) (Or did you mean to
use curly braces instead of parentheses?) Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 18 Mar 1997 18:23:17 -0800
From: Russ Allbery <rra@cs.stanford.edu>
To: st94zm5g@dunx1.ocs.drexel.edu (Philip Ives)
Subject: Re: Assignment of string not working
Message-Id: <qumhgi8r562.fsf@cyclone.stanford.edu>
[ Posted and mailed. ]
Philip Ives <st94zm5g@dunx1.ocs.drexel.edu> writes:
> In my script I am assigning a string variable to the $to variable to
> sendmail.
What does this mean? Are you passing something to sendmail on the command
line, are you setting the To: header in the text of a message you're
piping to sendmail, or are you doing something else? Just setting $to in
a Perl script isn't going to affect sendmail in the slightest.
--
Russ Allbery (rra@cs.stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: 18 Mar 1997 18:28:05 -0800
From: Russ Allbery <rra@cs.stanford.edu>
To: mer@world.evansville.net (Marc Rouleau)
Subject: Re: BUG? Improper variable interpolation in patterns?
Message-Id: <qumd8swr4y2.fsf@cyclone.stanford.edu>
[ Posted and mailed. ]
Marc Rouleau <mer@world.evansville.net> writes:
> $_ = '$x'; $a = '$x'; $b = '\$x';
> print "\$a matched\n" if /$a/;
> print "\$b matched\n" if /$b/;
> My output from this fragment is
> $b matched
Right. It's not interpolating variables, it's applying the *other*
meaning of $. The pattern /$x/ in this case is matching the end of a line
($) followed by the character 'x', which isn't going to do what you want.
In the $b case, you're escaping the $ so that its special meaning isn't
used.
Depending on where this came up at, you may want to look at \Q or
quotemeta to solve the problem.
--
Russ Allbery (rra@cs.stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: 18 Mar 1997 18:43:43 -0800
From: mconst@soda.CSUA.Berkeley.EDU (Michael Constant)
Subject: Re: BUG? Improper variable interpolation in patterns?
Message-Id: <5gnjsv$41n@soda.CSUA.Berkeley.EDU>
Marc Rouleau <mer@world.evansville.net> wrote:
>$_ = '$x'; $a = '$x'; $b = '\$x';
>print "\$a matched\n" if /$a/;
>print "\$b matched\n" if /$b/;
>
>My output from this fragment is "$b matched"
That's because when you interpolate $a into the pattern match, you
get a pattern match that looks like /$x/. Since $ is a metacharacter
that matches only at the end of a line, this pattern match fails.
You can fix it, as you discovered, by putting a backslash in front
of the $ sign; this does not prevent $x from being treated as a
variable (which would never happen in any case), but merely quotes
the $ character as used in the regular expression.
The best way to get around this is to use \Q to automatically quote
any regexp metacharacters:
print "\$a matched\n" if /\Q$a/;
This will not only replace $ with \$, but it will also backslash any
other regexp metacharacters which happen to appear in $a. See the
perlre(1) manpage for more information.
--
Michael Constant (mconst@soda.csua.berkeley.edu)
------------------------------
Date: 18 Mar 1997 15:26:25 -0500
From: Vivek Khera <khera@kcilink.com>
Subject: Re: CGI libraries won't compile in 5.003_93
Message-Id: <x7k9n5lzf2.fsf@kci.kciLink.com>
Well, bad style or not, I'm following up to my own post...
I figured out the smallest set of patches that are needed to make
CGI-modules-2.75 run under Perl 5.003_93 with "use strict" in effect
in my program, like they used to work under 5.003. Here they are.
Is CGI-modules being dropped in favor of CGI.pm? It seems to me the
former is a better way to go and much smaller; CGI.pm has gotten
*really* huge and has many functions not used by most programs, but it
is being actively developed unlike CGI-modules.
*** CGI/Base.pm.orig Thu Feb 15 02:54:02 1996
--- CGI/Base.pm Tue Mar 18 15:13:28 1997
***************
*** 588,594 ****
$CGI::Base::SERVER_PORT = 80;
$CGI::Base::SERVER_PROTOCOL = 'HTTP/1.0';
$CGI::Base::HTTP_USER_AGENT = $CGI::Base::SERVER_SOFTWARE;
! my $sn = $0;
unless ($sn =~ m:^/:) {
require Cwd;
my $cwd = Cwd::fastcwd();
--- 588,594 ----
$CGI::Base::SERVER_PORT = 80;
$CGI::Base::SERVER_PROTOCOL = 'HTTP/1.0';
$CGI::Base::HTTP_USER_AGENT = $CGI::Base::SERVER_SOFTWARE;
! $sn = $0;
unless ($sn =~ m:^/:) {
require Cwd;
my $cwd = Cwd::fastcwd();
***************
*** 598,604 ****
$CGI::Base::SCRIPT_NAME = $sn;
$CGI::Base::REQUEST_METHOD = 'GET';
! my $qs = '';
if (@ARGV) { # Debugging off-line via command line args
$qs = "@ARGV";
$qs =~ tr/ /&/ if $qs =~ m/=/;
--- 598,604 ----
$CGI::Base::SCRIPT_NAME = $sn;
$CGI::Base::REQUEST_METHOD = 'GET';
! $qs = '';
if (@ARGV) { # Debugging off-line via command line args
$qs = "@ARGV";
$qs =~ tr/ /&/ if $qs =~ m/=/;
*** CGI/BasePlus.pm.orig Thu Feb 15 02:54:02 1996
--- CGI/BasePlus.pm Tue Mar 18 15:13:28 1997
***************
*** 169,175 ****
do {$TMPDIRECTORY = $_; last} if -w $_;
}
$TMPDIRECTORY = "." unless $TMPDIRECTORY;
! $SEQUENCE="CGItemp$$0000";
%OVERLOAD = ('""'=>'as_string');
--- 169,175 ----
do {$TMPDIRECTORY = $_; last} if -w $_;
}
$TMPDIRECTORY = "." unless $TMPDIRECTORY;
! $SEQUENCE="CGItemp${$}0000";
%OVERLOAD = ('""'=>'as_string');
*** CGI/Carp.pm.orig Thu Feb 15 02:54:02 1996
--- CGI/Carp.pm Tue Mar 18 15:13:31 1997
***************
*** 126,133 ****
@EXPORT = qw(confess croak carp);
@EXPORT_OK = qw(carpout);
- $main::SIG{__WARN__}='CGI::Carp::warn';
- $main::SIG{__DIE__}='CGI::Carp::die';
$CGI::Carp::VERSION = '1.02';
# These are the originals
--- 126,131 ----
***************
*** 171,176 ****
--- 169,177 ----
$message=~s/^/$stamp/gm;
realdie $message;
}
+
+ $main::SIG{__WARN__}= \&warn;
+ $main::SIG{__DIE__}= \¨
sub confess { CGI::Carp::die Carp::longmess @_; }
sub croak { CGI::Carp::die Carp::shortmess @_; }
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D. Khera Communications, Inc.
Internet: khera@kciLink.com Rockville, MD +1-301-258-8292
PGP/MIME spoken here http://www.kciLink.com/home/khera/
------------------------------
Date: Tue, 18 Mar 1997 18:41:53 -0600
From: Kevin Hawkins <khawkins@ncsa.uiuc.edu>
To: Gene Glass <glass@asu.edu>
Subject: Re: Cutting off the first letter.
Message-Id: <332F3651.41C67EA6@ncsa.uiuc.edu>
Gene Glass wrote:
>
> I am stuck trying to find a way of cutting off the initial letter in
> a word that has been associated with a variable and then use that letter
> as a variable itself. Have tried chop (wrong end), split, slice, reverse
> ...I don't know that much Perl to start with and I'm out of leads.
> Here's the problem:
> I read in a person's last name and call it $name. Now I want to
> isolate the first letter of that name and call it $letter. How is this
> done?
> Thanks for any help. Gene Glass glass@asu.edu
Try this:
#!/usr/bin/perl
$last_name = "Smith";
$letter = substr($last_name, 0, 1); # Get the first letter
$$letter = "Sparky!";
print "\$\$letter is $$letter\n";
print "\$S = $S\n";
and my output looked like this:
$$letter is Sparky!
$S = Sparky!
HTH,
Kevin
--
=) Kevin Hawkins -- Senior in Computer Science, University of Illinois
(= NCSA Technology Management | e-mail to: khawkins@ncsa.uiuc.edu
=) http://gto.ncsa.uiuc.edu/khawkins/
(= PGP public key available -- finger khawkins@ncsa.uiuc.edu
------------------------------
Date: 19 Mar 1997 01:40:02 GMT
From: "Bill Brunning" <web435@ix.netcom.com>
Subject: Re: Cutting off the first letter.
Message-Id: <01bc3406$cd434fc0$8bccb7c7@stygian>
Gene Glass <glass@asu.edu> wrote in article <332F0814.693E@asu.edu>...
> I am stuck trying to find a way of cutting off the initial letter in
> a word that has been associated with a variable and then use that letter
> as a variable itself. Have tried chop (wrong end), split, slice, reverse
> ...I don't know that much Perl to start with and I'm out of leads.
> Here's the problem:
> I read in a person's last name and call it $name. Now I want to
> isolate the first letter of that name and call it $letter. How is this
> done?
> Thanks for any help. Gene Glass glass@asu.edu
>
Gene:
Your wording is a bit ambiguous -- do you actually want to remove the first
letter from $name, or just assign a copy of it to $letter, leaving $name
intact? I'll assume you mean the latter, in which case:
$letter = substr($name, 0, 1);
is the statement you seek. See the Camel book (2nd ed.), p. 227 for
details on the substr() function.
HTH.
Bill Brunning --- bill@stygian.com
------------------------------
Date: Tue, 18 Mar 1997 15:59:45 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Jeremy Coulter <vss@xtra.co.nz>
Subject: Re: Directory access Denying
Message-Id: <Pine.GSO.3.96.970318155842.6855L-100000@kelly.teleport.com>
On Tue, 18 Mar 1997, Jeremy Coulter wrote:
> A friend asked me to write a perl script that deals with Passwords to
> stop people getting access to certain pages on his server.
Usually you don't need to do this. Check your server's docs; it probably
supports that. If you have more questions, check out a newsgroup about
servers, or its faq. Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Tue, 18 Mar 1997 16:41:35 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Webwalkers <sturner1@gte.net>
Subject: Re: Help on Shopping Cart
Message-Id: <Pine.GSO.3.96.970318163925.6855S-100000@kelly.teleport.com>
On 18 Mar 1997, Webwalkers wrote:
> I am working on a shopping cart script that needs some modification.
> Since I don't know much about scripting, I don't know where to begin.
A good place to begin would be to obtain some good books about Perl, such
as the ones mentioned in perlbook(1). You can also get a lot of help from
free information such as the FAQ, regularly posted to c.l.p.a. Hope this
helps!
news:comp.lang.perl.announce
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Tue, 18 Mar 1997 17:51:59 -0800
From: Zachary Deretsky <zach@aristotech.com>
Subject: Help redirect STDOUT, STDERR under NT !!!
Message-Id: <332F46BF.90F@aristotech.com>
My tool, written in Perl, reads a list of commands from an ASCII file
and calls them with the system call like:
system($B_sysCommand);
At the beginning it optionally redirects STDOUT and STDERR into a
logfile:
if(!$opt_D) {
open(LOG, ">>$B_logfile") || die "Can't open $B_logfile";
$B_oldFh = select(LOG); $| = 1; select($B_oldFh);
open(SAVEOUT, ">&STDOUT"); $B_oldFh = select(SAVEOUT); $| = 1;
select($B_oldFh);
open(SAVEERR, ">&STDERR"); $B_oldFh = select(SAVEERR); $| = 1;
select($B_oldFh);
open(STDOUT, ">&LOG") || die "Can't redirect stdout to
$B_logfile";
open(STDERR, ">&LOG") || die "Can't redirect stderr to
$B_logfile";
}
$B_oldFh = select(STDOUT); $| = 1; select($B_oldFh);
$B_oldFh = select(STDERR); $| = 1; select($B_oldFh);
This all worked for years under Unix both with Perl4 and Perl5. Now,
under WindowsNT with the latest, build 303 activeware Perl it works
without redirection but blows up when I want a logfile:
Failed in '11: d:/atools/src/tpbuild.pl $SRCPROD $DSTDIR $GZFILE
$PRODNODE $PRODLEAF $SCRIPT $VERSION'.
Exit value 9.
Signal value 0.
System error string 'Exec format error'.
The above 4 lines are produced by my script and Exit value is $? >> 8;
signal is $? & 255; and System error string is $!
My commands are perl scripts which might call other perl scripts.
What shall I do to make redirection of STDERR, STDOUT wotk under NT???
Thank you, Zach.
------------------------------
Date: 18 Mar 1997 22:53:52 GMT
From: mike@athena.mit.edu (Michael T Decerbo)
Subject: How can I parameterize a package name?
Message-Id: <5gn6e0$89t@senator-bedfellow.MIT.EDU>
>Sure, pass the package name as a paramter and compose
>a fully qualified reference in your symbolic assignment.
>eg (untested):
>
>sub import_vars_from_hashref_keys {
> my ($hashref,$pck) = @_;
> while (($key, $value) = each %$hashref) {
> ${"$pck::$key"} = $value;
> }
>}
>
>import_vars_from_hashref_keys( \%myhash, "temp" );
I can't for the life of me figure out why, but the Perl snippet
suggested doesn't actually work.
For some reason, it seems that
${"$pck::$key"} = $value;
is setting the variable named for $key in the package where the
subroutine is defined, not in the one named by $pck. I had to use:
eval ('$' . "$pck" . "::" . "$key = $value");
This sort of feels like cheating, but I couldn't figure out how to do
it without an eval.
--
Mike Decerbo -- mike@mit.edu
------------------------------
Date: Tue, 18 Mar 1997 16:48:49 GMT
From: dharma@msys.net (Rhadji P)
Subject: How To Pattern Match To The First Occurance Of A Character
Message-Id: <5gmh5q$90i@krypto.zippo.com>
I must be missing something. It can't be that difficult.
What I'm trying to do is pattern match to the first occurance of a
character.
For example, given the following string...
<TEXTAREA NAME="area 1" ROWS="10" COLS="10"></TEXTAREA>
I want $1 to equal NAME="area 1" ROWS="10" COLS="10"
but the pattern /<TEXTAREA(.*)>/
gobbles up the string to the second ">" causing
$1 to equal NAME="area 1" ROWS="10" COLS="10"></TEXTAREA
How do I pattern match to the first occurance of > ?
Thanks
Ron
dharma@msys.net
------------------------------
Date: 18 Mar 1997 15:02:32 -0700
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Is it Possible?
Message-Id: <5gn3do$ci@nova.dimensional.com>
skafte@news.worldgate.com (Greg Skafte) writes:
>Is it possible to untaint an unlink command in suid/sgid enviroment
>
>most of my endevours get me something like:
>
> Insecure dependency in unlink while running setgid
> at /usr/local/sbin/.numeric-page line 88.
Take a look at the perlsec manual page.
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
Date: Tue, 18 Mar 1997 22:42:22 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Multiple substitutions
Message-Id: <ebohlmanE79GEM.8Hr@netcom.com>
Randal Schwartz (merlyn@stonehenge.com) wrote:
: Exactly. I've been programming for (35-9=) 24 years myself, and I
: find the best way to learn a new language is to *read* every example
: snippet I can find, with a reference book close by. Eventually, the
: *rhythm* of the language starts pounding in my head... and my fluency
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: is close at hand. That's how I learned Perl, and now I'm one of the
: drummers. :-)
That is truly an outstanding metaphor for having a mental model of how
the language works. Some would say "grok" and others would talk about
the language becoming "intuitive." It's something quite different from
memorizing a bunch of facts about the language, because mere memorization
doesn't tell you how those facts relate to each other to form a whole.
Without a mental model, you can't *think* in the language when you're
trying to solve a problem; all you can do is search a set of solutions
in hopes of finding one that might relate to the problem, at which point
you've got the tail wagging the dog.
It saddens me to see lots of CGI writers trying to modify someone else's
existing code (which in itself is a worthwhile way of building on others'
efforts rather than re-inventing the wheel) without understanding what the
code *means*. This also extends to HTML creation. Gerald Weinberg wrote
25 years ago on how the cognitive aspects of writing an application
designed for use by others differ from those of writing a program for
one's personal use, but it seems that nowadays everyone is approaching Web
development as if it were the latter; too many people just experiment with
techniques they don't really understand until they've got something that
appears to work for them (you might say they throw random "solutions" at
the problem until one sticks), and take the attitude that it doesn't
matter if it doesn't work for others as long as they get paid before the
shit hits the fan.
------------------------------
Date: Tue, 18 Mar 1997 23:12:54 GMT
From: dan@gulch.demon.co.uk (Dan Sumption)
Subject: Parsing html tag attributes & values in Perl
Message-Id: <332f2129.10780701@news.demon.co.uk>
OK, I haven't yet had any response to my rather convoluted
posting last night, so I started working at it myself. I've made
a little progress, but have hit a problem.
I wrote a subroutine to look at an html tag and return an
associative array containing the tag attributes and their
associated values. For example, if you feed it the tag <META
NAME="Author" CONTENT="Dan Sumption"> it will produce the array
{NAME, Author,
CONTENT, Dan Sumption}
My problem is that that the program separates out the tag by
looking for the < and > characters. This can lead to errors (and
a potentially never-ending loop) when one of these characters
appears as part of a value. For example:
<img src="arrow.gif" alt="Look Here >">
Should be reduced to:
src="arrow.gif" alt="Look Here >"
before parsing, but my code instead reduces it to:
src="arrow.gif" alt="Look Here ">
I can write various 'fixes' to avoid some of these potential
problems, but they all seem very long-winded and ugly looking.
Surely there must be 'more than one way to do it'?
I'd like the code to be as bullet-proof as possible - potential
problems include sending two tags to the subroutine by accident
(meaning that you can't rely on the last > being the close of the
tag), and tags that use single as well as double quotes (meaning
that you can't just check the number of quotes before the > -
there could be quotes within quotes). Escaped-out quotes in bits
of JavaScript is a further headache which I don't think I'll even
try to tackle right now.
On the plus side, my code managed to cope with <META
http-equiv="PICS-Label" content='(PICS-1.0
"http://www.rsac.org/ratingsv01.html" l gen true comment "RSACi
North America Server" by "dan@hardnet.co.uk" for
"http://www.ogilvy.com" on "1996.04.16T08:15-0500" exp
"1997.07.01T08:15-0500" r (n 0 s 0 v 0 l 0))'>
Enough already! Here's the code:
(call using, for e.g., %pairs=&tag_attribs('<META NAME="Author"
CONTENT="Dan Sumption">');
sub tag_attribs
{
local ($_, *pairs) = shift;
s/^\s*<\s*\w+\s*([^>]*)>.*/$1/;
local ($attribute, $value,$separator, %pairs) = '';
while ($_) {
s/^\s*((\w|-)+)\s*//;
$attribute = $1;
if (s/^\s*=\s*//) {
if (s/^\s*("|')//) {
$separator = $1;
s/^([^$1]*)$1\s*//;
$value = $1;
}
else {
s/^(\S*)\s*//;
$value = $1;
}
}
else {
$value = '';
}
$pairs{$attribute} = $value;
s/^\s*//;
}
%pairs;
}
-------------------------------------------------------------------
Dan Sumption : dan@gulch.demon.co.uk
Hard Media, London SE1 dan@hardnet.co.uk
-------Yell/.net award winners-------
Home (meow!): http://www.hardnet.co.uk/dan/
Work (mooo!): http://www.hardnet.co.uk/
------------------------------
Date: 18 Mar 1997 18:21:57 -0800
From: Russ Allbery <rra@cs.stanford.edu>
To: walshemj@boat.bt.com
Subject: Re: Regular Expressions Problem
Message-Id: <qumlo7kr58a.fsf@cyclone.stanford.edu>
[ Posted and mailed. ]
maurice walshe <walshemj@boat.bt.com> writes:
> so I want a regular expression that matches string/any_valid_directory/
> but not any further down for example hear is some test code illustrating
> this $good_target should match and $badtarget should not.
> #!/usr/local/bin/perl
> #
> $search = "/www/foo/Products/;
> $good_target = "/www/foo/Products/Wombats/";
> $bad_target "/www/foo/Products/Wombats/Leamur_conspiracy/";
> if ($search =~ /$target?=(\/+[a-z*A-Z*]+\//)) {
> Print " Matched \n";
> }
$search =~ m%^$target/+(?!\.\./*$)[^/]*/*$%;
will match $target, followed by one or more /s, followed by a directory
name (something not containing a /), followed by zero or more slashes.
The reason for the:
(?!\.\./*$)
part is to avoid matching the special directory .., which you don't want
to allow. You may want to disallow . as well, in which case you should
make that:
(?!\.\.?/*$)
and change [^/]* to [^/]+ (that will prevent matching just $target). Note
that if $target doesn't change, you'll want to put an /o modifier on that
regex.
--
Russ Allbery (rra@cs.stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: Tue, 18 Mar 1997 15:57:45 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: James Patterson <renman@callamer.com>
Subject: Re: Reloading web pages
Message-Id: <Pine.GSO.3.96.970318155045.6855K-100000@kelly.teleport.com>
On Sat, 15 Mar 1997, James Patterson wrote:
> One of the cgi scripts I have edits an html page and then calls that
> page. I just switched servers and now the page doesn't reload
> automatically as it should.
I may be mistaken here, but it sounds as if you're now using a browser and
a server, they aren't doing what you want, but neither of them is written
in Perl. If that's the case, how can Perl possibly help? (If you don't
like the drive-in movie, it doesn't help to give your car a tune up.)
Maybe you want to check your server's manual, or maybe your browser's.
(The section about caching might be helpful.) If you have more questions,
they may be answered in a newsgroup about servers or browsers, or even in
that group's FAQ. Good luck!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Tue, 18 Mar 1997 15:54:53 -0800
From: Daniel Glassman <dglass@swpartners.com>
Subject: San Diego Sybase Job Opportunity!!!
Message-Id: <332F2B4D.4927@swpartners.com>
Sybase Engineers Wanted!!!
Software Partners is a solutions oriented consulting company serving the
southern California area. We specialize in developing custom
client/server
applications, such as data-driven intranets and Internet web sites. We
are
also an authorized reseller of Sybase and PowerBuilder products. We
provide quality service to our customers and have an excellent track of
achieving total customer satisfaction.
Software Partners currently has several job openings for Sybase
engineers
who will be assigned to work with one of our key customers in the
financial
services industry. Job assignment areas include Sybase Reporting,
Sybase
Data Integrity, Sybase/Forte Application Development, Sybase/Visual
Basic Application Development, Sybase Data Import, and Sybase DBA.
The successful candidate will have a Bachelors or Masters degree in
Computer
Science or related discipline, will have at least one year of Sybase
experience,
will have strong Unix skills, and will enjoy working in customer
environments.
The Forte assignment also requires one year of Forte experience.
If this sounds good to you, mail, fax, or e-mail your resume to:
Human Resources
Software Partners
Box 230229
Encinitas, CA 92023-0229
Fax: (619) 350-0372
email: dglass@swpartners.com
------------------------------
Date: Wed, 19 Mar 97 01:27:30 GMT
From: sussex@interlog.com (Sussex Silversmiths)
Subject: Re: simple glob fails under Linux
Message-Id: <5gnfjb$as5@news.interlog.com>
Keywords: perl linux glob bug
In article <5gih2m$c9k@news.interlog.com>,
sussex@interlog.com (Sussex Silversmiths) wrote:
>I can't get directory globbing to work under the August 96 slackware
>distribution of Linux 2.0, Perl 5.003.
Thanks to all the helpful people who replied directly to me, the solution
is that the Perl binary distributed with Slackware requires a shell not
provided in that distribution. The following fixes the problem:
# cd /bin
# ln -s tcsh csh
by providing a symbolic link to let Perl find a csh compatible.
Thank You,
Peter Wooster
sussex@interlog.com
------------------------------
Date: Tue, 18 Mar 1997 18:20:22 -0800
From: Lewis Taylor <lewis@nexusint.com>
Subject: Re: Split
Message-Id: <332F4D66.37B7@nexusint.com>
Fapso Marek wrote:
>
>
> Hi all!
> I have a program:
>
> $tmp="a|||b|||";
> @li=split('\|',$tmp);
>
> This program split string into array with size only 4. Why?
> Marek !
>
> --
> fapsom@hron.fei.tuke.sk
I have copied and tested your prog and it appears that the PERL split
command only recognises occurences up to the last non empty occurance.
ie,
a|||b|||||||||||||||||||||||||||||||||
would also give four. One unelegant but practical solution, is therefore
to append some arbitrary character to the string, split it and then
remove the last element.ie,
$tmp="a|||b|||";
$tmp=$tmp."a";
@li=split('\|',$tmp);
pop(@li);
It works!
Lewis
------------------------------
Date: Tue, 18 Mar 1997 15:54:55 -0800
From: Steve Fink <sfink@cs.berkeley.edu>
To: abigail@ny.fnx.com
Subject: Re: term 'regular expressions' considered undesirable
Message-Id: <332F2B4F.75E9@cs.berkeley.edu>
My apologies for putting this on a perl newsgroup, but it sorta kinda
relates.
> AFAIK the class of "all languages minus a
> regular one" isn't regular, and you can describe that language with
> /^(?!$regex$)/. (You can do intersection and subtraction of RE's
> with look-a-head too.)
Actually, it's more clearly described as "all strings not matched by a
given regex", which is regular, for a very simple reason that is very
non-simple until someone tells you the trick. ;)
Simple explanation: there is a 1-1 correspondence between regexes and
NFAs. To negate an NFA, make every accepting state non-accepting, and
vice versa.
It seems like intersection could be done by... er... taking the
cartesian product of the power sets of the states in the two NFAs, and
then making a state accepting iff it contains at least one accepting
state from the first NFA *and* from the second NFA. But I'm just doing
that off the top of my head and I suck at these sorts of things. For all
I know, regular languages may not be closed under intersection.
So now can anyone give me the simple explanation for why language
ambiguity is undecidable? I should know this, but I don't and I'm too
lazy to look it up. (And please don't send it to the perl newsgroup!)
------------------------------
Date: Tue, 18 Mar 1997 17:47:43 -0800
From: Lewis Taylor <lewis@nexusint.com>
Subject: text to HTML
Message-Id: <332F45BF.312A@nexusint.com>
I am currently writing a primative text to HTML routine. I want to
replace all instances of double carriage return (\n\n) with a paragraph
tag. But this :
$big_string =~ s/\n\n/<P>/g;
does'nt seem to do anything. I have also tried the two \n's in a
variable to no avail. Other printable chars in place of \n\n work. Can
someone please help?
Thanks in advance,
Lewis Taylor (lewis@nexusint.com)
Infinet Communications Inc.
------------------------------
Date: Tue, 18 Mar 1997 23:55:07 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: text to HTML
Message-Id: <ebohlmanE79Jrw.EDE@netcom.com>
Lewis Taylor (lewis@nexusint.com) wrote:
: I am currently writing a primative text to HTML routine. I want to
: replace all instances of double carriage return (\n\n) with a paragraph
: tag. But this :
: $big_string =~ s/\n\n/<P>/g;
By default, patterns don't match across line boundaries. You need to use
the m option to enable this, so the line should end with "/gm" instead of
just "/g".
------------------------------
Date: 19 Mar 1997 00:56:40 GMT
From: mal@nautronix.com.au (Malcolm Cifuentes)
Subject: Re: Unix vs WIN95 equivalents
Message-Id: <5gndk8$kmv@b2.nautronix.com.au>
In article <332C55D8.5CAC@worldnet.att.net>,
Mark Miller <M.P.Miller@worldnet.att.net> writes:
>I am using the llama book and am having difficulty finding any kind of
>documentation explaining equivalent keystrokes between Unix and WIN95. As an
>example, on page 65, it explains how to end a manually entered array: press
>"Control-D" and then the script will continue. This combination does not work
>in WIN95. Instead, I've had to use the following:
>
Have you tyried "Control-Z", I know this has the same effect as "Control-D"
for some applications between unix and 95.
mal
------------------------------
Date: Tue, 18 Mar 1997 23:22:22 GMT
From: cgsystem@dircon.co.uk (Zac)
Subject: Windows 3.11 and Perl
Message-Id: <5gn7l7$2mi$2@newsserver.dircon.co.uk>
Is it possible to learn Perl on an old 486 running 3.11.
I have a virtual Web Server with a full CGI capability, and very
little idea on how to use it.
Any tips or advice would be gratefully received.
Regards
Zac
------
------------------------------
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 141
*************************************