[18133] in Perl-Users-Digest
Perl-Users Digest, Issue: 293 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 15 09:06:12 2001
Date: Thu, 15 Feb 2001 06:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <982245910-v10-i293@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 15 Feb 2001 Volume: 10 Number: 293
Today's topics:
foreach - thoughts (Wolfgang S.)
Re: foreach - thoughts (Wolfgang Schauer)
Hash containing arrays? <agandhi@mail.utexas.edu>
Re: Hash containing arrays? egwong@netcom.com
Re: Hash containing arrays? (Damian James)
Re: Hash containing arrays? (Bernard El-Hagin)
Re: Help understanding Lists of Lists or Multi-dimensio (Michel Dalle)
Re: How can I use template files? <fxn@retemail.es>
Re: How can I use template files? (Anno Siegel)
How do i do this <egon.vennik@wanadoonl>
Re: How do i do this <beable@my-deja.com>
Re: no headers using CGI.pm <ron@savage.net.au>
Re: perl -e '$a='*'' What's wrong with it ? (Villy Kruse)
Re: perl -e '$a='*'' What's wrong with it ? (Abigail)
Re: perl -e '$a='*'' What's wrong with it ? (Villy Kruse)
Re: perl -e '$a='*'' What's wrong with it ? (Abigail)
perl support thread <hauhau@seed.net.tw>
Re: Perl, Solaris and readdir64 (Joe Smith)
Re: Problem on mail (Abigail)
Re: Proper sorting - alphanumeric values? <pdcawley@bofh.org.uk>
Re: regex experts (Anno Siegel)
Re: regex experts (Abigail)
RegEx Help Pls <grichards@endertechnology.com>
Re: RegEx Help Pls <mpapesch@gmx.de>
Re: Using Modules (Garry Williams)
Re: Why can't I grab this URL? (Malcolm Ray)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Feb 2001 11:40:15 GMT
From: w-s@gmx.de (Wolfgang S.)
Subject: foreach - thoughts
Message-Id: <96gf6v$l3o5c$1@fu-berlin.de>
Hi there,
------- snip -------
my $aref = [ "foo", "bar" ];
my $i = ($#{$aref}+1);
foreach ( reverse @$aref ) {
$i--;
if ( condition ) {
splice(@$fields,$i,1); next }
# else: do something with $_
}
------- snap -------
This code-snipped works for me, but I was still wondering if splicing
like this is 'healthy'. From 'man perlsyn':
If any part of LIST is an array, foreach will get very
confused if you add or remove elements within the loop
body, for example with splice. So don't do that.
Any comments ?
In general, what does foreach 'do' with the list while iterating ?
I mean, is it legal to say "foreach ( $sth->fetchall_arrayref )"
where $sth is a DBI statement handle, taking into account that
DBI::fetchall_arrayref should be called only once ?
If foreach 'evaluates' $sth->fetchall_arrayref everytime it loops,
something wired might happen.
Thanks for enlightment !
Greets,
Wolfgang
------------------------------
Date: 15 Feb 2001 11:42:19 GMT
From: w-s@gmx.de (Wolfgang Schauer)
Subject: Re: foreach - thoughts
Message-Id: <96gfar$l3o5c$2@fu-berlin.de>
sorry, code looks like this of course:
------- snip -------
my $aref = [ "foo", "bar" ];
my $i = ($#{$aref}+1);
foreach ( reverse @$aref ) {
$i--;
if ( condition ) {
splice(@$aref,$i,1); next }
# else: do something with $_
}
------- snap -------
------------------------------
Date: Thu, 15 Feb 2001 00:27:18 -0600
From: "Amish H. Gandhi" <agandhi@mail.utexas.edu>
Subject: Hash containing arrays?
Message-Id: <3A8B76C6.A1B0538B@mail.utexas.edu>
Hi...
Is there a way to create a hash of arrays? Or am I restricted only to
scalar values?
eg %master_hash = ($key, @array1);
or $master_hash{$key}=@array1;
Thanks..
-A
------------------------------
Date: Thu, 15 Feb 2001 07:00:49 GMT
From: egwong@netcom.com
Subject: Re: Hash containing arrays?
Message-Id: <B8Li6.1930$Sx5.147515@news.flash.net>
Amish H. Gandhi <agandhi@mail.utexas.edu> wrote:
> Is there a way to create a hash of arrays? Or am I restricted only to
> scalar values?
>
> eg %master_hash = ($key, @array1);
>
> or $master_hash{$key}=@array1;
Hash values can only be scalars, but lucky for you, you can use a
scalar to reference an array (or a hash or scalar or coderef, etc.)
You'll want to do something like:
$master_hash{$key} = [ @array ]; # note use of square brackets
... and later on ...
my @array = @{$master_hash{$key}};
See perlreftut, perlref and perldata.
------------------------------
Date: 15 Feb 2001 07:17:56 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Hash containing arrays?
Message-Id: <slrn98n0kh.qu0.damian@puma.qimr.edu.au>
Thus spake egwong@netcom.com on Thu, 15 Feb 2001 07:00:49 GMT:
>Amish H. Gandhi <agandhi@mail.utexas.edu> wrote:
>> Is there a way to create a hash of arrays? Or am I restricted only to
>> scalar values?
>>...
>...
>
>See perlreftut, perlref and perldata.
>
Not to mention perldsc and perllol.
To the OP: you can find these manuals in the Perl documentation installed
with perl on your computer. Just go to a command line, and type, eg:
perldoc perlref
HTH
Cheers,
Damian
--
$;=ord$%,$:=$;-ord q,.,,$_=q 13346:3366:3276:3326:3386:546:566:966:3396:3376:1.
q 73386:546:;96:3326:3336:3386:3266:3236:3366:546::26:3236:3366:32:6:546:32667.
q,:;96:;;6:3296:3236:3366:326:56,,s,.,;ord($&)-$:-$;;;;;,eg,s,$;,;chr$&-$:;,eg,
eval eval; #requires 5.6.0 ## my first attempt at one of these...
------------------------------
Date: Thu, 15 Feb 2001 07:24:29 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Hash containing arrays?
Message-Id: <slrn98n11b.7s.bernard.el-hagin@gdndev25.lido-tech>
On Thu, 15 Feb 2001 00:27:18 -0600, Amish H. Gandhi
<agandhi@mail.utexas.edu> wrote:
>Hi...
>
>Is there a way to create a hash of arrays? Or am I restricted only to
>scalar values?
The answer to both those questions is "Yes". But a scalar can be a
reference to an array. Read:
perldoc perlref
perldoc perllol
perldoc perldsc
Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: Thu, 15 Feb 2001 12:08:52 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Help understanding Lists of Lists or Multi-dimensional arrays
Message-Id: <96ggvq$ld2$1@news.mch.sbs.de>
In article <96fk2g$1ie$1@plonk.apk.net>, "Jody Fedor" <Jodyman@usa.net> wrote:
>First, I've read and re-read Programming Perl pg 257-264. Also Perl
>Cookbook
>pg 97-105 I don't understand them
>..
I'd recommend that you read the following documentation :
1) perldoc perldata
2) perldoc perldsc
3) perldoc perlfaq4
If I understand your description correctly, you're looking for a hash of
hashes, and not an array of arrays...
After you've gone through those three and solved your problem, have a
quick look at perllol, perlreftut and perlref as well for later use.
HTH,
Michel.
------------------------------
Date: Thu, 15 Feb 2001 08:35:18 +0100
From: F. Xavier Noria <fxn@retemail.es>
Subject: Re: How can I use template files?
Message-Id: <nj1n8t01mhgqredahcs1qa7209fbv88e49@4ax.com>
On Wed, 14 Feb 2001 18:26:28 -0800, Ameesh Oza <ameesh@interweavetech.com>
wrote:
: I am trying to use template files to create other files.
: I want to substitute variables inside the template files with
: the values that my perl extracts from somwhere. Is there an
: automatic or algorithmic way to do this?
Look for Text::Template at http://search.cpan.org.
-- fxn
------------------------------
Date: 15 Feb 2001 10:19:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How can I use template files?
Message-Id: <96gag5$79k$1@mamenchi.zrz.TU-Berlin.DE>
Ameesh Oza <ameesh@interweavetech.com> wrote in comp.lang.perl.misc:
>I am trying to use template files to create other files.
>I want to substitute variables inside the template files with
>the values that my perl extracts from somwhere. Is there an
>automatic or algorithmic way to do this?
Another poster has pointed you to Text::Template.
>As an aside...
>
>If
>
>@array_of_vars="$var1","$var2"... (list of variable names)
>
>How can I substitute the values of these vars directly into the array??
Did you even try that line of code? It does not assign a list of
variable names to @array_of_vars as you seem to think.
Please, if you expect other people to spend time to solve your
problem, spend the time to state your problem correctly.
Anno
------------------------------
Date: Thu, 15 Feb 2001 08:30:49 +0100
From: "Egon" <egon.vennik@wanadoonl>
Subject: How do i do this
Message-Id: <3a8b8523$0$2221@reader4>
I want to make this kind of pricelist:
http://www.funprice.nl/img/prijslijst2.html
Is there somekind of script which also allows me to create and manage the
content of the list? Can this be done with a flat file database?
Regards
--
Egon
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(for reply put a dot between wanadoo and nl)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Thu, 15 Feb 2001 13:43:50 GMT
From: Beable van Polasm <beable@my-deja.com>
Subject: Re: How do i do this
Message-Id: <m3itmculsj.fsf@beable.van.polasm.bigpond.net.au>
"Egon" <egon.vennik@wanadoonl> writes:
> I want to make this kind of pricelist:
> http://www.funprice.nl/img/prijslijst2.html
>
> Is there somekind of script which also allows me to create and manage the
> content of the list?
I think you would need a custom-designed solution to manage your
prijslijst.
> Can this be done with a flat file database?
It sure can. This simple example program shows how you can use
Perl's GDBM module to store a list sort of like that in a simple
database.
--------------8<---------------------------------------------------------
#!/usr/bin/perl -w
use strict;
use GDBM_File;
my %pricehash = ();
tie %pricehash, 'GDBM_File', "prijslijst", &GDBM_WRCREAT, 0600 or
die "couldn't open pricelist database file: $!";
# add some stuff to the database
my $i = 0;
for ($i = 0; $i < 100; $i++)
{
my $product_name = "product" . $i;
my $aanbieding = int(rand 2);
my $price = rand 10000;
my $price_ex_btw = $price * 0.84;
my $info = "$aanbieding,$price,$price_ex_btw";
$pricehash{$product_name} = $info;
}
# get some stuff out of the database
for ($i = 0; $i < 10; $i++)
{
my $product_id = "product" . int(rand 100);
my $info = $pricehash{$product_id};
print $product_id, ": ", $info, "\n";
}
untie %pricehash;
--------------8<---------------------------------------------------------
--
This isn't right!! -- WCW Nitro Commentator #1
This is a travesty! -- WCW Nitro Commentator #2
IQC 78189333
http://members.nbci.com/_______/index.html
------------------------------
Date: Thu, 15 Feb 2001 21:12:24 +1100
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: no headers using CGI.pm
Message-Id: <I5Ni6.160$v4.7991@ozemail.com.au>
See below
--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html
Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov> wrote in message
news:863ddgu8oi.fsf@jon_ericson.jpl.nasa.gov...
> "Jeff Fletcher" <jeff_fletcher@pacbell.net> writes:
>
> > My server uses MS IIS, so I've been told I need to prevent my scripts
from
> > sending a header. I've tried to use...
If this is true...
Perl CGI scripts often do this:
use CGI;
my($q) = CGI -> new();
print $q -> header();
If yours does, drop the call to header.
------------------------------
Date: 15 Feb 2001 08:44:21 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: perl -e '$a='*'' What's wrong with it ?
Message-Id: <slrn98n5n3.v2e.vek@pharmnl.ohout.pharmapartners.nl>
On 14 Feb 2001 22:40:33 GMT, Abigail <abigail@foad.org> wrote:
>
>However, the
>
> '$a='*''
>
>is different. Again, quotes protect the shell from interpreting
>
> $a=
>
>but * *is* being interpreted, and expanded to a list of file/directory
>names. So, perl will get something like:
>
That is what I would expect, but I can't make any of my shell do this, unless
there is whitespace between ' and *.
$ /bin/echo '$a='*''
$a=*
/bin/echo '$a=' *''
$a= 2.2.14-5.0 2.2.14-5.0.tar.gz
This is confusing.
Villy
------------------------------
Date: 15 Feb 2001 10:13:18 GMT
From: abigail@foad.org (Abigail)
Subject: Re: perl -e '$a='*'' What's wrong with it ?
Message-Id: <slrn98natu.tv1.abigail@tsathoggua.rlyeh.net>
Villy Kruse (vek@pharmnl.ohout.pharmapartners.nl) wrote on MMDCCXXV
September MCMXCIII in <URL:news:slrn98n5n3.v2e.vek@pharmnl.ohout.pharmapartners.nl>:
!! On 14 Feb 2001 22:40:33 GMT, Abigail <abigail@foad.org> wrote:
!!
!! >
!! >However, the
!! >
!! > '$a='*''
!! >
!! >is different. Again, quotes protect the shell from interpreting
!! >
!! > $a=
!! >
!! >but * *is* being interpreted, and expanded to a list of file/directory
!! >names. So, perl will get something like:
!! >
!!
!!
!! That is what I would expect, but I can't make any of my shell do this, unless
!! there is whitespace between ' and *.
!!
!! $ /bin/echo '$a='*''
!! $a=*
Hmmm, you are right.
In that case, it would mean Perl sees "$a=*", which isn't valid Perl either.
Abigail
--
use lib sub {($\) = split /\./ => pop; print $"};
eval "use Just" || eval "use another" || eval "use Perl" || eval "use Hacker";
------------------------------
Date: 15 Feb 2001 13:57:26 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: perl -e '$a='*'' What's wrong with it ?
Message-Id: <slrn98no25.jf.vek@pharmnl.ohout.pharmapartners.nl>
On 15 Feb 2001 10:13:18 GMT, Abigail <abigail@foad.org> wrote:
>
>
>Hmmm, you are right.
>
>In that case, it would mean Perl sees "$a=*", which isn't valid Perl either.
>
>
You could always avoid quote problems by using q() or qq() quoting.
Then you will get exactly what you wrote at the shell prompt.
It would be better than this:
$ echo '$a='"'*'"
$a='*'
which concatanates the strings '$a=' and "'*'".
or this
$ echo "$a='*'"
='*'
Villy
------------------------------
Date: 15 Feb 2001 14:03:13 GMT
From: abigail@foad.org (Abigail)
Subject: Re: perl -e '$a='*'' What's wrong with it ?
Message-Id: <slrn98nod1.tv1.abigail@tsathoggua.rlyeh.net>
Villy Kruse (vek@pharmnl.ohout.pharmapartners.nl) wrote on MMDCCXXV
September MCMXCIII in <URL:news:slrn98no25.jf.vek@pharmnl.ohout.pharmapartners.nl>:
:) On 15 Feb 2001 10:13:18 GMT, Abigail <abigail@foad.org> wrote:
:)
:)
:) >
:) >
:) >Hmmm, you are right.
:) >
:) >In that case, it would mean Perl sees "$a=*", which isn't valid Perl either.
:) >
:) >
:)
:) You could always avoid quote problems by using q() or qq() quoting.
:) Then you will get exactly what you wrote at the shell prompt.
:)
:) It would be better than this:
:)
:) $ echo '$a='"'*'"
:) $a='*'
:) which concatanates the strings '$a=' and "'*'".
:)
:) or this
:)
:) $ echo "$a='*'"
:) ='*'
You missed out the most obvious of all:
perl -e '$a="*"'
Abigail
--
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
------------------------------
Date: Thu, 15 Feb 2001 20:55:42 +0800
From: "hauhau" <hauhau@seed.net.tw>
Subject: perl support thread
Message-Id: <96gja0$4o3@netnews.hinet.net>
Hello!
I want to embed a perl in my c++ program.
so I downloaded the ActivePerl source.
But when it is linking, it say that it have unresolved external symbol
_PL_op_mutex and _PL_thr_key.
Can anyone tell me how to get it right ?
------------------------------
Date: 15 Feb 2001 11:13:10 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: Perl, Solaris and readdir64
Message-Id: <96gdk6$2e5q$1@nntp1.ba.best.com>
In article <mqGg6.722$Ld2.4018@eagle.america.net>,
Garry Williams <garry@zvolve.com> wrote:
>On Thu, 08 Feb 2001 13:25:17 GMT, James Pearson
><j.pearson@ge.ucl.ac.uk> wrote:
>
>[snip]
>
>>I can reproduce the same problem with some C code:
>>
>>dirp = opendir(dir);
>>while ((dp = readdir(dirp)) != NULL)
>> printf("%s ", dp->d_name);
>>closedir(dirp);
>>
>>If I replace readdir() in the C code with readdir64(), then it works OK
>>- the contents of the directory in question are printed out ...
>>
>>So my question is, can I do something similar in perl? Can I force perl
>>on Solaris to use readdir64() somehow? Or, is there some sort of
>>readdir64 for perl available via a module etc.?
>
> Rebuild perl with -DUSE_LARGE_FILES
Or upgrade to perl version 5.6.0, which defaults to using large files.
Note: The version of perl that ships with Solaris-8 does not
handle large files; the version at http://www.sunfreeware.com does.
(Perl 5.6.1 is expected out any week now.
http://www.perl.com/pub/q/archivep5p is one place to look for announcments.)
-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
------------------------------
Date: 15 Feb 2001 10:18:07 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Problem on mail
Message-Id: <slrn98nb6v.tv1.abigail@tsathoggua.rlyeh.net>
p3 (p3@netnavi.net) wrote on MMDCCXXV September MCMXCIII in
<URL:news:3A8B60ED.39356829@netnavi.net>:
## What does 'O' mean in the header 'Status' in a mail ?
##
## Status: RO
man perlmail
What do you mean, there is no such manual page? Oh, you mean Perl
is neither a MDA nor a MUA? Well, perhaps you should ask in a group
dealing with mail then.
Abigail
--
perl -Mstrict -we '$_ = "goto X.print chop;\n=rekcaH lreP rehtona tsuJ";X1:eval'
------------------------------
Date: 15 Feb 2001 09:03:13 +0000
From: Piers Cawley <pdcawley@bofh.org.uk>
Subject: Re: Proper sorting - alphanumeric values?
Message-Id: <m3k86sco8e.fsf@iest.bofh.org.uk>
Ren Maddox <ren.maddox@tivoli.com> writes:
> "Philip Obbard" <pobbard@hotresponse.com> writes:
>
> > My question is: Can I do a smarter sort of this? Can I mix pure numerics AND
> > alphanumerics and get the numerics to sort correctly, or is that not
> > possible? Is there a regex combo that might help?
>
> Yes, you can do this.
>
> The hard part is deciding exactly what the right order is, and then
> determining a comparison routine that gives you what you want.
>
> A quick first-pass is to use a numeric compare and then fall back on
> an ascii compare. Any values that don't look like numbers will
> compare as 0. This is possibly OK if all of your numeric-type values
> are greater than 0, but gets problematic if some of them are equal to
> or less than 0.
>
> Anyway, start with using:
>
> { $a <=> $b or $a cmp $b }
>
> as your comparison and go from there.
This has been discussed before. Can't remember if it was on here or on
perl-friends. What you suggest doesn't work in the case of 'F10' and
the like, and it's likely to have problems with 5.6.1, 5.6.2 and
5.6.10, so, using a Schwartzian Transform because the transformation
is pretty heavyweight:
map {$_->[0]}
sort {$a->[1] cmp $b->[1]}
map {[$_, pad_out($_)} @list
sub pad_out {
shift;
s/(\d+)/substr('0' x 20 . $1, -20)/e;
return $_;
}
This pads the numbers out with zeroes so that they are all 20
characters long (if your numbers are going to be longer than that then
use more than 20 chars), and fixed width numbers will always sort
correctly using alphabetic comparison.
--
Piers
------------------------------
Date: 15 Feb 2001 12:31:41 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: regex experts
Message-Id: <96gi7d$mmt$1@mamenchi.zrz.TU-Berlin.DE>
Garry Williams <garry@zvolve.com> wrote in comp.lang.perl.misc:
>On Wed, 14 Feb 2001 17:43:39 GMT, Uri Guttman <uri@sysarch.com> wrote:
>>
>>the $ before the ; makes no sense. that is going to be parsed as $;
>>which is an obscure perl var (used to separate keys in a old perl4 style
>>multilevel hash). $ only means an ending anchor if it is at the end of
>>the whole regex (or some component that can end the regex).
>
>That's interesting. So /$^/ would be parsed as $^, the (obscure)
>format_top_name Perl variable?
The parsing of "$" inside a regex is one of the murkier parts of the
Perl parsing process. "$" is interpreted as end-of-line immediately
before "|" and ")" instead of interpolating $| or $), while other
similar variables are interpolated.
Earlier editions of the Camel even talked about some statistics-based
heuristics in this context though I couldn't find it in the 3rd edition
in a hurry.
>A while back, I posted something like
>
> perl -wne '/start_pattern/ .. /$^/ and print' file
>as a way to print lines starting with the one that contains
>start_pattern and continuing though the end of file. My intention was
Yes, I have occasionally used /$^/ as a match-never pattern as well.
It seemed to work, but looking at the default content of $^, "STDOUT_TOP",
this is probably no surprise, even though $^ is indeed interpolated as
"print qr/$^/" shows.
So what *is* a simple regex that never matches?
Anno
------------------------------
Date: 15 Feb 2001 13:03:43 GMT
From: abigail@foad.org (Abigail)
Subject: Re: regex experts
Message-Id: <slrn98nktf.tv1.abigail@tsathoggua.rlyeh.net>
Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDCCXXV
September MCMXCIII in <URL:news:96gi7d$mmt$1@mamenchi.zrz.TU-Berlin.DE>:
^^
^^ So what *is* a simple regex that never matches?
/\z./
/(?=a)(?=b)/
/.\A/
/\w\b\w/
/.\b\B./
But why would you want a regex that never matches? In the mentioned
.. case, the arguments are not limited to regexes. Just like any other
operator, .. takes 2 expressions as arguments. 0, "" or undef produce
false as well.
Abigail
--
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
------------------------------
Date: Thu, 15 Feb 2001 08:26:33 GMT
From: "Gabriel Richards" <grichards@endertechnology.com>
Subject: RegEx Help Pls
Message-Id: <ZoMi6.14673$_D.1515365@typhoon.we.rr.com>
Here is the input string:
<td valign=top width="50%">
<a
href=/Regional/U_S__States/California/Metropolitan_Areas/Los_Angeles_Metro/C
ounties_and_Regions/South_Bay/Business_and_Shopping/><font
face=arial><b>Business & Shopping</b></font></a>
</td>
Here is my RegEx:
my @categories = ($content =~
/href\=(\/Regional\/U_S__States\/California\/Metropolitan_Areas\/Los_Angeles
_Metro\/Counties_and_Regions\/South_Bay\/.+)>/g);
print @categories;
I want to match everything between "href=" and the closing ">", but the
above doesn't work, it returns everything upto and including the "a" in
"</a>".
If I alter my RegEx to:
my @categories = ($content =~
/href\=(\/Regional\/U_S__States\/California\/Metropolitan_Areas\/Los_Angeles
_Metro\/Counties_and_Regions\/South_Bay\/.+)><f/g);
I get what I want in @categories.
Can someone help?
Thanks,
Gabe
--
Ender Technology
Website and Database Development for Small Business
http://www.endertechnology.com
310-532-7455
------------------------------
Date: Thu, 15 Feb 2001 10:10:39 +0100
From: Matthias Papesch <mpapesch@gmx.de>
Subject: Re: RegEx Help Pls
Message-Id: <96g6d8$b6f$00$1@news.t-online.com>
Hi,
Try to match '[^>]+' ,which is anything but a closing '>' , instead of
'.+', which is just anything.
HTH,
Matthias
Gabriel Richards wrote:
> Here is the input string:
>
> <td valign=top width="50%">
> <a
>
href=/Regional/U_S__States/California/Metropolitan_Areas/Los_Angeles_Metro/C
> ounties_and_Regions/South_Bay/Business_and_Shopping/><font
> face=arial><b>Business & Shopping</b></font></a>
> </td>
>
> Here is my RegEx:
>
> my @categories = ($content =~
>
/href\=(\/Regional\/U_S__States\/California\/Metropolitan_Areas\/Los_Angeles
> _Metro\/Counties_and_Regions\/South_Bay\/.+)>/g);
^^^^
> print @categories;
>
> I want to match everything between "href=" and the closing ">", but the
> above doesn't work, it returns everything upto and including the "a" in
> "</a>".
>
> If I alter my RegEx to:
>
> my @categories = ($content =~
>
/href\=(\/Regional\/U_S__States\/California\/Metropolitan_Areas\/Los_Angeles
> _Metro\/Counties_and_Regions\/South_Bay\/.+)><f/g);
>
> I get what I want in @categories.
>
> Can someone help?
>
> Thanks,
> Gabe
>
> --
> Ender Technology
> Website and Database Development for Small Business
> http://www.endertechnology.com
> 310-532-7455
>
>
------------------------------
Date: Thu, 15 Feb 2001 05:14:34 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Using Modules
Message-Id: <_AJi6.477$MF5.6460@eagle.america.net>
On Wed, 14 Feb 2001 15:02:21 -0800, terminalsplash
<shino_korah@yahoo.com> wrote:
[snip]
>What is wrong here?
>The compiler complains s1.pl didnot return a true value at s2.pl line 2.
>Please help
The manual can help a lot faster. From the perldiag manual page:
%s did not return a true value
(F) A required (or used) file must return a true value
to indicate that it compiled correctly and ran its
initialization code correctly. It's traditional to end
such a file with a "1;", though any true value would do.
See the require entry in the perlfunc manpage.
--
Garry Williams
------------------------------
Date: 15 Feb 2001 14:03:03 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: Why can't I grab this URL?
Message-Id: <slrn98nocn.djv.M.Ray@carlova.ulcc.ac.uk>
On Wed, 14 Feb 2001 05:24:00 GMT, What A Man ! <whataman@home.com> wrote:
>Why can't I grab this URL?
>
>http://www.fortunecity.com/millenium/blyton/243/clemrule.zip
>
>My coding below grabs most every URL for me and stores it
>in $tmpfile. However, a URL on a webhost like this one
>redirects to the webhost's HTML default page. From a
>browser I get the correct zip file, but from the perl
>script below I get a default html page. Why?
Cookies? fortunecity.com has a nasty habit of refusing to hand out
a document if you don't supply the right cookie.
--
Malcolm Ray University of London Computer Centre
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 V10 Issue 293
**************************************