[7531] in Perl-Users-Digest
Perl-Users Digest, Issue: 1158 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 10 18:07:52 1997
Date: Fri, 10 Oct 97 15:00:26 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 10 Oct 1997 Volume: 8 Number: 1158
Today's topics:
"Not a scalar string" in new pRPC / Storable modules <wayne@misinfo.com.au>
Re: -Help with eval <rootbeer@teleport.com>
Re: 5.004_03 test failure on IRIX 5.3 <rootbeer@teleport.com>
access to MicroFocus COBOL indexed file under SCO Opens <frank@bcsi.ca>
Calling Perl from C++ problem <Iain.Bisset@ubs.com>
GD.pm <dturley@rocketmail.com>
Re: generating javascript <icache@usa.net>
Re: Help storing a hash of hashes using DB_File <seay@absyss.fr>
Re: Help with installation... <rootbeer@teleport.com>
How to get everything in between <pre>....</pre> tags i <dlortie@nt.com>
Re: How to get everything in between <pre>....</pre> ta (Jeff Stampes)
Re: html2text <usenet-tag@qz.little-neck.ny.us>
Re: Lists of lists in Perl 4 <seay@absyss.fr>
Looking for a script to split mailbox in HTML-files Gerben_Wierda@RnA.nl
Re: Looking for a script to split mailbox in HTML-files <friedman@uci.edu>
Re: map in void context (was Re: $x = $y || $z - danger <friedman@uci.edu>
Re: Need Help Parsing ASCII File <blk@redneck.intel.com>
need tricky regex <mreimer@vpop.net>
Re: need tricky regex (brian d foy)
Re: need tricky regex <usenet-tag@qz.little-neck.ny.us>
Passing arguments to a script in HTML <forda@monroe.army.mil>
Re: PERL and Access <ragoff@sandia.gov>
Perl DBM file sizes?!? (Yves Dagenais)
Re: Perl Questions <rootbeer@teleport.com>
Re: Perl5.003: Is it possible to alter the sort order <rootbeer@teleport.com>
Re: PerlScript & ASP...accessing System Command Line? (I R A Aggie)
Re: please help! <burleigh@hackberry.chem.niu.edu>
Re: Posting to a Newsgroup with a Perl Script. (Faust Gertz)
Re: Question: File locking <rootbeer@teleport.com>
Re: range of return values for rand function <rootbeer@teleport.com>
Re: Reading Variable Names from a file <rootbeer@teleport.com>
regexp help.. (Alex Krohn)
Re: regexp help.. (Tad McClellan)
Re: regexp help.. <usenet-tag@qz.little-neck.ny.us>
Why the ambiguity? <add@rice.edu>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 11 Oct 1997 03:57:47 +1000
From: Wayne Blick <wayne@misinfo.com.au>
Subject: "Not a scalar string" in new pRPC / Storable modules
Message-Id: <343E6C9B.30D1@misinfo.com.au>
I'm trying to get a small example for the new pRPC modules (by Jochem
Wiedmann) working. It uses the Storable modules (by Rahael Manfredi).
The Storable 0.5 tests all pass.
The pRPC 0.1002 tests all pass.
The RPC::pServer module calls Storable::thaw and I get a "Not a scalar
string" error. Any ideas? - I'm not a XS expert!
I've used dumpvar and the string sent by the RPC::pClient is received by
the RPC::pServer OK and intact - it just won't "thaw" properly.
Thanks.
Wayne Blick
------------------------------
Date: Fri, 10 Oct 1997 14:11:24 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "M. Wick" <mwick@toy.mem.ti.com>
Subject: Re: -Help with eval
Message-Id: <Pine.GSO.3.96.971010140917.4500M-100000@usertest.teleport.com>
On Thu, 9 Oct 1997, M. Wick wrote:
> I'm trying to catch the exit status (number) from one file within
> another.
Don't use eval; use system, qx//, or open on a process. Then you can use
$? properly. Details mostly in perlipc(1), and a few other places. 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: Fri, 10 Oct 1997 14:37:56 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "James W. Durkin" <jwd@graphics.cornell.edu>
Subject: Re: 5.004_03 test failure on IRIX 5.3
Message-Id: <Pine.GSO.3.96.971010143540.4500S-100000@usertest.teleport.com>
On 9 Oct 1997, James W. Durkin wrote:
> I just redid our Perl installation on various systems, switching from
> 5.004_01 to 5.004_03 in the process. The build/test used to go
> cleanly on our IRIX 5.3 systems, but doesn't now. It fails in the
> tests of lib/complex.
There were some recent changes to complex number handling, and they're (as
I recall) part of the reason that _03 was never an official release. They
should be fixed in _04 - which may or may not become an official release.
:-) 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: Fri, 10 Oct 1997 13:06:09 -0400
From: "Frank S. Bernhardt" <frank@bcsi.ca>
Subject: access to MicroFocus COBOL indexed file under SCO Openserver
Message-Id: <343E6080.B4876081@bcsi.ca>
Is there a way to access MicroFocus COBOL v3+ indexed files under SCO
OpenServer from PERL?
I need to be able to get at the files from a CGI script in order to
serve the data to a WEB page. Initially READ access would be fine but
eventually WRITE/REWRITE access would be required. The files are KEY and
DATA compressed.
Yes, I could export the files into an ASCII file but I am trying to get
real-time information to the WEB user.
Any help would be greatly appreciated.
--
Regards
Frank S. Bernhardt
b.c.s.i.
frank@bcsi.ca
------------------------------
Date: Fri, 10 Oct 1997 19:13:04 +0100
From: Iain Bisset <Iain.Bisset@ubs.com>
Subject: Calling Perl from C++ problem
Message-Id: <343E7030.89F0B904@ubs.com>
This is a cryptographically signed message in MIME format.
--------------msB90830A0A45ABCE3A145D0A2
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi,
Maybe someone can help me. I'm calling a Perl subroutine from Visual C++
and it works fine until my Perl starts to "use" other modules like
"Net::Telnet" or "IO::File". It CAN use modules like "strict" and
"integer" ok.
Has anyone experienced this before ? It works fine from the command
prompt on Windows NT but fails from Visual C++ and debugging is a
nightmare....the cut-down code follows.and calls the Perl subroutine
"do_telnet" in the file "blah.pl".....
Thanks
Iain
--------------------------------------------------------------------------------------------------------
Visual C++
-------------
static PerlInterpreter *my_perl;
static char *LoginInfo[] = {
"nol2015.fh.zh.ubs.com", "nol2949:0.0", "mmk", NULL} ;
char *my_argv[2] = { "", "blah.pl"};
my_perl = perl_alloc();
perl_construct( my_perl );
int parse_status = perl_parse(my_perl, NULL, 2, my_argv, (char **)
NULL);
int telnet_status = perl_call_argv("do_telnet", G_DISCARD,
LoginInfo);
perl_destruct(my_perl);
perl_free(my_perl);
blah.pl
--------
sub do_telnet
{
use strict;
use Net::Telnet(); # Works fine till I include these 2 lines
use IO::File; #
.........
.........
}
--------------msB90830A0A45ABCE3A145D0A2
Content-Type: application/x-pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"
Content-Description: S/MIME Cryptographic Signature
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
--------------msB90830A0A45ABCE3A145D0A2--
------------------------------
Date: Fri, 10 Oct 1997 14:11:45 -0600
From: David Turley <dturley@rocketmail.com>
Subject: GD.pm
Message-Id: <876510421.14887@dejanews.com>
I will lick this yet.
I am trying to use GD.pm, following the readme instructions for those
without privileges to main perl directory. I've uncompressed the archive
into my own lib directory and added the proper path to use lib in my
script.
I get this error:
"Can't find loadable object for module GD in @INC..."
The proper directory is listed in @INC so I don't know exactly what it is
looking for. Tips, hints, mantras greatfully accepted.
Cheers,
David
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Fri, 10 Oct 1997 11:00:49 -0600
From: Keith Davis <icache@usa.net>
Subject: Re: generating javascript
Message-Id: <343E5F41.4B02@usa.net>
Mark Wilhelm wrote:
>
> I'm having some problems using perl to generate javascript. I think the
> biggest obstacle is how to handle/escape the javascript code brackets so
> that perl doesn't interpret them as perl code. Anyone have any
> ideas/subroutines I can "creatively plagiarize" (read: steal)?
>
> ==================================================================
> Mark Wilhelm | mwilhelm@astro.temple.edu
> Operations & Technical Support |
> Systems Office | http://astro.temple.edu/~mwilhelm
> Temple University |
> Samuel Paley Library | (215) 204-6573
> ********************************************************************
>
>
The brackets are no problem,
however use the escape\ on all double quote", on all semi-colons;, and
on all curly braces{}.
------------------------------
Date: Fri, 10 Oct 1997 10:47:08 +0200
From: Doug Seay <seay@absyss.fr>
To: Larry Lentner <llentner@raven.bbnplanet.com>
Subject: Re: Help storing a hash of hashes using DB_File
Message-Id: <343DEB8C.6827B6AB@absyss.fr>
Larry Lentner wrote:
>
> Hello,
>
> Does anybody have some pointers to examples/hints/etc for storing a
> hash of hashes in a Berkeley db file, using DB_File? It appears that a
> hash tied with "tie %hash, "DB_File", ... " will only work with a flat
> (ie. not multidimensional) hash.
The CPAN module list (CPAN/modules/00modlist.long.html) includes the
following entry under "Database Interfaces"
MLDBM bdpO Transparently store multi-level data in DBM GSAR
I've never used it, so I don't know how well it works, but the
description sounds like it might do what you want it to do. Since it is
listed as "beta", you might have to adjust a few things to get it
perfect for your needs.
- doug
------------------------------
Date: Fri, 10 Oct 1997 14:33:42 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jen Lyons <lyonsj@bgnet.bgsu.edu>
Subject: Re: Help with installation...
Message-Id: <Pine.GSO.3.96.971010143224.4500Q-100000@usertest.teleport.com>
On Thu, 9 Oct 1997, Jen Lyons wrote:
> The location of gcc is /usr/bin/gcc, but it says "Whoa there! Your gcc
> doesn't seem to be working properly! Let me know where it is!" and then
> stops. I don't have any library files; would this make a difference?
Yes, the lack of library files would be likely to keep gcc from working
right. If you can't find them (or find how to install them), check with
the folks in a newsgroup about your system. When you have those libraries
installed, gcc should work. 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: Fri, 10 Oct 1997 15:59:35 -0400
From: Daniel Lortie <dlortie@nt.com>
Subject: How to get everything in between <pre>....</pre> tags in html
Message-Id: <343E8927.26E1@nt.com>
Please help me with this,
I have an HTML file that I read from the internet, but I want
to parse the file I receive to only keep the text between the
<pre> and </pre> tags.
Is there a quick way to do this?
I read the file using the LWP module.
Any info appreciated,
Daniel Lortie
dlortie@nt.com
------------------------------
Date: 10 Oct 1997 21:40:46 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: How to get everything in between <pre>....</pre> tags in html
Message-Id: <61m7cu$lhn$1@neocad.com>
Daniel Lortie (dlortie@nt.com) wrote:
: I have an HTML file that I read from the internet, but I want
: to parse the file I receive to only keep the text between the
: <pre> and </pre> tags.
: Is there a quick way to do this?
: I read the file using the LWP module.
I don't know about the LWP module...but if this was any other file I
was looking at, the range operator would be my friend:
while (<IN>)
{
if (m{<pre>} .. m{/<pre>}) {print $_}
}
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: 10 Oct 1997 17:11:43 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: html2text
Message-Id: <eli$9710101254@qz.little-neck.ny.us>
Tracy Bednar <spectran@netcom.com> wrote:
> gonzalo@interimagen.com wrote:
> : Do you know how I can discart HTML tags and anly take the text form a
> : HTML file?. I need open a file just to extract the text.
> If you have lynx, you can do
> lynx -dump abc.html
This requires the html be in a file. It also will be influenced
(perhaps with poor results) by the user's lynx preference files.
> Very handy, if not, then check out some of the modules, I think
> LWP or LIBWWW.
HTML.
This is a script I proposed recently for someone who wanted a
one liner to strip HTML:
perl -MHTML::Parse -MHTML::FormatText -0777e '$f=new HTML::FormatText;print $f->format(parse_html(<>))'
There is probably some trick I am overlooking to shorten that.
With a large and complex regular expression you could strip all the
tags, but you run into several problems.
foo<br>foo should not become foofoo
f<code>o</code>o should not become f o o
f o o should not become f o o
How <hr> and the various lists should be interpreted is a matter of
application.
Elijah
------
there are probably scripts on CPAN that work faster than my one liner
------------------------------
Date: Fri, 10 Oct 1997 10:21:43 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Lists of lists in Perl 4
Message-Id: <343DE597.42B95AC7@absyss.fr>
Brandon S. Allbery KF8NH; to reply, change void to kf8nh wrote:
> You can create a "list of lists" in Perl 4 by means of symbol table
> manipulations: create an anonymous list and insert its symbol table entry
> into another list. Doing so is a major pain and *accessing* it afterward is
> even more of one. (I used to do a lot of this; it got to be so much of a pain
> that I switched languages until Perl5 stabilized.)
How do you create "an anonymous list" in Perl4? You could use eval to
build a list named after the contents of a counter, but that isn't
truely anonymous. Did you have a different approach?
- doug
------------------------------
Date: Fri, 10 Oct 1997 18:05:31 GMT
From: Gerben_Wierda@RnA.nl
Subject: Looking for a script to split mailbox in HTML-files
Message-Id: <EHuKx8.95z@RnA.NL>
I am looking for a script that takes a mailbox and produces HTML-files, one
per mail messages with links between related messages and stuff like
forward-back etc.
Since these types of interfaces are fairly often to be encountered, I
wondered if there would be some script available to create such a webbable
mail overview.
Thanks in advance,
--
Gerben_Wierda@RnA.nl (Gerben Wierda)
"If you don't know where you're going, any road will take you there"
Paraphrased in Alice in Wonderland, originally from the Talmud.
Renee: "Met veel koper maakt men hoempa." (After hearing Brahms'
Festouverture)
------------------------------
Date: 10 Oct 1997 20:41:08 GMT
From: "Eric D. Friedman" <friedman@uci.edu>
Subject: Re: Looking for a script to split mailbox in HTML-files
Message-Id: <61m3t4$6c3@news.service.uci.edu>
In article <EHuKx8.95z@RnA.NL>, <Gerben_Wierda@RnA.nl> wrote:
<I am looking for a script that takes a mailbox and produces HTML-files, one
Check out MHonArc:
http://www.oac.uci.edu/indiv/ehood/
--
Eric D. Friedman
friedman@uci.edu
------------------------------
Date: 10 Oct 1997 17:23:16 GMT
From: "Eric D. Friedman" <friedman@uci.edu>
Subject: Re: map in void context (was Re: $x = $y || $z - dangerous assumption?)
Message-Id: <61loa4$t6c@news.service.uci.edu>
In article <8chgar2ggc.fsf@gadget.cscaper.com>,
Randal Schwartz <merlyn@stonehenge.com> wrote:
<So, I'd say in speed (knowing a little behind the scenes), from
<fastest to slowest, it'd be:
<
< foreach my $x
< foreach $x
< grep returning false
< grep returning true/false
< map returning ()
< map returning other
#!/dcs/bin/perl5 -w
use Benchmark;
use constant LIST => (0 .. 10000);
timethese(1000, {
'for (@list)' => \&f,
'grep' => \&g,
'foreach $i (@list)' => \&fe,
'foreach my $i (@list)' => \&fem,
'map' => \&m,
}
);
sub g
{
my %val = ();
grep { $val{$_}++ } LIST;
}
sub f
{
my %val = ();
for (LIST)
{
$val{$_}++;
}
}
sub m
{
my %val = ();
map {$val{$_}++} LIST;
}
sub fem
{
my %val =();
foreach my $i (LIST)
{
$val{$i}++;
}
}
sub fe
{
my %val =();
foreach $i (LIST)
{
$val{$i}++;
}
}
Benchmark: timing 1000 iterations of for (@list), foreach $i (@list), foreach my $i (@list), grep, map...
for (@list): 434 secs (432.56 usr 0.03 sys = 432.59 cpu)
foreach $i (@list): 468 secs (459.17 usr 0.02 sys = 459.19 cpu)
foreach my $i (@list): 436 secs (433.35 usr 0.01 sys = 433.36 cpu)
grep: 463 secs (460.89 usr 0.00 sys = 460.89 cpu)
map: 510 secs (508.91 usr 0.00 sys = 508.91 cpu)
--
Eric D. Friedman
friedman@uci.edu
------------------------------
Date: Fri, 10 Oct 1997 08:18:36 -0700
From: "Brian L. King" <blk@redneck.intel.com>
Subject: Re: Need Help Parsing ASCII File
Message-Id: <343E474C.3F54BC7E@redneck.intel.com>
Tad McClellan wrote:
>
> Rob Truban (rtruban@erols.com) wrote:
> : Hi all,
>
> Hi.
>
> : I'm a Perl Newbie in need of advice. I want to take an ASCII text file
> : (which is the result of an SQL query done on a Sybase DB), parse the
>
> Is this the output from isql, with all those dashes and stuff?
>
> I think I did something like this once before in a galaxy far, far away...
>
> : text file and populate an Access DB with the info. For the record, this
> : will not be a web based app...
>
<snip>
>
> : Essentially, what I need to do is take each word in the
> : file and make it a scalar. None of the elements in the header have
> : white space, if that helps. I want the header data to be the keys in
> : the associative array, then use the "actual" data to fill in the record
> : portion of the array. Each Array "key" would associate to a table field
> : in the Access DB, and the "record" portion of the array would be used to
> : fill in the records in Access table.
>
> : Does that make sense??
>
> Not much ;-(
>
> : I'm not sure if I'm approaching this the right
> : way.
>
> : Any input would be greatly appreciated.
>
I've done a LOT of this, but in a different way. Parsing isql output
into an associative array is difficult because of the multiline data
"rows" returned by isql.
To avoid the hassle, I installed sybperl which lets you talk directly to
the Sybase server (SQL or replication server) and get your data back,
already in an associative array, just as you've described (or regular
array, if you choose). From there, it's easy to crunch the numbers,
format your output, yada, yada, yada.
I forget where the latest sybperl is, but it *may* be on CPAN. You can
definitely find it (as I did) by searching the web and chasing some
links.
You'll need to install perl5 & sybperl on an os that Sybase supports
(NT, NCR SysV, Solaris, ???) 'cause you need their libraries.
If you're interested and can't find sybperl, send me a mail. I'll try
to help.
-blk
--
----------------------------------------------------------------------
Brian L. King
m/blk@(redneck|mailbox\.jf)\.intel\.com/
Server Engineering, Intel Corporation. Hillsboro, Oregon
------------------------------
Date: Fri, 10 Oct 1997 11:15:24 -0700
From: Matthew Reimer <mreimer@vpop.net>
Subject: need tricky regex
Message-Id: <343E70BC.2C8817D3@vpop.net>
I need a single regex to pull out two pieces of information from a
stream that looks like the text at the end of this message.
I want to capture the text between the <H3></H3> tags, and the HREF, if
there is not another <H3> tag between the first <H3> and the <A
HREF...>.
Using the sample text below, this should return ('Title 1', 'abc.html')
and ('Title 3', 'def.html').
In my program, I read a web page into a string, and match the string
like this:
while ($page =~ /$regex/misg) {
do something with $1 (title) and $2 (href)
}
The closest I can get is the regex below, which doesn't work properly:
<H3>(*?)</H3>.*?<A HREF=(.*?)>
The problem I'm having is that this regex is returning ('Title 1',
'abc.html') which is correct, but the second match is ('Title 2',
'def.html'); instead, I need it to return ('Title 3', 'def.html').
Can someone suggest a regex that would handle this?
Matt
------
<H3>Title 1</H3>
ipsum <i>lorem</i>...
<a href="abc.html">qwerty</a>
<H3>Title 2</H3>
multiple lines of <b>text</b> and tags...
<H3>Title 3</H3>
more text and <b>tags</b>...
<a href="def.html">asdfg</a>
------
------------------------------
Date: Fri, 10 Oct 1997 17:15:34 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: need tricky regex
Message-Id: <comdog-ya02408000R1010971715340001@news.panix.com>
In article <343E70BC.2C8817D3@vpop.net>, Matthew Reimer <mreimer@vpop.net> wrote:
>I need a single regex to pull out two pieces of information from a
>stream that looks like the text at the end of this message.
>
>I want to capture the text between the <H3></H3> tags, and the HREF, if
>there is not another <H3> tag between the first <H3> and the <A
>HREF...>.
>
>Using the sample text below, this should return ('Title 1', 'abc.html')
>and ('Title 3', 'def.html').
>The closest I can get is the regex below, which doesn't work properly:
>
> <H3>(*?)</H3>.*?<A HREF=(.*?)>
>
>Can someone suggest a regex that would handle this?
a regex for this gets really nasty... how about redefining the
solution? you can split the data in pieces based on the '<H3>', then
check each of the peices individually. there won't be overlap of the
different sections since they are stored separately.
consider this example (don't be afraid of the regex, it's just
eXtended to show comments. it's very similar to what you already
have. good luck :)
#!/usr/bin/perl -w
local $/ = undef;
$data = <DATA>;
@sections = split /<h3>/i, $data;
foreach( @sections )
{
$hash{$1} = $3 if
m:
#this part matches the headline title
#remember the opening headline tag is not there any more
(.*?) #anything (including \n) non-greedily
</h3> #the closing tag
#this part matches anything non-greedily
.*?
#this part matches the anchor tag
<a #the start of an anchor tag
\s+ #at least one whitespace character
href #the hypertext reference attribute
\s*=\s* #an equal sign possibly surrounded by whitespace
(["']?) #maybe a quote thing
([^"'\s>]+) #not anything that closes the quote or tag
\2? #a back reference to the quote thing - optional
[^>]* #everything else in the anchor tag (e.g. JavaScript)
> #the end bracket on the anchor tag
:xisg;
}
foreach (keys %hash)
{
print "$_: $hash{$_}\n";
}
__DATA__
<H3>Title 1</H3>
ipsum <i>lorem</i>...
<a href="abc.html">qwerty</a>
<H3>Title 2</H3>
multiple lines of <b>text</b> and tags...
<H3>Title 3</H3>
more text and <b>tags</b>...
<a href="def.html">asdfg</a>
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 10 Oct 1997 21:24:41 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: need tricky regex
Message-Id: <eli$9710101700@qz.little-neck.ny.us>
Posted and mailed.
Matthew Reimer <mreimer@vpop.net> wrote:
> I want to capture the text between the <H3></H3> tags, and the HREF, if
> there is not another <H3> tag between the first <H3> and the <A
> HREF...>.
This is very tricky with regexps, unless you split the input on
each /<H3>/.
> Using the sample text below, this should return ('Title 1', 'abc.html')
> and ('Title 3', 'def.html').
> In my program, I read a web page into a string, and match the string
> like this:
[corrected and simplified version of his code]
while ($page =~ m:<H3>(.*?)</H3>.*?<A HREF=(.*?)>:misg) {
do something with $1 (title) and $2 (href)
}
> The problem I'm having is that this regex is returning ('Title 1',
> 'abc.html') which is correct, but the second match is ('Title 2',
> 'def.html'); instead, I need it to return ('Title 3', 'def.html').
The second .*? eats the next <H3>. The *? may make it non-greedy, but
it does not force perl to find the shortest matches.
> Can someone suggest a regex that would handle this?
I tried m:<H3>([^>]*)</H3>(?:(?!.*?<H3>).*?)<A HREF=(.*?)>: but that
did not work, so I'd recomend junking *? altogether.
> <H3>Title 1</H3>
> ipsum <i>lorem</i>...
> <a href="abc.html">qwerty</a>
> <H3>Title 2</H3>
> multiple lines of <b>text</b> and tags...
> <H3>Title 3</H3>
> more text and <b>tags</b>...
> <a href="def.html">asdfg</a>
m:<H3>([^>]*)</H3>(?:[^<]|<(?!H3))*<A HREF=(.*?)>:misg
Worked for me on that text.
Elijah
------
thinks non-greediness is much too complicated for most people to use wisely
------------------------------
Date: 10 Oct 1997 21:56:32 GMT
From: "Allie Ford" <forda@monroe.army.mil>
Subject: Passing arguments to a script in HTML
Message-Id: <01bcd5c0$b2f99730$7664f893@forda>
Trying to pass arguments obtained in an HTML form to a Perl script in NT.
Tested the script in command mode and the script can print the arguments.
But when arguments are passed to the script in a Form Action tag, the
script prints cannot see the arguments and prints empty arguments.
Using IIS 3.0 and <FORM ACTION="/scripts/HelloWorld.pl arg1 arg2"
METHOD="GET">
Thanks ahead of time.
------------------------------
Date: Fri, 10 Oct 1997 13:47:58 -0600
From: Robert Goff <ragoff@sandia.gov>
Subject: Re: PERL and Access
Message-Id: <343E866E.DCFB79BE@sandia.gov>
> Access isn't recognizing the \n operator as a line break to
> move on to the next entry. I also tried using the \r operator as well
> as the \r\n operators together.
Try writing a literal ^M (control-m). That's what I have to to for a
flat file that gets imported into FoxBase.
--
=================================================
Robert Goff email: ragoff@sandia.gov
Sandia National Labs Phone: (505)284-3639
------------------------------
Date: Fri, 10 Oct 1997 21:40:13 GMT
From: yves@streamwave.com (Yves Dagenais)
Subject: Perl DBM file sizes?!?
Message-Id: <343e9efa.116163125@news.synapse.net>
Hello,
I'm taking an ASCII tab delimited file (file size is 1.4MB with about
25,000 records) and creating a DBM with it. The interesting thing is
that under different platforms, I get WAY different file sizes... Here
are my results when running this import under various platforms:
Under FreeBSD:
- DBM file size is approx 7 Megs.
- file extension becomes a .db
Under Win95:
- DBM file size is approx. 70 Megs!
- file extension becomes a .pag & a .dir
Under Solaris:
- DBM file size is approx. 50 Megs!
- file extension becomes a .pag & a.dir
My questions is does anybody know why .pag DBMs are sooo much larger
than the FreeBSD .db DBM format.??? Is the .db DBM format using a
compress of some sort? If so, can I enable that on the other
platforms?
Any help would be appreciated,
Thanks!
Yves
yves@streamwave.com
------------------------------
Date: Fri, 10 Oct 1997 14:08:00 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Peter Rose <WISH@uriacc.uri.edu>
Subject: Re: Perl Questions
Message-Id: <Pine.GSO.3.96.971010140608.4500L-100000@usertest.teleport.com>
On Thu, 9 Oct 1997, Peter Rose wrote:
...
> So this question probably has more to do with your Web-server
> configuration than Perl, and to get an answer, you'll probably have to
> tell us what you're using for server software.
No, please don't! :-) Instead, if you must tell somebody, tell the folks
in a newsgroup about servers. They can give you a better and more-complete
answer than we can give you here, 'cause around here, we try to talk about
nothing but Perl itself. Thanks!
--
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: Fri, 10 Oct 1997 14:13:51 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Gail Hunn <hunngai@fast.net>
Subject: Re: Perl5.003: Is it possible to alter the sort order for a single sort?
Message-Id: <Pine.GSO.3.96.971010141258.4500N-100000@usertest.teleport.com>
On Thu, 9 Oct 1997, Gail Hunn wrote:
> Is there any way to tell the sort function to use a different order
> from the default?
The entry under 'sort' in the perlfunc(1) manpage should tell you
everything you need. Is there something else that you're looking for?
--
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: Fri, 10 Oct 1997 13:21:54 -0400
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: PerlScript & ASP...accessing System Command Line?
Message-Id: <-1010971321540001@aggie.coaps.fsu.edu>
In article <343e440b.153888499@News>, paul_burke@onesource.com (Paul T.
Burke) wrote:
+ Greetings,
+
+ I am a newbie to PerlScript and ASP. In an attempt to port over my
+ existing Perl scripts to PerlScript and ASP, I am in desperate need of
+ accessing the Windows NT system command line. Could anyone point me
+ to an object that provides system call functionality. [being able to
+ capture the output back would be a big plus as well.]
Ummm...forgive my ignorance (I don't have access to NT), but shouldn't
the port permit you to use the 'system ()' interface??
James
--
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: Fri, 10 Oct 1997 13:16:35 -0500
From: Darin Burleigh <burleigh@hackberry.chem.niu.edu>
Subject: Re: please help!
Message-Id: <343E7103.7580@hackberry.chem.niu.edu>
Gang Wang wrote:
>
> Hi,
>
> I'm a beginner in Perl. I'm trying to write a perl script
> to read/modify the registry content in Windows NT Win32 environment.
> It uses Win32::Registry package like this:
> use Win32::Registry
>
> But when I tried to compile it, it gave me error:
> Goto undefind subroutine &AutoLoader::AUTOLOAD at C:\Perl\lib/Win32/
> Registry.pm line 84.
>
> Can anyone give me the reason for this compilation error?
I'd guess that very cryptic message means your should
try looking at line 84 in the file Registry.pm. I'd even
hazard a guess that the line has a call to subroutine
named Autoloader, which is probably not installed properly
on your machine. don't ask me how I know this. the essence
of being a Perl Guru is to know the unknowable.
==========================================================
- darin
burleigh@hackberry.chem.niu.edu
\\//\\//.\\//\\//.\\//\\//. http://hackberry.chem.niu.edu/HOME/dcb/
'2 kinds of green, look out!' - dieter rot
------------------------------
Date: Fri, 10 Oct 1997 18:57:45 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: Posting to a Newsgroup with a Perl Script.
Message-Id: <343e7687.1916113@news.wwa.com>
On Thu, 09 Oct 1997 16:56:21 -0700, Brandon Stirling
<brandons@uidaho.edu> wrote:
>Posting to a Newsgroup with a Perl Script.
This better not just mean: spamming Usenet with a perl script. If it
does, then we will have to work on making Brandon's life miserable
with a perl script. :-)
>This should be an easy task, but I can only find a method to read
>Newsgroups with a perl script.
It is easy, too easy. The reason you don't find many Usenet posting
scripts is because very few people like Spam!
>Can anyone in Perl land give me a starting point for this process?
Look for the Net:NNTP module and use the 'post()' method. If it isn't
already installed, it is part of the libnet distribution and should be
available from any CPAN site. If you are stuck in perl version 4.x
land, you will probably have to play with "sockets.pl". Good luck.
Have fun. Be nice. Be very, very nice.
Streben nach Wahrheit
Faust Gertz
Philosopher at Large
"We're headed for social anarchy when people start pissing on
bookstores!" --Tom Waits, _The Fisher King_
------------------------------
Date: Fri, 10 Oct 1997 14:26:53 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "George J. Lee" <gjlee@uclink4.berkeley.edu>
Subject: Re: Question: File locking
Message-Id: <Pine.GSO.3.96.971010141459.4500O-100000@usertest.teleport.com>
On Thu, 9 Oct 1997, George J. Lee wrote:
> I am not actually writing to the file I lock; I
> am only using it so two programs can't buy at the same time.
On many (most? all?) systems, you must open the file with write access
before you can lock the file. It's easy to make a test script which will
tell you whether your strategy is working:
#!/usr/bin/perl -w
$| = 1; # No output buffering
use strict;
use Fcntl qw/:flock/;
print "Process $$ starting...\n";
open FILE, "+>>lockable"
or die "Can't open file for update: $!";
print "Process $$ requesting lock...\n";
flock FILE, LOCK_EX
or die "Can't get exclusive lock: $!";
print "Process $$ has lock...\n";
sleep 5;
print "Process $$ closing file and releasing lock...\n";
close FILE
or die "Problem closing: $!";
exit;
Just save this as "locktest", then use a command like "locktest &"
repeatedly to try three or so of these at once. 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: Fri, 10 Oct 1997 14:34:52 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jim Sauer <jim@theaction.com>
Subject: Re: range of return values for rand function
Message-Id: <Pine.GSO.3.96.971010143419.4500R-100000@usertest.teleport.com>
On Thu, 9 Oct 1997, Jim Sauer wrote:
> According to the camel book :
> rand returns a value between 0 and 1 (including 0 and excluding 1).
> rand EXPR returns a number between 0 and the value of EXPR.
> Is that also (including 0 but excluding the value of EXPR)?
Yes; you can get zero, but never EXPR, from a call to rand. 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: Fri, 10 Oct 1997 14:32:01 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: peo@sprintmail.com
Subject: Re: Reading Variable Names from a file
Message-Id: <Pine.GSO.3.96.971010142742.4500P-100000@usertest.teleport.com>
On Thu, 9 Oct 1997 peo@sprintmail.com wrote:
> I have a file that has a list of variable references in it of the form:
>
> MYPATH=$PATH:/HOME/MYDIR
> NEWPATH=${MYPATH}
>
> etc.
>
> What I want to do is read in the file and process each line picking out
> all the variable references (both types $VAR and ${VAR})
Sounds as if you want to do a pattern match, perhaps like this:
while (<FILE>) {
s<\$(\w+)|\{(\w+)\}> {
# In here, the variable name, without the dollar
# sign, should be in the magical $+ variable.
# So you could perhaps do this:
$value{$+}
}ge;
# Maybe print out $_ here?
}
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: Fri, 10 Oct 1997 18:34:12 GMT
From: alex@gossamer-threads.com (Alex Krohn)
Subject: regexp help..
Message-Id: <343e7480.6016787@news.supernews.com>
Hi,
I'm hoping someone can help me out here. I have a string, and I need
to replace a word in that string with bold tags around it. Something
like the following:
$output =~ s,\Q$word\E,<STRONG>$word</STRONG>,gi;
This works, but unfortuantely, I don't want to replace the word if it
is found inside of a < >. For instance if the word is in a <A
HREF="http://blah/$word/blah/">. I don't want the reg expression to
replace it.
Any suggestions/ideas?
Much appreciated,
Alex
------------------------------
Date: Fri, 10 Oct 1997 15:38:05 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: regexp help..
Message-Id: <dn3m16.3k2.ln@localhost>
Alex Krohn (alex@gossamer-threads.com) wrote:
: I'm hoping someone can help me out here. I have a string, and I need
: to replace a word in that string with bold tags around it. Something
: like the following:
: $output =~ s,\Q$word\E,<STRONG>$word</STRONG>,gi;
: This works, but unfortuantely, I don't want to replace the word if it
: is found inside of a < >. For instance if the word is in a <A
: HREF="http://blah/$word/blah/">. I don't want the reg expression to
: replace it.
: Any suggestions/ideas?
Sure:
s,(<[^>]+>)|\Q$word\E,defined($1) ? $1 : "<STRONG>$word</STRONG>",gie;
The basic idea is to match both cases, and then only do your
substitution for the case you choose.
: Much appreciated,
You're welcome.
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: 10 Oct 1997 21:35:40 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: regexp help..
Message-Id: <eli$9710101723@qz.little-neck.ny.us>
Posted and mailed.
Alex Krohn <alex@gossamer-threads.com> wrote:
> $output =~ s,\Q$word\E,<STRONG>$word</STRONG>,gi;
>
> This works, but unfortuantely, I don't want to replace the word if it
> is found inside of a < >. For instance if the word is in a <A
> HREF="http://blah/$word/blah/">. I don't want the reg expression to
> replace it.
>
> Any suggestions/ideas?
This is slightly tricky because the context is not exactly next to
the $word.
I'd try something like this (untested):
1 while ($output =~ s,\Q$word\E([^>]*(?:<|\Z)),<STRONG>$word</STRONG>$1,gi);
The while loop is to handle the case of
$word foo $word <a ...
properly. You need a much more complicated RE if you want to handle
<img src="http://blah/$word/blah/" alt="<alt>"> correctly. Doable,
but I don't want to bother with that now. :^)
Elijah
------
sometimes wishes vi could do "1 while(s///g);" type stuff
------------------------------
Date: Fri, 10 Oct 1997 15:56:28 -0500
From: Arthur Darren Dunham <add@rice.edu>
Subject: Why the ambiguity?
Message-Id: <343E967C.42A0@rice.edu>
So I'm trying to open a file based on IP subnet in $sub...
open (FILE, "+>>128_42_$sub_0");
Well, that's not going to work.. The $sub_0 will be interpreted
as a single variable... So I try this..
open (FILE, "+>>128_42_${sub}_0");
Now I get a warning that ...
Ambiguous use of ${sub} resolved to $sub at ....
I was assuming that I could always use ${var} within a
double-quoted string. Now I'm guessing that this is worrying
about some sort of referenced hash or anonymous hash that I might
be trying to define?? Maybe?
Is there a 'right' way to do this 'in-string' without having
the parser worry?
-Thanks.
--
Darren Dunham add@is.rice.edu
UNIX Sysadmin Rice University
(This line currently in revision) Houston, TX
Any resemblance between real opinions and my post is coincidental
------------------------------
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 1158
**************************************