[8043] in Perl-Users-Digest
Perl-Users Digest, Issue: 1668 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 18 21:08:05 1998
Date: Sun, 18 Jan 98 18:00:32 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 18 Jan 1998 Volume: 8 Number: 1668
Today's topics:
Re: Access Log (Martien Verbruggen)
Re: Building indexes in Perl <rootbeer@teleport.com>
Re: can you attach a password (Martien Verbruggen)
Determining file type <scriptabuser@127.0.0.1>
Download Usenet group <lkl@runge.uni-c.dk>
Re: Find::file running slow (Martien Verbruggen)
Free Cgi-Bin <cybercom@pacific.net.sg>
Re: Free Cgi-Bin <rootbeer@teleport.com>
FrontPage 98 <xvt28@dial.pipex.com>
Re: FrontPage 98 (Jeremy D. Zawodny)
Re: get machine name from IP? <scriptabuser@127.0.0.1>
Re: GetOpts::Std and 'Use of Uninitialized variable' er <rootbeer@teleport.com>
Re: Hello... I need HELP!!! <rootbeer@teleport.com>
Re: I am still a virgin (Jonathan Stowe)
Re: I need some help pleeze (Martien Verbruggen)
Re: JavaScript & Perl (Joshua J. Kugler)
Re: JavaScript & Perl <rootbeer@teleport.com>
Re: Looking for online auction script (Martien Verbruggen)
Re: module to calculate dates? <corky@ultranet.com>
Re: Parsing HTML tag parameters <rjk@coos.dartmouth.edu>
Re: Pattern match of no character, any character, or sp (Martien Verbruggen)
Perl for Win32 <ordway@iwshost.net>
Re: Perl for Win32 (Jeremy D. Zawodny)
Perl Library <jpowell@*NOSPAM*ieee.engg.uregina.ca>
Re: Question about @INC and require <rootbeer@teleport.com>
Re: Read STDERR from child? (David Efflandt)
Reading a .dat file for a password <e.phillips@mindspring.com>
Re: REGEXP: Does it need optimization? (Tad McClellan)
Re: Searching for bitypes.h (Martien Verbruggen)
Re: source into binary code <danboo@negia.net>
system() call fails at redirection operator <brannon@surf.usc.edu>
Re: UserAgent Post/Get, Print, Here, etc. <rootbeer@teleport.com>
Re: Why does'nt this sub work <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Jan 1998 00:06:04 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Access Log
Message-Id: <69u5dc$cdh$1@comdyn.comdyn.com.au>
(The originals of the included messages in this post didn't make it to
my news server yet, so I am using this one)
In article <69qiml$jq6$4@winter.news.erols.com>,
wcb4@erols.com (William Byrd) writes:
> On Fri, 16 Jan 1998 01:35:36 +0100, Geurt Schimmel <geurt@sybase.com>
> wrote:
>
>>Hans Van Lint wrote:
>>
>>> $logfile = "../logs/access_log";
>>> open(best, $logfile) || "Error"
You need to do something like
open(BEST, $logfile) or die "error: $!";
You need the die, and the $! will tell you what exactly went wrong.
(File handles normally are uppercased)
>>> I get the following error:
>>> ../logs/access_log: Permission denied
Looks like you're not allowed to read it. Can you read it with
less, more or cat?
>>In fact, you'r trying open(best,"> $logfile") - and that won't work if you're
>>not root. When running this program as root, it will remove the logfile
>>completely...
>>
>>Try open(best,"< $logfile");
Not necessary. Without any specifiers before the filename, open will
default to open for reading. Not open for writing.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Very funny Scotty, now beam down my
Commercial Dynamics Pty. Ltd. | clothes.
NSW, Australia |
------------------------------
Date: Sun, 18 Jan 1998 17:19:56 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: FRIHA Lamia <friha@cui.unige.ch>
Subject: Re: Building indexes in Perl
Message-Id: <Pine.GSO.3.96.980118171629.11982I-100000@user2.teleport.com>
On 18 Jan 1998, FRIHA Lamia wrote:
> I a beginner in Perl and have to build different indexes on a set of
> ASCII files, describing different products. Each file contains different
> informations on the product (+errors of syntax...etc). What is the best
> way to do that?
This is like going to a newsgroup about Toyotas and saying, "I am a
beginner at driving my Toyota, and I need to drive to one of the Great
Lakes. Which lake is the best?" :-)
If you're interested in finding about indexing techniques, any good
university's Computer Science library should be able to help you out. If
you've found an indexing technique which you are having trouble
implementing in Perl, we may be able to help you here. 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/
Ask me about Perl trainings!
------------------------------
Date: 19 Jan 1998 01:22:21 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: can you attach a password
Message-Id: <69u9sd$cr8$1@comdyn.comdyn.com.au>
In article <34BF8BB2.B49BFF6D@hc.ti.com>,
Toby Potts <potts@hc.ti.com> writes:
> Can you attach a password to a directory or group of directories that
> not even root can get into?
If that is possible, it is a system specific question, and has nothing
to do with perl at all. Try asking on a newsgroup that talks about
your operating system.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au |
Commercial Dynamics Pty. Ltd. | Curiouser and curiouser, said Alice.
NSW, Australia |
------------------------------
Date: Mon, 19 Jan 1998 00:56:39 +0000
From: Mark Worsdall <scriptabuser@127.0.0.1>
Subject: Determining file type
Message-Id: <jMGlTRAHTqw0EwsN@worsdall.demon.co.uk>
Hi,
I have a program that lists files, basically then a path/filename is
pass into a variable called:-
$pathfile
Now the program that has this file needs to work out what type of file
it is, graphic, text, binary etc, then it will do this:-
if (html or text) print "Content-type: text/html\n\n";
if (graphic) print "Content-type: image/gif\n\n";
(Here though I want it to display any image including jpegs etc)
if (binary) force broswer to download
Is there any modules to achieve my goal?
--
Mark Worsdall (Webmaster) - WEB site:- http://www.shadow.org.uk
Shadow:- webmasterATshadow.org.uk
Home :- shadowwebATworsdall.demon.co.uk
Any opinion given is my own personal belief...
------------------------------
Date: Mon, 19 Jan 1998 02:15:38 +0100
From: "Lars Kr. Lundin" <lkl@runge.uni-c.dk>
Subject: Download Usenet group
Message-Id: <34C2A93A.FF6@runge.uni-c.dk>
Can anybody tell me how I can use perl to download the postings
in a Usenet group?
Thank you,
Lars.
--
M.Sc. Lars Kr. Lundin. | Problems worthy
IMM, Technical University of Denmark. | of attack
Phone (Office) +45 4525 3079, Fax +45 4593 2373. | prove their worth
E-mail: lkl@runge.uni-c.dk | by hitting back
URL: http://www.imm.dtu.dk/~lkl/ | -Piet Hein
Currently stationed at:
Department of Computer Science
University of Minnesota
6-210 EE/CS Building
200 Union Street SE
Minneapolis, MN 55455
USA
Phone: +1 612 626 0071
Fax: +1 612 625 0572
------------------------------
Date: 19 Jan 1998 00:26:33 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Find::file running slow
Message-Id: <69u6jp$cdh$3@comdyn.comdyn.com.au>
In article <34BDC12B.5B58F00E@virgin.net>,
Andrew Spiers <andrew.spiers@virgin.net> writes:
> #!/usr/bin/perl
[snip]
> sub wanted { return unless /htm/; push @ARGV, $File::Find::name; };
>
> foreach $file (@ARGV) {
> print pre("$file\n");
> }
You probably shouldn't be using @ARGV for this. Use an array that is
not a perl internal variable, unless you know that this is exactly
what you want.
> Yet when I add another print line after print pre("$file\n"); does the
> sript take ages to run ?
It shouldn't. What is the print line that you add?
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | The gene pool could use a little
Commercial Dynamics Pty. Ltd. | chlorine.
NSW, Australia |
------------------------------
Date: Mon, 19 Jan 1998 07:28:28 +0800
From: "Ho Seng Yip" <cybercom@pacific.net.sg>
Subject: Free Cgi-Bin
Message-Id: <69u3i9$ctn$2@newton.pacific.net.sg>
Hi,
Anyone knows if any company or website offers free cgi-bin access which
anyone can apply ? Will like to run some perl scripts but my current
provider hosting my webpage does not allow telnet access to their cgi-bin.
Thanks. ;-)
Regards,
Seng Yip
------------------------------
Date: Sun, 18 Jan 1998 17:36:18 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ho Seng Yip <cybercom@pacific.net.sg>
Subject: Re: Free Cgi-Bin
Message-Id: <Pine.GSO.3.96.980118173203.11982L-100000@user2.teleport.com>
On Mon, 19 Jan 1998, Ho Seng Yip wrote:
> Anyone knows if any company or website offers free cgi-bin access which
> anyone can apply ? Will like to run some perl scripts but my current
> provider hosting my webpage does not allow telnet access to their
> cgi-bin.
Of course, there's nothing Perl-specific about this; the cgi-bin directory
doesn't care what language the programs are written in. But would you
really trust your data to a sysadmin who allows just _anybody_ to install
scripts? That's like sending your children to the daycare center in the
state penitentiary's license plate factory. :-)
--
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/
Ask me about Perl trainings!
------------------------------
Date: 18 Jan 1998 23:06:48 GMT
From: "Colin Dixon" <xvt28@dial.pipex.com>
Subject: FrontPage 98
Message-Id: <01bd2465$678c80c0$77f682c1@hal>
Does anyone one have some intructions on configuring Perl to interface to
the Web Server provided with Front Page 98
------------------------------
Date: Mon, 19 Jan 1998 00:55:21 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: FrontPage 98
Message-Id: <34c2a463.14738853@woody.wcnet.org>
[original author automagically cc'd via e-mail]
On 18 Jan 1998 23:06:48 GMT, "Colin Dixon" <xvt28@dial.pipex.com>
wrote:
>Does anyone one have some intructions on configuring Perl to interface to
>the Web Server provided with Front Page 98
The Microsoft Knowledge Base does. You might look there.
Jeremy
--
Jeremy D. Zawodny jzawodn@wcnet.org
Web Server Administrator www@wcnet.org
Wood County Free Net (Ohio) http://www.wcnet.org/
------------------------------
Date: Mon, 19 Jan 1998 00:50:13 +0000
From: Mark Worsdall <scriptabuser@127.0.0.1>
Subject: Re: get machine name from IP?
Message-Id: <6sWjbNAFNqw0EwtQ@worsdall.demon.co.uk>
Try this, works for me:-
1) Obtain IP number
2) Untaint the IP number passed
3) Ensure one IP number is used
4) Resolve into domain name
5) Further to this see is domain has a website
It is probably very untidy and sloppy, but it works, any suggestions for
improving will be gratefully recieved.
Maybe someone can help me with my problem, look for the subject:-
Determining file type
$httpheader = 'http://www.';
# Untaint the IP numbers, they might be multiple (1 2 or 3 numbers)
$surfer = $ENV{'HTTP_X_FORWARDED_FOR'} || 'Nothing';
if (defined $surfer) {
my @list = split /,\s*/, $surfer;
for (@list) {
if (/^([-@\w.]+)$/) { # Right pattern?
$_ = $1;
} else {
warn "Can't extract from '$_', skipping";
$_ = undef;
}
}
$surfer = # what you get when you
join ', ' , # join with commas
grep defined, # the defined elemens of
@list; # that list
} else {
$surfer = 'nothing';
}
########################################
# Now extract a single IP number if multiple
# numbers passed
$surfername = $surfer;
$surfername =~ s/ //g; # drop spaces
if (index($surfername, ',') != -1) {
@ips = split (',', $surfername);
foreach (@ips) {
next if (/unknown/);
next if (/nothing/);
next if (index($_, '10.') == 0);
$surfername = $_;
last;
}
}
########################################
# Translate variable $surfername from IP address into domain name
if ($surfername =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/) {
($dns) = gethostbyaddr(pack("C4",$1,$2,$3,$4),2);
$surfername = $dns if ($dns);
$surfername = lc($surfername);
}
# If $surfername has been successfully translated into domain name
# See if we can trim it down more by seeing if there is a website there.
if ($surfername !~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/) {
$oldsurfer = $surfername;
print ERR "$oldsurfer\n$surfername\n";
$status = 500;
$surfername = "dummy." . $surfername;
while ((index($surfername, ".") != -1) && ($status != 200)) {
$pos = index($surfername , ".") + 1;
$surfername = substr($surfername, $pos);
$ua = new LWP::UserAgent;
$request = new HTTP::Request('GET' ,
"$httpheader$surfername" );
$response = $ua->request($request);
$status = $response->code ? $response->code : 'NULL';
}
if ((index($surfername, ".") == -1) && ($status != 200)) {
$surfername = $oldsurfer;
} else { $oldsurfer= ''; }
}
--
Mark Worsdall (Webmaster) - WEB site:- http://www.shadow.org.uk
Shadow:- webmasterATshadow.org.uk
Home :- shadowwebATworsdall.demon.co.uk
Any opinion given is my own personal belief...
------------------------------
Date: Sun, 18 Jan 1998 17:07:48 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Mark Hazen <mhazen@franklin.uga.edu>
Subject: Re: GetOpts::Std and 'Use of Uninitialized variable' errors?
Message-Id: <Pine.GSO.3.96.980118165007.11982F-100000@user2.teleport.com>
On Sat, 17 Jan 1998, Mark Hazen wrote:
> I can't use the '-T' flag (as far as I know) because of two things: one
> of the command line options allows the user to point anywhere they wish
> to for a config file (which I parse as carefully as I know how),
That needn't preclude taint checking. You should verify that the filename
given is valid and meets any other criteria you need (stat and the
filetest operators should be all right; you may or may not care about
checking the directories and possible symlinks along the path to the
file). Then you may use the methods in the perlsec manpage to make an
untainted copy of the filename, which you may then use however you need.
You may wish to require the config file to be located in one of a short
list of safe places, such as the user's own home directory or a known-good
system directory.
> and secondly, the nature of the program builds large arrays of files,
> directories and their subdirectories using File::Find, and even if it
> works, I'm cautious about stuffing 400 directories into $ENV{'PATH'}.
As you should be; that's almost certainly the wrong approach. Did you
realize that you needn't put a program's containing directory into the
PATH in order to run the program? I can't see why anyone would want such a
lengthy PATH.
> This program does nothing to files except generate complex file age
> reports, so I'm not too worried about overeager users using it to hack
> other files (all output is to STDOUT).
Maybe you don't need taint checking, then. But what's the config file all
about? And why should you need a PATH at all?
> I could be wrong about that was well, but seeing as this is a script
> only accessible by root anyhow, if the a user other than myself can run
> it in the first place, I've got more serious problems. :-)
Why didn't you say that in the first place? :-) That's easy to take care
of:
BEGIN { die "Can't run $0 if not root" if $< or $> }
Of course, if root is running it, who cares where the config file is? And
taint checking is probably a waste of time, right? (Why would root have to
feed bogus data to the script? Root can edit the script!)
> 1) If I try to initialize a variable ahead of time which getopts() would
> return a value in, getopts will not return a value properly. This is to
> say, if I include a line befre the call to getopts() which said "my
> $opt_v;" $opt_v will never be set to '1' by getopts() even if I call my
> program with a '-v' option. Is there a reason for this behavior?
Yes; my() variables aren't accessible by name outside their scope. The
module is, I'm sure, setting the corresponding global variable.
> 2) If I try to test the status of a variable set by getopt() using "if
> ($opt_d = 1)"
That's not right. == perhaps?
> I get a "Use of Uninitalized variable" error for that
> line, but if I test via "if ($opt_d)" I get no error. Can someone
> explain to me the difference?
Undef is a false value. After using the module, you could set defaults
with something like this...
$opt_d = 0 unless defined $opt_d;
$opt_q = 'foo' unless defined $opt_q;
...but if you're only testing something for true/false, it's simpler to
use the if test.
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/
Ask me about Perl trainings!
------------------------------
Date: Sun, 18 Jan 1998 17:12:51 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Walter Archie <warchie@att.net.hk>
Subject: Re: Hello... I need HELP!!!
Message-Id: <Pine.GSO.3.96.980118170934.11982G-100000@user2.teleport.com>
On Sun, 18 Jan 1998, Walter Archie wrote:
> Subject: Hello... I need HELP!!!
Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
> #! use/perl/bin
Is that right?
> sub parse_form {
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> if (length($buffer) < 5) {
> $buffer=$ENV{'QUERY_STRING'};
> }
You should really use CGI.pm to do this decoding. It has many virtues.
Highly ranked among them is that it does this...
> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs) {
> ($name, $value) = split(/=/, $pair);
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
> $FORM{$name} = $value;
> }
> }
...but CGI.pm actually does it properly. :-)
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/
Ask me about Perl trainings!
------------------------------
Date: 18 Jan 1998 22:59:57 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: I am still a virgin
Message-Id: <69u1hd$j3n$1@plutonium.btinternet.com>
In article <34C22707.304E3D13@hotmail.com>, katigaebler@hotmail.com says...
>
>Hello,
>
>Could someone help me get started.
>
>I made a simple test and placed
>it in my cgi bin:
>
<example code snipped>
This is due to a http server configuration problem almost certainly. I
would read the docs on your server software and check your cgi-bin directory
is set as being executable for the server.
Jonathan
------------------------------
Date: 19 Jan 1998 01:37:03 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: I need some help pleeze
Message-Id: <69uanv$cr8$2@comdyn.comdyn.com.au>
In article <34C15176.2983@datasync.com>,
Jay Hodges <jhodges@datasync.com> writes:
> if ($sex == "M") {$sex_a++;}
> elsif ($sex == "F") {$sex_b++;}
elsif? No else? Do you plan to support more than 2 sexes? :)
Anyway, you'd want to use the eq operator, not the ==.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Make it idiot proof and someone will
Commercial Dynamics Pty. Ltd. | make a better idiot.
NSW, Australia |
------------------------------
Date: Sun, 18 Jan 1998 23:08:33 GMT
From: jkugler@inreach.com (Joshua J. Kugler)
Subject: Re: JavaScript & Perl
Message-Id: <34c28b22.13593058@news.inreach.com>
On Sun, 18 Jan 1998 00:30:40 -0500, "Jerry Davis" <gedavis3@vt.edu>
wrote:
()For example the javascript command document.referrer will return the
()referring page. I am wondering if there is a way to pass that into
a script
()via the get method.
Look at the HTTP_REFERRER env% variable. That should help.
I read this group. Sometimes my ISP doesn't. Please e-mail too.
Joshua J. Kugler
Computer Consultant--Web Developer
jkugler@inreach.com
http://www.cwebpages.com/jkugler
Every knee shall bow, and every tongue confess, in heaven, on earth, and under the earth, that Jesus Christ is LORD -- Count on it!
------------------------------
Date: Sun, 18 Jan 1998 17:14:31 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Jerry Davis <gedavis3@vt.edu>
Subject: Re: JavaScript & Perl
Message-Id: <Pine.GSO.3.96.980118171323.11982H-100000@user2.teleport.com>
On Sun, 18 Jan 1998, Jerry Davis wrote:
> Anyone know if it is possible to pass a value from java script into a
> perl program.
If it's possible at all, you'd use the same technique passing data from
JavaScript to any other scripting language; there's nothing Perl-specific
about it. Your docs about JavaScript should be able to answer your
question, or you could ask in a newsgroup about JavaScript. 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/
Ask me about Perl trainings!
------------------------------
Date: 19 Jan 1998 00:18:35 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Looking for online auction script
Message-Id: <69u64r$cdh$2@comdyn.comdyn.com.au>
> excuse me!
>
> correct me if i'm wrong but cant cgi written in P E R L ? ? ?
>
> darny
That is beside the point. It can be written in virtually any language.
The matter is that questions about the CGI protocol should go to one
of the CGI groups. If you choose to write your CGI scripts in perl,
then you can ask any *perl specific* questions here. That does NOT
include the CGI protocol.
"I have written a program in perl that connects to our proprietary
BLURBIE server, using our self devised BLURB protocol. Can you people
please explain that protocol to me?"
Martien
PS. Yes, I know I'm stretching the point.
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | We are born naked, wet and hungry. Then
Commercial Dynamics Pty. Ltd. | things get worse.
NSW, Australia |
------------------------------
Date: Sun, 18 Jan 1998 18:25:01 -0500
From: Bob Trieger <corky@ultranet.com>
To: rjk@coos.dartmouth.edu
Subject: Re: module to calculate dates?
Message-Id: <34C28F4D.2953@ultranet.com>
[posted and mailed]
Chipmunk wrote:
>
>
> Bob Trieger wrote:
> >
> > Dean Burdick wrote:
> > >
> > > In article <34BFF7A0.2BFE@ultranet.com>, corky@ultranet.com says...
> > > >
> > > >Is there a perl module/library out there that calculates dates?
> >
> > > Check out the 'datemanip' module on CPAN.
> >
> > I left out one tiny fact. I am doing this on an NT server and can't get
> > datemanip or datecalc to install correctly.
>
> In other words, your question is not "Is there a perl module that
> calculates dates?" but "How do I correctly install this perl module?"
>
Actually my post was meant to read "is there a perl32 module/library
that calculates dates?" I asked about installing the CPAN modules in
another post.
------------------------------
Date: Sun, 18 Jan 1998 18:35:51 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: Parsing HTML tag parameters
Message-Id: <34C291D6.D4E9F9E2@coos.dartmouth.edu>
nobody@nowhere wrote:
>
> >Ben Glazer (ben.glazer@mail.utexas.edu) wrote on 1600 September 1993 in
> ><URL: news:34c092cb.93214615@newshost.cc.utexas.edu>:
> >++ All I want to do is split the parameter list of an HTML tag into an
> >++ array. So, for example, starting off with input of
> >++
> >++ <img src="pish.gif" alt="hello kitty" width=100>
> >++
> >++ my program sets
> >++
> >++ $params = "src=\"pish.gif\" alt=\"hello kitty\" width=100";
> >++
> >++ which is all well and good. Now all I want to do is find some way to
> >++ set
> >++
> >++ @params = (
> >++ "src=\"pish.gif\",
> >++ "alt=\"hello kitty\",
> >++ "width=100")
> >
> Try this:
> @params = split(/\s+/, $params);
Hmm... I wonder what that would do if there were spaces within the
quoted parameter arguments.
As there are in the example provided by the original poster, say.
Chipmunk
------------------------------
Date: 19 Jan 1998 01:08:52 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Pattern match of no character, any character, or space (word boundary)
Message-Id: <69u934$cqv$1@comdyn.comdyn.com.au>
In article <884984012.1064566799@dejanews.com>,
cotal@delphi.com writes:
> as[/ ]?400 matches as/400
It also matches 'as400' and 'as 400' (where ' ' is a space, which is what
you specified).
> as[ /]?400 matches as400 and as/400
This also matches 'as 400', where ' ' is a space.
What are you using as the delimiter for m// ? What exactly is that
empty space in there?
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au |
Commercial Dynamics Pty. Ltd. | Curiouser and curiouser, said Alice.
NSW, Australia |
------------------------------
Date: Sun, 18 Jan 1998 17:56:50 -0600
From: "Brandon" <ordway@iwshost.net>
Subject: Perl for Win32
Message-Id: <69u4nf$5h1$1@reggie.win.bright.net>
I have made a few programs for perl in win32. Is there anyway that I can
put an icon on my desktop and have it execute those perl programs instead of
going into dos prompt and typing "perl myscript.pl"? Email me or reply to
this post. Thanks!
ordway@iwshost.net
------------------------------
Date: Mon, 19 Jan 1998 00:56:09 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Perl for Win32
Message-Id: <34c3a48e.14781414@woody.wcnet.org>
[original author automagically cc'd via e-mail]
On Sun, 18 Jan 1998 17:56:50 -0600, "Brandon" <ordway@iwshost.net>
wrote:
>I have made a few programs for perl in win32. Is there anyway that I can
>put an icon on my desktop and have it execute those perl programs instead of
>going into dos prompt and typing "perl myscript.pl"? Email me or reply to
>this post. Thanks!
There's nothing special about Perl scripts. Treat them as you would
any other "program" and it will work fine.
Jeremy
--
Jeremy D. Zawodny jzawodn@wcnet.org
Web Server Administrator www@wcnet.org
Wood County Free Net (Ohio) http://www.wcnet.org/
------------------------------
Date: Sun, 18 Jan 1998 16:47:01 -0600
From: "John R. Powell" <jpowell@*NOSPAM*ieee.engg.uregina.ca>
Subject: Perl Library
Message-Id: <Pine.LNX.3.96.980118164512.3629A-100000@ieee.engg.uregina.ca>
Where would one find sample 'database' perl scripts to be run on Linux?
Please reply direct removing *NOSPAM*.
Thanx,
John Powell
Sysadmin, IEEE South Saskatchewan Section
jpowell@*NOSPAM*ieee.engg.uregina.ca
REMOVE *NOSPAM* before replying
------------------------------
Date: Sun, 18 Jan 1998 16:45:36 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Gary Nielson <gnielson@charlotte.infi.net>
Subject: Re: Question about @INC and require
Message-Id: <Pine.GSO.3.96.980118164059.11982D-100000@user2.teleport.com>
On Sun, 18 Jan 1998, Gary Nielson wrote:
> Is it a true statement that the @INC path is compiled into perl when you
> build it?
Yes.
> If so, how can I find out what that @INC path is on a remote virtual
> host?
There's more than one way to do it. Maybe you could ask the person who
gives you permission to run Perl on that machine what it's @INC path is.
Or, you could run a program that would output @INC. Or you could use the
command 'perl -V' and get lots of good information about it.
> Does this mean that when you write a require in a script, say:
>
> require 'cgi-lib.pl';
>
> that it will look for that *.pl in the @INC path?
That's what it's documented to do. :-) But you should use CGI.pm instead
of cgi-lib.pl, really.
> What if you just want to include your cgi-lib.pl or whatever in the very
> same path as the script you are running?
Then you should modify @INC before the require.
> How can you add or modify an already coded-up @INC path in your script
> to accommodate a file that may be outside that path?
You could use unshift, or any other way of adding info to an array. Or
'use lib', which is often easier.
For more information, see the perlfunc manpage, and the docs for lib.pm
and CGI.pm. 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/
Ask me about Perl trainings!
------------------------------
Date: Mon, 19 Jan 1998 01:40:41 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Read STDERR from child?
Message-Id: <34c2ac3e.185094@flood.xnet.com>
efflandt@xnet.com (David Efflandt) wrote:
>Now if I could just find a faq on redirection so I can figure out how
>to the following (my 'man bash' lacks multiple redirection info):
>
>1. Capture STDERR from one external process in real time (instead of
>after it exits) and STDOUT >file.
>
> &&
>
>2. Process data from STDERR part 1 and send it to STDIN of 2nd
>external process in real time and leave STDOUT of the second process
>alone. All attempts at part 2 either result in no display or an
>initial display and no screen update until all data has been sent.
Nevermind, I got it all figured out. But I couldn't have done it
without the 3>&1 1>&2 2>&3 3>&- trick from Justin Vallon. Thanks
again.
The final thing that tripped me up was that the stderr status I was
trying to monitor in part 1 just refreshed a single line, so I got
nothing until eof. Once I set $/ = "\r", everything flowed. Part 2
turned out to be a simple pipe with select used to point to it and
free up stdout for the part 2 screen display.
David Efflandt/Elgin, IL USA
efflandt@xnet.com http://www.xnet.com/~efflandt/
------------------------------
Date: Sat, 17 Jan 1998 20:01:14 -0000
From: "Eric Phillips" <e.phillips@mindspring.com>
Subject: Reading a .dat file for a password
Message-Id: <69u8n8$krk@camel12.mindspring.com>
I have had some problems in the past reading a file called "users.dat" file
for a login and a password. Here's the syntax of the users.dat file:
login|password
Could someone tell me how to read (with Perl) that users.dat file line by
line to confirm if the user is registered (login and password are correct)?
My problem in the past was that it would only read the bottom line, thus
only the user on the bottom could login.
Thanks!
--
Eric Phillips
e.phillips@mindspring.com
------------------------------
Date: Sun, 18 Jan 1998 16:45:18 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: REGEXP: Does it need optimization?
Message-Id: <ul0u96.qhg.ln@localhost>
Rick Freeman (rick@marinweb.com) wrote:
: I'm pretty new to this and was wondering if anhone has any suggestions
: here. A search script I modified now uses the following regexp to
: exclude portions of an HTML page from searches:
: s#(^.*)(</head>.*<!--content-->)(.*)(<!--/content-->.*$)#\1 \3#i
^^ ^^
^^ ^^
I see you are not using the -w switch.
You should *always* use the -w switch...
That only "works" if the part to be excluded is on the same line.
Expecting it to be on the same line is Not Good.
s///si; # let dot match a newline
^
I would not trust wherever you copied the original script from.
Either the author is silly, or it is several years old. Nobody
with any sense writes it that way anymore.
: I have the following concerns:
: 1. Should I be using the non-greedy modifier on any of the *
: quantifiers? (Would that make it run faster?)
Non-greedy is often _slower_ than greedy.
The issue is not which will run faster, but which does The Right Thing.
You would want non-greedy in the $3 grouping if there could be more
than one delimited section in the file.
But since you require a </head> tag, I guess that is not an issue,
since having more than one of those would be pretty strange.
: 2. Is the performance hit from using /i very significant?
Yes. But again the question is doing the Right Thing.
Since HTML can be in any case, it won't do the Right Thing without the i.
: 3. /o wouldn't be useful here... would it?
No, not at all.
There is no variable part, so /o will have no effect.
Using /o also makes no sense unless the regex is in a loop. If it
is not in a loop, then it will be compiled only once anyway...
As to your questions about execution speed, the Benchmark module
can be used to compare the alternatives:
-------------------------
#!/usr/bin/perl -w
use Benchmark;
timethese(1000000, {
'exact case' => '$_ = q/REGEXP: Does it need optimization/;
s#need##',
'ignore case' => '$_ = q/REGEXP: Does it need optimization/;
s#need##i',
});
-------------------------
outputs:
Benchmark: timing 1000000 iterations of exact case, ignore case...
exact case: 15 secs (13.48 usr 0.00 sys = 13.48 cpu)
ignore case: 26 secs (26.03 usr 0.00 sys = 26.03 cpu)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 19 Jan 1998 00:28:41 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Searching for bitypes.h
Message-Id: <69u6np$cdh$4@comdyn.comdyn.com.au>
In article <34BDF6B8.B49@club-internet.fr>,
STOCK Fridiric <bidouye@club-internet.fr> writes:
> Hello,
>
> I'm trying to compile Perl5.003 under Sco Unix R3.2V4.2 with Gcc
If you install a version of perl, you better get the latest one
(5.004_04). it fixes lots of issues/bugs that exist in 5.003, and some
of the behaviour has changed.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | That's not a lie, it's a terminological
Commercial Dynamics Pty. Ltd. | inexactitude.
NSW, Australia |
------------------------------
Date: Sun, 18 Jan 1998 18:10:05 -0500
From: Dan Boorstein <danboo@negia.net>
Subject: Re: source into binary code
Message-Id: <34C28BCD.CA98628A@negia.net>
Abigail wrote:
>
> Dan Boorstein (danboo@negia.net) wrote on 1601 September 1993 in
> <URL: news:34C1AB37.2F7675C0@negia.net>:
> ++ Abigail wrote:
> ++ >
> ++ > Rubbish. If they want to "steal" your code, and there is an easier
> ++ > alternative available, they won't use your code at all.
> ++
> ++ am i reading this correctly? if they want to steal my code and there
> ++ is an easier alternative which they take then my security has been
> ++ successful, hasn't it? they have been thwarted.
>
> Right. So, you are sitting there with your precious code, and
> noone buys/uses it. There are easier ways then encrypting to
> archieve that.
in your first comment above you clearly specified that i would prevent
people from "steal"ing my code. i agreed. now you have extrapolated from
there to include all who buy/use it. i now disagree. could you please
show the logical steps in this argument.
dan
------------------------------
Date: 18 Jan 1998 14:57:37 -0800
From: Terrence Brannon <brannon@surf.usc.edu>
Subject: system() call fails at redirection operator
Message-Id: <lbzpkts84e.fsf@lnc.usc.edu>
>From the shell, this perl script fails to execute an apparently simple
shell command with the following diagnostics errors:
brannon@lnc ~/rs/Seescape/web : ./run_canny.cgi
PnmToFlt: started
PnmToFlt: finished
sh: -c: line 1: syntax error near unexpected token `<'
sh: -c: line 1: `/usr/bin/imgFltToPnm < '
imgPnmToFlt < /newport/freeway/brannon/rs/Seescape/web/venice.pgm > /tmp/x.flt0
brannon@lnc ~/rs/Seescape/web :
======
I am executing Image::Star::PnmToFlt and it dies during the system
call right after printing the innocuous system command
=====
package Image::Star;
use Exporter;
@ISA = qw(Exporter);
sub Canny {
$filename = $_[0];
$result=`imgCanny < ${filename}`;
}
sub PnmToFlt {
$filename = $_[0];
$syscmd="imgPnmToFlt < ${filename} > /tmp/x.flt";
print $syscmd;
system($syscmd);
}
1;
===
I include the main program for reference:
#!/usr/bin/perl
BEGIN {
unshift(@INC, "/newport/freeway/brannon/rs/Seescape/web");
}
use English;
use CGI;
use IO::File;
use Seescape::Constants;
use Image::Star;
$fn="${Seescape::Constants::home}/venice.pgm";
$fpfile=Image::Star::PnmToFlt($fn);
$cmd="\`/usr/bin/imgFltToPnm < ${filename}\`";
$result=eval($cmd);
#$cnyimg=Image::Star::Canny($fpfile)
#$image = IO::File->new($fn);
#$the_cgi = CGI->new;
#print $the_cgi->header('image/gif');
#print $the_cgi->header('text/plain');
print $fpfile
--
Terrence Brannon * brannon@lnc.usc.edu * http://lnc.usc.edu/~brannon
USC, HNB, 3614 Watt Way, Los Angeles, CA 90089-2520 * (213) 740-3397
Got Milk? Should you? http://www.milk.com vs. http://www.notmilk.com
------------------------------
Date: Sun, 18 Jan 1998 16:39:54 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: SasEz! Publications and Design <sase@sasezdesyn.com>
Subject: Re: UserAgent Post/Get, Print, Here, etc.
Message-Id: <Pine.GSO.3.96.980118163623.11982C-100000@user2.teleport.com>
On Sat, 17 Jan 1998, SasEz! Publications and Design wrote:
> Now, when I run this from the command
> line it appears to work perfectly, no errors/dies/etc. But running
> from the browser (chmod'ed to 777 to rule that out) it returns a 500
> internal server error.
Don't chmod anything to 777 that doesn't contain your password. :-)
When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.
http://www.perl.com/CPAN/
http://www.perl.org/CPAN/
http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
http://www.perl.org/CPAN/doc/manual/html/pod/
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/
Ask me about Perl trainings!
------------------------------
Date: Sun, 18 Jan 1998 17:30:19 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Builders Connection <jim39@interworldnet.net>
Subject: Re: Why does'nt this sub work
Message-Id: <Pine.GSO.3.96.980118172809.11982J-100000@user2.teleport.com>
On Sun, 18 Jan 1998, Builders Connection wrote:
> the sub stordata in this program won't open and write to the file.
> open(FILE, ">> $stordata")|| die ("I can't open: Database\n");
Maybe you should fix that to provide a more informative diagnostic
message:
open FILE, ">> $stordata"
or die "Can't open file '$stordata' for append: $!";
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/
Ask me about Perl trainings!
------------------------------
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 1668
**************************************