[6517] in Perl-Users-Digest
Perl-Users Digest, Issue: 142 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 19 04:08:12 1997
Date: Wed, 19 Mar 97 01:00:27 -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 Wed, 19 Mar 1997 Volume: 8 Number: 142
Today's topics:
Re: /RE/ for Dummies - Match all caps <tchrist@mox.perl.com>
2 fields 2 files <john@mcl.net>
Re: Broken Pipes <tchrist@mox.perl.com>
Re: Cutting off the first letter. (Tad McClellan)
Desperate for help on perl4 and DOS/4G (DesiLGrant)
Re: differences between FileHandle and *HANDLE{IO} <roderick@argon.org>
Re: dir matching question <OperaGhost@NetTown.com>
Executable? <masmith@telusplanet.net>
Re: Field Separators <lauriem@cstr.ed.ac.uk>
Re: getting system date on NT? <david_mitchell@hp.com>
grep clone <rob@netcentral.net.no.spam>
Re: Help needed with PERL script!! (Lars Gregersen)
Re: Help with Pattern Matching (Bill)
How to parameterize a package name. (Solved.) (Michael T Decerbo)
Re: How To Pattern Match To The First Occurance Of A Ch (Tad McClellan)
Re: Lost backslash (Dave Thomas)
Mailing files from a perl script <stats9@mail.idt.net>
Re: Newbie needs help? (Nathan V. Patwardhan)
Re: Parsing html tag attributes & values in Perl (Dan Sumption)
Re: Perl for NT ***Help**** (Betty Kainz)
Re:dir matching question <OperaGhost@NetTown.com>
Re: Unix and ease of use (WAS: Who makes more ...) (Bill Dugan)
Re: What's wrong with "an email" (Dave Thomas)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Mar 1997 05:16:12 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: /RE/ for Dummies - Match all caps
Message-Id: <5gnsqs$b02$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
sailboat@tiac.net (Robert Schuldenfrei) writes:
:I have been having a problem trying to match lines in which everything is
:capitalized. We have some manuals that use all caps and I would like to pretty
:them up with just initial caps.
:
:Thus I would like the following line:
:
: THIS IS ALL CAPS
:
:To be converted into:
:
: This Is All Caps
:
:My first probe at this was:
:
:if(/[A-Z]+/) {
: tr/[A-Z]/[a-z]/;
: }
:
:But that translated every line of text, not just the lines of all caps. I am
:obviously missing something basic in RE, but I do not know what it is. Please
:enlighten me. TIA Bob
s/(\w+)/\L\u$1/g
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"It's easier to make up sayings people like to hear than sayings they
like to heed."
--Larry Wall
------------------------------
Date: Wed, 19 Mar 1997 08:14:39 +0000
From: John Clark <john@mcl.net>
Subject: 2 fields 2 files
Message-Id: <332FA06F.1D0D@mcl.net>
I have 2 fields in 2 files. A and B in file 1, A and C in file2.
Fields A in both files are not necessary in the same order and some
entries may be missing. How do I use keys to sort and print ABC.
Regards
J. Clark
------------------------------
Date: 19 Mar 1997 03:40:13 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Broken Pipes
Message-Id: <5gnn6t$7g5$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
brownt@python.cis.ohio-state.edu (tracy allen brown) writes:
: I was hoping someone could explain the possible reasons why the open()
:function, when used to fork off a process, could produce a broken pipe error
:message.
NAME
perlfaq8 - System Interaction ($Revision: 1.15 $)
DESCRIPTION
This section of the Perl FAQ covers questions involving
operating system interaction. This involves interprocess
communication (IPC), control over the user-interface
(keyboard, screen and pointing devices), and most anything
else not related to data manipulation.
...
Why doesn't open() return an error when a pipe open fails?
It does, but probably not how you expect it to. On systems
that follow the standard fork()/exec() paradigm (eg, Unix), it
works like this: open() causes a fork(). In the parent, open()
returns with the process ID of the child. The child exec()s
the command to be piped to/from. The parent can't know whether
the exec() was successful or not - all it can return is
whether the fork() succeeded or not. To find out if the
command succeeded, you have to catch SIGCHLD and wait() to get
the exit status.
In perlipc it also explains that you have to trap sigpipe.
not outlive the parent. Actually, elsewhere in the FAQ, it
mentions:
Signals
You'll have to catch the SIGCHLD signal, and possibly
SIGPIPE too. SIGCHLD is sent when the backgrounded process
finishes. SIGPIPE is sent when you write to a filehandle
whose child process has closed (an untrapped SIGPIPE can
cause your program to silently die). This is not an issue
with `system("cmd&")'.
I suppose this info should be next to the question I first cited.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
Let us be charitable, and call it a misleading feature :-)
--Larry Wall in <2609@jato.Jpl.Nasa.Gov>
------------------------------
Date: Tue, 18 Mar 1997 18:17:33 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Cutting off the first letter.
Message-Id: <tabng5.394.ln@localhost>
Gene Glass (glass@asu.edu) wrote:
: I am stuck trying to find a way of cutting off the initial letter in
^^^^^^^^^^^
So if $name='Glass', you want it's value to be 'lass' after?
Or maybe you just want to extract a (very short ;-) substring?
: 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 think you meant as the _value_ of a variable?
"use that letter as a variable itself" sounds like you want
$G to be set to something...
: ....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?
------------------
#! /usr/bin/perl -w
$name = 'Glass';
$letter = substr($name, 0, 1);
print "name '$name' letter '$letter'\n";
------------------
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 19 Mar 1997 05:36:23 GMT
From: desilgrant@aol.com (DesiLGrant)
Subject: Desperate for help on perl4 and DOS/4G
Message-Id: <19970319053600.AAA09685@ladder01.news.aol.com>
i am running perl4 under the following environment:
- DOS6.0
- windows 3.1
- HTTPD 1.4c
- perl 4 (with DOS/4G extender to manage virutal memory)
- 4MB ram
- 3+MB vitural memory
i have a perl script being run from an html form
my "hs??????.out" file contains the message (DOS/4GW Professional fatal
error 1307: not enough memory). however, when i compile the companion
"hs??????.bat" file outside of the windows environment, the script runs to
completion and i get the results that i expect.
Q1: Can anyone help analyze this situation. i think i am having a
problem setting up a proper ".vmc" file.
Q2: is there an online source of documentation for the DOS/4GW DOS
extender??? the documentation (readme.dos) that came with perl4 on this
subject seems woefully inadequate.
thanks in advance for any and all help in this matter
DesiLGrant@aol.com
------------------------------
Date: 18 Mar 1997 22:16:27 -0500
From: Roderick Schertler <roderick@argon.org>
To: apuzzo@snake.Colorado.EDU (Tony Apuzzo)
Subject: Re: differences between FileHandle and *HANDLE{IO}
Message-Id: <pzvi6od18u.fsf@eeyore.ibcinc.com>
On 18 Mar 1997 18:47:50 GMT, apuzzo@snake.Colorado.EDU (Tony Apuzzo) said:
>
> $_ = &nextline(*STDIN); # works;
> $_ = &nextline(*somearray); # works;
> $fh = new FileHandle "<filename";
> $_ = &nextline(*fh); # fails (*fh{IO} doesn't exist,
> # $fh is a filehandle object)
$fh is really a reference to a glob. The IO element of this glob
contains the filehandle you're interested in. This isn't what you're
passing to &nextline, though. You're giving &nextline the glob which
contains the scalar which is a reference to the glob which contains the
filehandle. If that doesn't make sense maybe this more verbose take
will help:
$fh is a reference to an anonymous glob,
call it *ANON
*ANON contains the ANON filehandle (plus the @ANON array
and all the rest, but they haven't been
used so test as empty)
You pass *fh to &nextline so
*fh contains the scalar $fh which you set up, and
that's it. The filehandle in this glob
has not been used. Only the scalar in
*fh has been used.
If you want &nextline to get the glob which contains the filehandle
you'll need to invoke it with
*{$fh} which is the *ANON glob. You're dereferencing
the glob reference contained in $fh,
resulting in the glob itself.
However, I wouldn't suggest that you continue down this path. Globs are
confusing and I think using them for this subroutine is a mistake. I'd
do it like this (untested):
use Symbol ();
sub nextline {
my $ref = shift;
if (ref $ref eq 'ARRAY') {
$line = shift @$ref;
}
else {
$ref = Symbol::qualify $ref;
no strict 'refs';
$line = <$ref>;
}
return $line;
}
This will allow you to invoke it with any of
$_ = nextline \@somearray;
Caller must explicitly create the array reference. This does
implement different semantics than yours, though.
$_ = nextline STDIN;
Bareword filehandle. The Symbol::qualify call is what allows
this to work with arbitrary filehandles if &nextline is in a
different package than the caller.
$_ = nextline \*STDIN;
Reference to glob. This is just like using a filehandle object,
a filehandle object is really a reference to a glob.
$_ = nextline *STDIN;
A real glob, similar to a reference to a glob. The later is
the standard idiom, but this works too.
$_ = nextline *STDIN{IO};
Reference to the IO slot in the given glob.
$_ = nextline $fh;
A scalar which contains any of the above, such as a filehandle
object.
--
Roderick Schertler
roderick@argon.org
------------------------------
Date: Wed, 19 Mar 1997 00:07:59 +0000
From: Opera Ghost <OperaGhost@NetTown.com>
Subject: Re: dir matching question
Message-Id: <332F2E5F.3AD6FE3B@NetTown.com>
this is a better loop...
for ($good_target, $bad_target, $good_target2) {
print "$_...";
print 'NOT ' unless m!$search[^/]*?/$!;
print "Matched!\n";
}
--
<i>Opera Ghost</i>
<OperaGhost@NetTown.com>
------------------------------
Date: 19 Mar 97 06:04:23 GMT
From: "Mike Smith" <masmith@telusplanet.net>
Subject: Executable?
Message-Id: <01bc342c$71e57600$b24722cf@Mike.compusmart.ab.ca>
I put a perl script on my isp's cgi server last week. I telnet to the
server, type perl mcr.cgi in the directory where the script is and
everything works fine. The tags print to screen and such. I used chmod 777
mcr.cgi to make it executable. Doesn't that mean I can tpye mcr.cgi
(without running perl; ie. perl mcr.cgi)? Anyway, when I type mcr.cgi Unix
gives me a "bad command" message.
The other thing is when I click the form using the script I get a server
error that states there is an internal configuration problem. I called my
ISP and they said my cgi password may (they are not sure??????) be
crackable so that may be the problem. But how can I execute scripts through
telnet if that is true?
Thanks,
Mike aka stressed out in Edmonton
masmith@telusplanet.net
------------------------------
Date: Tue, 18 Mar 1997 16:41:01 +0000
From: Laurence Molloy <lauriem@cstr.ed.ac.uk>
Subject: Re: Field Separators
Message-Id: <332EC59D.191A@cstr.ed.ac.uk>
Terry Robison wrote:
>
> I have data in the form:
>
> "248347554","90834598","This is a comment, sometime with multiple commas
> inside","dategd","4545","transaction type","7459087"~
>
> I am trying to set the FS equal to ",", including the quotes.
>
> I set FS="\",\"" and print FS. It appears to be ",", but fields break on
> a single ".
>
> Can I set a multiple character FS?
>
> Thanks,
> T Robison
Why not try:
s/","/:/g
or some such other character for ':' that you're sure doesn't occur in your
data (just make sure that if you choose a reserved character, you escape it
with '\'). To be sure that your choice of character doesn't already occur in
your file, just grep it.
This will then trasform all such "," strings into single characters which can
then be specified as your field separator.
Laurence.
--
____________________________________________________________
Laurence Molloy
Centre for Speech Technology Research
University of Edinburgh
Level D
80 South Bridge Tel. +44 131 650 6357
Edinburgh. EH1 1HN Fax. +44 131 650 6351
Scotland, UK. Email lauriem@cstr.ed.ac.uk
____________________________________________________________
------------------------------
Date: Wed, 19 Mar 1997 18:45:02 +1000
From: Dave Mitchell <david_mitchell@hp.com>
Subject: Re: getting system date on NT?
Message-Id: <332FA78E.9EB@hp.com>
Try using the localtime() function, and pass it "time") as a parameter;
it's supported under NT and works fine.
Dave Mitchell
------------------------------
Date: Tue, 18 Mar 1997 11:34:46 -0600
From: Rob Huffstedtler <rob@netcentral.net.no.spam>
Subject: grep clone
Message-Id: <332ED236.24B4CA74@netcentral.net.no.spam>
I have written a grep-clone in perl, mostly as an R&D exercise to see if
I could implement it as a funcction in a program where I am currently
making a systtem call to grep.
grope (my script) does case insensitive matching and doesn't deal well
with wild card expansion. However, it will take regex's on the command
line.
In my comparison tests it was consistently performing about 0.02 sec
faster than grep. Then I started doing the same test multiple times.
grope's perfomance stayed exactly the same, but grep -i was about four
times faster the second time I ran it. It consistently stayed faster on
the same search after that.
This makes me think that grep is somehow caching either the file or the
search results. Could anyone verify this and suggest how I might
implement the same sort of thing in Perl.
Thanks,
Rob
PS)Please reply by email as well as my newsfeed has been a wee bit flaky
recently.
------------------------------
Date: Wed, 19 Mar 1997 07:53:47 GMT
From: lg@kt.dtu.dk (Lars Gregersen)
Subject: Re: Help needed with PERL script!!
Message-Id: <332f992e.3792733@130.228.3.8>
On Tue, 18 Mar 1997 20:50:25 GMT, njohnson@enterprise.net (Neil
Johnson) wrote:
>I hope someone can help me here!
>
>I have written the perl script below which creates an index html page
>of all the files on a sever. The problem is I want to add a few more
>features to make it more useful but just can't seem to get them to
>work!
>
>At the moment it gives file name, directory, size of file and date of
>file in days. What I am trying to add is a function that would get the
>file dates as well. I have found no switch for this like you can use
>to get the other information so hopefully someone out there know's how
>this can be done!
>
>I also want to get it to scan for command line paths. At the moment it
>just displays the whole file system but I would like it also to start
>scanning from a certain directory as well. So if someone ran the
>script by: indexer.pl?d:\wwwroot\ftp\
>It would start scanning from there istead of the deafult. Can this be
>done?
I would say that the better thing to do is to use File::Find instead
of your traverse code. That way other people will be able to use your
code on other systems.
If you want to start from somewhere else than the default just change
the line with $dir='..'; to $dir=ARGV[0], but add some code to check
if an argument was really given.
>One last query I have is that I have made it calculate the total size
>of the directires in MB but I want to format this number in a way so
>it adds a comma every three digits so if the total was: 999999999 it
>would be formatted to 999,999,999.
>
>Can that be implemented??
"Implemented" might be a strong word for a one-liner. From the perlop
man page:
1 while s/(\d)(\d\d\d)(?!\d)/$1,$2/g; # perl5
Lars Gregersen
Technical University of Denmark
Department of Chemical Engineering
E-mail : lg@kt.dtu.dk
Homepage: http://www.gbar.dtu.dk/~matlg/
------------------------------
Date: 19 Mar 1997 04:19:43 GMT
From: bill@sover.net.no.junkmail (Bill)
Subject: Re: Help with Pattern Matching
Message-Id: <slrn5iuqav.k3i.bill@granite.sover.net>
In article <332DAAE6.4F14@toy.mem.ti.com>, "M. Wick" wrote:
>I've tried grep, index, and the matching sequence and nothing seems to
>be working. I'm opening a file, reading in a line, and trying to
>match a pattern from within the line. I have found that I can match
>the line if the parameter starts at the beginning on the line. I want
>to find the pattern in the middle of the line, and nothing seems to be
>working correctly.
>
>while( <FILE> ){
> if ( (index($_, $pattern)) >= 0 ) {
>
> if (grep($pattern, $_) != 0) { (even though grep works on an array,
> I still tried it)
>
> if (/$pattern/) { (matching on the $_ from the file)
> do this stuff if match;
> }
>}
>
>I've tried all 3 possibilities.
>
>Here are the lines that I'm looking at:
>
>NAME <-- Works fine here
><LI><A HREF="http://..../">NAME</A> <-- Doesn't match this line
>
>I'm trying to find NAME. Any suggestions?
>Thanks in advance.
Well, if you are trying to extract a piece of information that you
don't know anything about except the things that come before and after
it, then in the above case you'd want something like: (untested, BTW)
while (<LINE>) {
if (/<A HREF=".+?">(.+?)<\/A>/i) {
print "Found $1\n";
}
}
The only thing is, this is pretty hardcoded to the way your particular
HTML was written. Image that instead it came across like:
<LI><A HREF="http://..../">NAME
</A>
In this case it wouldn't match, because the anchor tag spans lines.
Also, what about:
<LI><A HREF = "http://..../">NAME</a>
and
<LI><A HREF=http://..../>NAME</a> ?
So, to answer your initial question, use backreferences. :) See the
perlre man page or consult the camel book or some other resource. Consider
the consequences of imposing limitations in your code that don't exist in
HTML. I believe there is also a module that does HTML parsing at CPAN,
which you might want to check out. Hope this helps somewhat...
Bill
--
Sending me unsolicited email through mass emailing about a product or
service your company sells ensures that I will never buy or recommend your
product or service.
------------------------------
Date: 19 Mar 1997 00:40:33 GMT
From: mike@athena.mit.edu (Michael T Decerbo)
Subject: How to parameterize a package name. (Solved.)
Message-Id: <5gncm1$c6a@senator-bedfellow.MIT.EDU>
Sorry to follow up my own post, but before anyone takes a lot of time
helping me...
>>sub import_vars_from_hashref_keys {
>> my ($hashref,$pck) = @_;
>> while (($key, $value) = each %$hashref) {
>> ${"$pck::$key"} = $value;
>> }
>>}
>>
>>import_vars_from_hashref_keys( \%myhash, "temp" );
The line in question needed to be
${"${pck}::$key"} = $value;
I'm still not clear on quite why, but heck, I'll try to figure it out
as I go along.
I found this on p.5 of the perlref(1) man page, which I really had
read before! Guess it slipped my mind.
Thanks to all who responded.
Mike
------------------------------
Date: Tue, 18 Mar 1997 21:35:29 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How To Pattern Match To The First Occurance Of A Character
Message-Id: <1umng5.pu4.ln@localhost>
Rhadji P (dharma@msys.net) wrote:
: 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 > ?
/<TEXTAREA(.*?)>/
^
^
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 19 Mar 1997 04:04:38 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Lost backslash
Message-Id: <slrn5iupej.qkb.dave@fast.thomases.com>
On Tue, 18 Mar 1997 20:25:29 +0100, Thomas Buehner wrote:
> When I run this script:
>
> $test = '\.\\test';
> print $test;
>
> what gets printed is: \.\test
>From 'perldoc perlop'"
'STRING'
A single-quoted, literal string. Backslashes are
ignored, unless followed by the delimiter or
another backslash, in which case the delimiter or
backslash is interpolated.
Dave
--
_________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Tue, 18 Mar 1997 23:10:17 -0500
From: Chris Plachta <stats9@mail.idt.net>
Subject: Mailing files from a perl script
Message-Id: <332F66F0.2E9DD57D@mail.idt.net>
This one has been driving me crazy!
I'm running Perl 5 on a linux box.I'm writing a script to
email some text files to people.
The way I've been approaching it is to create a mail.file
that contains commands that the "mail" utility understands, and
piping this file into the "mail" command within the perl
script. The mail.file looks like this:
~rfile1
~rfile2
....
Within the perl script, I'm trying to execute the mail system command:
`mail -I person@addr.com < mail.file`;
When I do this in the script, an empty mail file gets sent. If I
do the same thing at the shell prompt, it works fine (file1 and file2
are included in the mail message). How do I do this within the perl
script????????????
Thanks in advance.
------------------------------
Date: 19 Mar 1997 04:47:00 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Newbie needs help?
Message-Id: <5gnr44$gte@fridge-nf0.shore.net>
crazyblake (crazyblake@earthlink.net) wrote:
: Well, sorry, but I just needed SOMETHING to cover this task, and I was
: told that perl was the easiest way to go about it.
The answer is yes and no. If you don't know Perl, or very much about
programming, I suspect that the implementation you are seeking won't be very
easy for you. The programs you might find will *work*, but when you try to
change them, and things might not work properly, you'll get frustrated. Again,
this is not a flame, but a statement from experience - don't bite off more than
you can chew.
: I've done a bit of background reading, soem tutorials on the web, and IU
: understand it fairly well. I'd prefer not to have to go out and buy a
: book, but if I absoutly HAVE to, could you make a suggestion as to which
: one?
I'd definitely suggest _Learning Perl_ by Randal Schwartz, an excellent
introduction to Perl, and _Programming Perl_ by Larry Wall, Tom Christiansen,
and Randal Schwartz, a definitive (IMHO) guide to Perl (+ version 5).
: I'm using perl5, and this project was my own idea (so you can understand
: why it may be a little far-fetched). The program is supposed to make a
: telnet connection to a specific TCP server, recieve the data that is
: automatically sent-out by the server, and listen for connections (where it
: would do the same).
Okay, if you want to start right in with sockets, your Perl distribution should
include files with a .pod (Plain Old documentation extension). Since you won't
be root, do this:
1) copy perlipc.pod from /usr/local/lib/perl5/pod to your working area. -> this
might be in a different location, but should be in the same directory under
the perl5 level.
2) run: pod2text perlipc.pod > perlipc.txt to convert the .pod format into
text.
3) Read the section of perlipc.txt about interprocess communication and
sockets, where you'll find a section dealing with a socket client/server
model, which will get you started on the socket meal. :-)
4) Try the examples, and revise them, trying different things each time.
Good luck and hope it works for you!
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: Wed, 19 Mar 1997 08:54:51 GMT
From: dan@gulch.demon.co.uk (Dan Sumption)
Subject: Re: Parsing html tag attributes & values in Perl
Message-Id: <332fa782.1093051@news.demon.co.uk>
At 18:19 18/03/97 -0500, you wrote:
>I don't recall your first post, but I'm curious...why are you writing
>this from scratch rather than using Tom Christiansen's 'striphtml' or
>inheriting functionality from the libwww or CGI modules?
Copy of my first post included at the end (be warned - it's long and
convoluted).
I wasn't aware of 'striphtml' - I'll try to track it down, as it sounds
like it may be ideal. I did look into using libwww, and probably could have
done so, but I kept running up against problems - firstly, I have not
previously set up any of the perl libraries, so there was a bit of a
learning curve involved. I tried it anyway, then tried getting pod2html
working so that I could take a look at the documentation, but it threw out
numerous syntax errors when I tried running it. This coupled with the fact
that I'm trying to run this stuff on Windows NT, which can mean problems
with perl programs, and also that I have to have this script up and running
ASAP, put me off using some huge piece of code which I don't feel I
understand. (Also, I spent about half-an-hour trying to work out how I'd do
it with libwww, and kept going round in circles - but that's nothing
unusual!)
-------------------------
Hi. I hope someone can help me - I have just embarked on a task which seems
to grow more mammoth every time I think about it. Fed up with the hassles
of writing different netscape/explorer versions of pages and updating
navigation aids throughout a website, I decided to write a perl script to
process each page served before the user gets to see it. However, I've got
a growing list of questions. I apologise if this post turns into something
of a ramble, but I don't even have some of the problems very clear in my
mind.
Firstly, if anyone has written or knows of any similar scripts which I can
pillage for ideas, I'd be grateful for the code or URL.
Secondly, I'm thinking of doing all sorts of things with tags - like check
all anchor tags to see if they're local, and if so then make the path to
the file absolute and add a reference to the script at the beginning with
variables passed at the end (e.g. <A HREF="index.html"> becomes <A
HREF="/cgi/thisscript.pl/index.html?site=lite">. I can do a quick and dirty
version of this, but would like to know if anyone has any ideas on how to
make the code as reuseable as possible, so that I can pull a named value
from any tag, alter it if necessary, and re-insert the altered tag into the
code to be output. The code would have to be as bullet-proof as possible -
accepting values either inside or out of quotes (and allowing spaces inside
quotes), allowing spaces and newlines at any point within the tag, etc.
Another thing I plan to do is add my own tags to the html, something like
<BROWSER TYPE="ie" VER="3" SITE="deluxe">. This seems to create the problem
that either I slurp the whole html file into one string so that I can catch
the BROWSER open and close tags plus anything in between in one regexp, or
I run through the code line by line, setting a flag once I enter a BROWSER
tag, checking for stuff on the end of the line with the <BROWSER> tag and
the beginning of the line with </BROWSER>, etc. - which is all possible but
a little messy. Does anyone have any ideas/suggestions.
Also on the subject of slurping, if I am checking for BROWSER tags (and
adding or ignoring the stuff enclosed by the tags) as well as checking and
changing anchor tags and possibly others, again it starts to look like my
best option is to do all operations on one big string, so that I can use
global regexp's. Does anyone have any comments on this or alternative
methods, or on how much it is likely to affect a server's performance if it
has to run a separate perl session slurping up 5-10k files for each page on
the site accessed.
I'm sure this won't be the end of my questions on this one - but if anyone
has any ideas which may possibly help me for now, I'd be very grateful.
-------------------------------------------------------------------
Dan Sumption : dan@gulch.demon.co.uk
Hard Media, London SE1 dan@hardnet.co.uk
http://www.hardnet.co.uk/dan/
------------------------------
Date: 19 Mar 1997 08:58:00 +0100
From: midimani@site88.ping.at (Betty Kainz)
Subject: Re: Perl for NT ***Help****
Message-Id: <6T9$60tCdNB@site88.ping.at>
Hi Jon ! :-)
On 17 Mar 97 jont@uunet.pipex.com wrote :
> Please help me before I go insane!
Gee, Jon...please don't do that, especially not about this problem. :^)
> How can I stop the Perl window closing as soon as it encounters an
> error. I cannot read the error messages as the windows closes like
> lightning.
Well, I solve this problem by opening an MSDOS window
(or in the command line of the Norton Commander, if you prefer),
and diverting the output to a file, like this for example:
D:\scripts>perl -w myfilename.pl > test_res.txt
...hope it saves you a trip to the funny farm. ;-)
Betty
-------------------------------------------------------------------
Betty Kainz /\/\idi /\/\ania - Vienna/Austria
Fido: 2:310/78.78 Internet: midimani@site88.ping.at
-------------------------------------------------------------------
WWW: http://www.ping.at/users/akainz/midimani.htm
-------------------------------------------------------------------
------------------------------
Date: Tue, 18 Mar 1997 23:49:59 +0000
From: Opera Ghost <OperaGhost@NetTown.com>
Subject: Re:dir matching question
Message-Id: <332F2A27.7AC7421@NetTown.com>
$search = "/www/foo/Products/";
$good_target = "/www/foo/Products/Wombats/";
$bad_target = "/www/foo/Products/Wombats/Leamur_conspiracy/";
$good_target2 = "/www/foo/Products/Wombats2/";
# r u confident of the / at the end?? im assuming so
# anything within // (or m!!) is just double quote expanded
# its allways a good idea to start off using m!! when matching dirs :-)
for ($good_target, $bad_target, $good_target2) {
print $_;
if (m!$search[^/]*?/$!) {
print "...Matched!\n";
}
else {
print "...NOT Matched!\n";
}
}
this is ava for running at
http://nettown.com/site_perl/doc/eg/re.dirmatch.cgi
this source is at
http://nettown.com/site_perl/doc/eg/re.dirmatch.cgi.source
--
<i>Opera Ghost</i>
<OperaGhost@NetTown.com>
------------------------------
Date: Wed, 19 Mar 1997 05:12:17 GMT
From: wkdugan@ix.netcom.com (Bill Dugan)
Subject: Re: Unix and ease of use (WAS: Who makes more ...)
Message-Id: <332f719c.2176263@nntp.ix.netcom.com>
wkdugan@ix.netcom.com (Bill Dugan) wrote:
>mwolfe@shrike.depaul.edu wrote:
>
>>In the end Linux will bury MS. Linux is open. This means open
>>competition. This means better products. LINUX RULES.
>
>MS has buried lots of better products.
Toan Tran <root@fireball.rh.uchicago.edu> wrote:
>And what products might those be?
Terje A. Bergesen <terjeber@eunet.spm-protect.no> wrote:
>They have? In that category? Which?
CPM-86, GEM, UCSD P-system, ...
Of course it's a matter of taste whether and how much these were
better than DOS or Windows at the time they were in competition, but
many people felt they were. What's probably more significant is that
no system can be the best for everyone. MS has managed to bury most of
its competitors, including several systems which were better for at
least some users.
Note I'm not arguing that MS was guilty of underhanded tactics here.
In most of these cases, MS just did a better job of marketing their
product than their competitors.
mjr@laulujoutsen.pc.helsinki.fi (Mikko Rauhala) wrote:
>Linux isn't something he can buy off. I don't see how MS could actually
>bury Linux.
I hope you're right, since we need more than one OS in the world, but
we'll have to wait and see.
------------------------------
Date: 19 Mar 1997 04:09:38 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: What's wrong with "an email"
Message-Id: <slrn5iupnv.qkb.dave@fast.thomases.com>
On 18 Mar 1997 13:38:33 -0800, Bruce M. Binder wrote:
>
> I disagree. Certainly the language changes. But many changes
> started out as an error that came to be accepted. Far more
> errors are not accepted and never cause a change in the
> language. I think were still at the stage where this is not
> "just a different way to use the term". It's an error. Why
> should this particular error be accepted merely because lazy
> users hide behind the "evolution of the language" argument?
I guess because the other solution would be to invent yet another new word
to mean 'an electronic letter'.
Mail is a collection of letters.
email is a collection of ?
(spam, mostly, in my case).
Dave
--
_________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
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 142
*************************************