[18071] in Perl-Users-Digest
Perl-Users Digest, Issue: 231 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 7 09:05:47 2001
Date: Wed, 7 Feb 2001 06:05:12 -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: <981554712-v10-i231@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 7 Feb 2001 Volume: 10 Number: 231
Today's topics:
Re: Ada feature borrowed for Perl?? <qvyht@iobox.fi>
Again---how to remove item in the array? <qvyht@iobox.fi>
Re: Again---how to remove item in the array? (Abigail)
Re: Again---how to remove item in the array? <joe+usenet@sunstarsys.com>
Re: Beginners Question (Tad McClellan)
Deleting Unnecessary Lines and Spaces in HTML <amskape@ev1.net>
don't want to let them enter & and = ... <emelin@my-deja.com>
Re: Fastest way of left-padding a number? <jonni@ifm.liu.se>
Re: Fastest way of left-padding a number? <jll63@easynet.be>
Re: Fastest way of left-padding a number? <jll63@easynet.be>
Re: Get file in string by virtual path????? <Martijn.vanPoppel@atosorigin.com>
Re: Get file in string by virtual path????? <thoren@southern-division.com>
h2xs and string constants renlen@my-deja.com
how to remove item in the array? <qvyht@iobox.fi>
Re: Linux does reclaim memory from perl <Jerome.Abela@free.fr>
Re: Need Help Checking IP Address Syntax w/ PERL? (Peter J. Acklam)
Pattern Extracting <philip.shean@uwe.ac.uk>
Re: Pattern Extracting (Bernard El-Hagin)
Re: Pattern Extracting <philip.shean@uwe.ac.uk>
Re: Pattern Extracting (Bernard El-Hagin)
Re: Pattern Extracting <philip.shean@uwe.ac.uk>
Re: Pattern Extracting (Bernard El-Hagin)
Re: Pattern Extracting <philip.shean@uwe.ac.uk>
Re: Pattern Extracting <amskape@ev1.net>
Re: Pattern Matching (Tad McClellan)
Re: Radical readdir suggestion <ccx138@coventry.ac.uk>
Re: regexp for splitting up file paths? <ccx138@coventry.ac.uk>
Re: regexp for splitting up file paths? (Philip Lees)
Scaling up sample data in an array of hashes (Philip Lees)
Re: Stream? Pipe? Socket? <s997659@ee.cuhk.edu.hk>
Re: XML::Parser question <matt@sergeant.org>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 07 Feb 2001 12:04:46 GMT
From: Hessu <qvyht@iobox.fi>
Subject: Re: Ada feature borrowed for Perl??
Message-Id: <3A813966.1133721D@iobox.fi>
Misanthrope wrote:
>
> Ada has two different keywords that deal with packages.
>
> If you had a package called Foo, you would make it visible to your code via
> the "with" statement.
> The "use" statement merges the package interface into your namespace.
> Without the "use", your code looks like this:
>
> Foo.somemethod();
>
> <gdemont@my-deja.com> wrote in message news:91cu9j$kkl$1@nnrp1.deja.com...
> >
> > > Does Ada use 'use' to use packages?
> >
> > Yep - Ada uses to use 'use' to use packages!
> >
> > Some sources on page below to take a look...
> >
> > http://members.nbci.com/_XMCM/gdemont/gsoft.htm
> >
> > G.
> >
> >
> > Sent via Deja.com
> > http://www.deja.com/
> >
Java-like!
Java is Ada without marketing errors...
------------------------------
Date: Wed, 07 Feb 2001 12:53:44 GMT
From: Hessu <qvyht@iobox.fi>
Subject: Again---how to remove item in the array?
Message-Id: <3A8144DF.12E6F945@iobox.fi>
I have a VERY, VERY big array (bigger than you can imagine)
with tiny tiny elements.
In loop one element is selected randomly, then another element
is selected randomly. These two items are something I want to get rid of
because random selection is getting more slower less there's free
elements
in array.
And I we don't want this little script stop its running,
don't we.
:)
can i do it with splice and how does this would work.
br,
lerning perl
------------------------------
Date: 7 Feb 2001 13:06:42 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Again---how to remove item in the array?
Message-Id: <slrn982i32.p6d.abigail@tsathoggua.rlyeh.net>
Hessu (qvyht@iobox.fi) wrote on MMDCCXVII September MCMXCIII in
<URL:news:3A8144DF.12E6F945@iobox.fi>:
--
-- I have a VERY, VERY big array (bigger than you can imagine)
-- with tiny tiny elements.
-- In loop one element is selected randomly, then another element
-- is selected randomly. These two items are something I want to get rid of
-- because random selection is getting more slower less there's free
-- elements
-- in array.
--
-- And I we don't want this little script stop its running,
-- don't we.
--
-- :)
-- can i do it with splice and how does this would work.
No, you really, really don't want to repeatedly splice a single element
out of a very, very big array. (Oh, and BTW, you don't have enough
memory to hold the array I can imagine).
The correct way to do this is to shuffle the array (see FAQ), then
read out the elements in order. And if you don't need all elements,
just shuffle till enough random elements are at the front (or back)
of the array.
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
------------------------------
Date: 07 Feb 2001 08:26:56 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Again---how to remove item in the array?
Message-Id: <m33ddqsjxb.fsf@mumonkan.sunstarsys.com>
Hessu <qvyht@iobox.fi> writes:
> I have a VERY, VERY big array (bigger than you can imagine)
> with tiny tiny elements.
> In loop one element is selected randomly, then another element
> is selected randomly. These two items are something I want to get rid of
> because random selection is getting more slower less there's free
> elements in array.
That's a fairly useless description of your problem. Please post a code
sample that illustrates
1) what the array elements look like;
2) what you are trying to do with the array.
I assume you've looked at
% perldoc -f splice
If that's too slow, maybe you want to use another structure besides
an array for this (like storing everything in a scalar and using
index and substring to access elements). Alternately, see
% perldoc -f pack
% perldoc -f vec
> can i do it with splice and how does this would work.
Yes.
--
Joe Schaefer "Perish the Universe, provided I have my revenge."
-- Cyrano de Bergerac
------------------------------
Date: Wed, 07 Feb 2001 12:44:00 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Beginners Question
Message-Id: <slrn9828s4.9eu.tadmc@tadmc26.august.net>
Scott Ferguson <sferguson@rationalconsulting.com> wrote:
>
>$label=<STDIN>; chomp $label;
>
>The name of the file is build.pl, so I want the user to be able to type
>build.pl REL2, on the command, and then have the program read the REL2
>as the $label variable string.
my $label = shift;
or
my $label = $ARGV[0];
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 07 Feb 2001 07:38:06 -0800
From: AmSkape <amskape@ev1.net>
Subject: Deleting Unnecessary Lines and Spaces in HTML
Message-Id: <3A816BDE.FAA4C29E@ev1.net>
I am writing a script that reads html pages into a scalar one line at a
time. It works except for when I run into a situation where an html line
is broken into multiple lines like so:
<p>This is a
line</p>
I would like this to be read into the variable as a single line as
opposed to two. I have tried substituting newline ("\n") with a space.
It helps with some lines but not with others. Is there a module that
formats html properly without unecessary newlines? Any help is greatly
apreciated.
------------------------------
Date: Wed, 07 Feb 2001 13:37:34 GMT
From: emelin <emelin@my-deja.com>
Subject: don't want to let them enter & and = ...
Message-Id: <95rj2u$aqn$1@nnrp1.deja.com>
I'm using the code below to fetch contents from a form. But if the user
enters & or = I encounter problems later on... things don't split
right... how do I check this before this code has split the contents??
%form = get_form();
sub get_form {
my (%form,$buffer,$name,$value,$pair,@pairs);
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$name =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex
($1))/eg;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex
($1))/eg;
$form{$name} = $value;
}
return %form;
}
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 7 Feb 2001 12:25:25 +0100
From: "Jonas Nilsson" <jonni@ifm.liu.se>
Subject: Re: Fastest way of left-padding a number?
Message-Id: <95rbal$lm3$1@newsy.ifm.liu.se>
I found a way that is faster on my platform (WinNT).
Try these:
use Benchmark;
$val=17;
timethese(2000000,{ 'test1',
'$a=sprintf("%04d",$val)',
'test2',
'$b=("0" x (4-length $val)).$val',
'test3',
'$c="0000";substr($c,(4-length $val),2)=$val',
'test4',
'$d=$val;$d=("0".$d) while ((length $d)<4)',
'test5',
'$e=substr("0000".$val,-4,4)',
'test6',
'$f=substr("0000".$val,-4)',
});
My result:
Benchmark: timing 2000000 iterations of test1, test2, test3, test4, test5,
test6...
test1: 6 wallclock secs ( 5.51 usr + 0.00 sys = 5.51 CPU) @
363174.14/s (n=2000000)
test2: 8 wallclock secs ( 8.30 usr + 0.02 sys = 8.32 CPU) @
240326.84/s (n=2000000)
test3: 8 wallclock secs ( 8.54 usr + 0.01 sys = 8.55 CPU) @
233863.42/s (n=2000000)
test4: 15 wallclock secs (14.99 usr + 0.02 sys = 15.01 CPU) @
133226.75/s (n=2000000)
test5: 7 wallclock secs ( 5.43 usr + 0.01 sys = 5.44 CPU) @
367849.92/s (n=2000000)
test6: 7 wallclock secs ( 5.37 usr + 0.01 sys = 5.38 CPU) @
371885.46/s (n=2000000)
Changing $val=17 to $val="17" gives sligtly faster result and so does "use
integer".
/jN
--
_____________________ _____________________
| Jonas Nilsson | | |
|Linkoping University | | Telephone |
| IFM | | --------- |
| Dept. of Chemistry | | work: +46-13-285690 |
| 581 83 Linkoping | | fax: +46-13-281399 |
| Sweden | | home: +46-13-130294 |
|_____________________| |_____________________|
"Jean-Louis Leroy" <jll63@easynet.be> wrote in message
news:m3hf26khxk.fsf@enterprise.starfleet...
> Given a number, say 17; given a fixed size, say 4; what's the fastest
> way of producing 0017? Faster than sprintf("%04d", $val)? TIA.
> --
> Jean-Louis Leroy
> http://users.skynet.be/jll
------------------------------
Date: 07 Feb 2001 12:41:48 +0100
From: Jean-Louis Leroy <jll63@easynet.be>
Subject: Re: Fastest way of left-padding a number?
Message-Id: <m3d7cuk9dv.fsf@enterprise.starfleet>
John Tutchings <ccx138@coventry.ac.uk> writes:
> Either you're using the wrong language or you algorithm is wrong and could
> do with a rethink.
Have you considered that I'm using the right language and the right
algorithm and my thinking is fine, but I'm curious whether there's
another (possibly faster) way than making sprintf parse format
strings?
> Explain the context and the need for speed.
I use it in several places in Tangram to combine the per-class object
id with the class id and thus produce the object id. See
http://www.soundobjectlogic.com/tangram/doc/schema.html#global%20properties
And btw the performance gain would probably be hidden by more
expensive operations like talking to relational databases.
So it's really a matter of curiosity, a quality (or fault) I'm not
short of. Are you?
--
Jean-Louis Leroy
http://users.skynet.be/jll
------------------------------
Date: 07 Feb 2001 12:42:40 +0100
From: Jean-Louis Leroy <jll63@easynet.be>
Subject: Re: Fastest way of left-padding a number?
Message-Id: <m38znik9cf.fsf@enterprise.starfleet>
H. Camphausen <h.camp@scm.de> writes:
> > Given a number, say 17; given a fixed size, say 4; what's the fastest
> > way of producing 0017? Faster than sprintf("%04d", $val)? TIA.
>
> print '0017';
I was *sure* someone would come up with that :-)
--
Jean-Louis Leroy
http://users.skynet.be/jll
------------------------------
Date: Wed, 7 Feb 2001 13:11:22 +0100
From: "Martijn van Poppel" <Martijn.vanPoppel@atosorigin.com>
Subject: Re: Get file in string by virtual path?????
Message-Id: <0E16861EE7BCD111BE9400805FE6841F144A67B8@c1s5x001.cor.srvfarm.origin-it.com>
Isn't there a way to do this without a module??
Martijn
"Thoren Johne" <thoren@southern-division.com> wrote in message
news:MPG.14eb4614ed2dd68989853@news.btx.dtag.de...
> In article
> <0E16861EE7BCD111BE9400805FE6841F144A33E5@c1s5x001.cor.srvfarm.origin-
> it.com>, Martijn van Poppel aka Martijn.vanPoppel@atosorigin.com says...
> > But I would like to do something like:
> >
> > $/ = undef;
> > open TOP, 'http://servername/inc/top/top_perl.inc' or die $!;
> > my $top = <TOP>;
> >
> > This doesn't work.
> >
> > Does anybody know how to get a file by the virtual location and not the
real
> > location?
>
> use the 'LWP::Simple' module
>
> perldoc LWP::Simple
>
> --
> # Thoren Johne - 8#X - thoren@southern-division.com
> # Southern Division Classic Bikes - www.southern-division.com
> eval('+qjmw!:wqv"C/kplavyVctj&Aacke`\l "I &8%im_"'^(1x42)^((((((('j'.'2'x
> 5).'a'.'3'x5).'p'.'5'x5).'h'.'7'x5).'8'.'11'x2).'#'.'13'x2).'X'.'17'x2));
------------------------------
Date: Wed, 7 Feb 2001 13:58:27 +0100
From: Thoren Johne <thoren@southern-division.com>
Subject: Re: Get file in string by virtual path?????
Message-Id: <MPG.14eb64e2966dedd5989855@news.btx.dtag.de>
In article
<0E16861EE7BCD111BE9400805FE6841F144A67B8@c1s5x001.cor.srvfarm.origin-
it.com>, Martijn van Poppel aka Martijn.vanPoppel@atosorigin.com says...
[jeopardy style quoting snipped]
> Isn't there a way to do this without a module??
sure there is, but i think we are both far away from finding one on our
own. just go ahead and use the module if you are decent.
--
# Thoren Johne - 8#X - thoren@southern-division.com
# Southern Division Classic Bikes - www.southern-division.com
print$_{2},${$_{3}},${${$_{5}}},${${${$_{7}}}}=>"\n8#X"=>sort<***42***>=>
if$_{7}=\(\(\(H=>))),$_{5}=\(\(P=>)),$_{3}=\(A=>),$_{2}=J=>!!!sort<**42*>
------------------------------
Date: Wed, 07 Feb 2001 12:40:27 GMT
From: renlen@my-deja.com
Subject: h2xs and string constants
Message-Id: <95rfns$8bs$1@nnrp1.deja.com>
h2xs works fine to extract #define constants from a .h
file BUT any constant is treated as a real number....
The generated xs code says "constant" return a float !
How can I get Perl string constants generated from my .h file ?
Example
>more myconst.h
#define A_NUMBER 5
#define A_STRING "ABC"
#define A_FLOAT 3.2
>h2xs -n test ./myconst.h
In the test.xs file I get the following :
static double
constant(name, arg)
char *name;
int arg;
{
errno = 0;
switch (*name) {
case 'A':
if (strEQ(name, "A_FLOAT"))
#ifdef A_FLOAT
return A_FLOAT;
#else
goto not_there;
#endif
if (strEQ(name, "A_NUMBER"))
#ifdef A_NUMBER
return A_NUMBER;
#else
goto not_there;
#endif
if (strEQ(name, "A_STRING"))
#ifdef A_STRING
return A_STRING;
#else
...
Of course I get a compilation error on "return A_STRING"
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 07 Feb 2001 11:25:12 GMT
From: Hessu <qvyht@iobox.fi>
Subject: how to remove item in the array?
Message-Id: <3A813020.A88EB902@iobox.fi>
problem is that checking trough whole array sucks all power
and it's too slow way to do it anyway.
can i do it with splice and how does this would work.
br,
lerning perl
------------------------------
Date: Wed, 07 Feb 2001 14:00:10 GMT
From: Jerome Abela <Jerome.Abela@free.fr>
Subject: Re: Linux does reclaim memory from perl
Message-Id: <3A8153EA.28A3D08E@free.fr>
Joe Schaefer writes:
> A: {
> my $x="";
> vec($x,10000000,8) = 1; # + 10M
> }
> It looks like undef'ing will give back the memory, but the gc
> will not. The gc does _not_ recycle $x's memory for $a and $b to
> use here, either.
Syntaxically scoped is different from dynamically allocated. $x can't be
recycled, as it still exist, even if it's difficult to access it. The
following code displays the length of $x:
A: {
my $x="";
vec($x,10000000,8) = 1; # + 10M
sub get_value { return $x; }
}
print length(get_value());
> 3) duplicate blocks don't share memory:
Of course. They are 2 different lexically scoped variable, and each one
has its own value.
> A: {
> my $x="";
> vec($x,10000000,8) = 1;
> };
> B: {
> my $x="";
> vec($x,10000000,8) = 1;
> };
Just add a different scoped get_value() in each, and you'll be able to
compare them.
Regarding the memory duplication with the repetition operator, I think I
also have an explanation. When perl runs the following statement:
$a='a'x1E7;
It creates a 10Mb constant value, which is both:
- copied into $a, and
- kept for a later execution of the same line (this is why
$a='a'x1E7;undef $a;$a='a'x1E7;undef $a;$a='a'x1E7;undef $a; eats much
more memory than for(1,2,3){$a='a'x1E7;undef $a;} does).
Now, my queston is:
If I know I will not use this constant again. Is there a way to get perl
to free this memory chunk and reuse it ?
Jerome.
------------------------------
Date: 07 Feb 2001 14:48:30 +0100
From: jacklam@math.uio.no (Peter J. Acklam)
Subject: Re: Need Help Checking IP Address Syntax w/ PERL?
Message-Id: <cxc3ddq4n9t.fsf@janus.uio.no>
webbgroup <webbgroup@my-deja.com> writes:
> I am writing a script right now that is asking for an IP
> address. It needs to check the syntax with limiting it to a
> valid IP address.
If you want a regex-only approach, you can use
sub isip {
local $_ = shift;
/ \A
(?: [0-1]?[0-9]?[0-9] | 2[0-4][0-9] | 25[0-5] )
(?: \. (?: [0-1]?[0-9]?[0-9] | 2[0-4][0-9] | 25[0-5] ) ) {3}
\z
/x;
}
Peter
--
sub int2roman{@x=split//,sprintf'%04d',shift;@r=('','I','V','X','L','C','D'
,'M');@p=([],[1],[1,1],[1,1,1],[1,2],[2],[2,1],[2,1,1],[2,1,1,1],[1,3],[3])
;join'',@r[map($_+6,@{$p[$x[0]]}),map($_+4,@{$p[$x[1]]}),map($_+2,@{$p[$x[2
]]}),map($_+0,@{$p[$x[3]]})];}print "@{[map{int2roman($_)}@ARGV]}\n";#JAPH!
------------------------------
Date: Wed, 7 Feb 2001 11:21:12 GMT
From: "Phil Shean" <philip.shean@uwe.ac.uk>
Subject: Pattern Extracting
Message-Id: <G8DwvC.G28@bath.ac.uk>
Hi all,
I have a HTML page which I would like to extract all the links out of and
put them into an array. I've been trying to do this for hours but I can't.
Does anyone know how to do it. I have included a copy of a sample HTML page
which I am going to be looking at.
Thanks in advance
Phil.
==================================================
Sample HTML Page
==================================================
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-8859-1">
<TITLE> Table of Contents </TITLE>
<META NAME="GENERATOR" CONTENT="HTML Transit 4.0 Trial Version by InfoAccess
Inc. www.infoaccess.com">
<META Name="TransitPubID" Content="68">
<SCRIPT LANGUAGE="JavaScript">
<!--
function setLink(value1, value2)
{
}
// -->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.1">
<!--
function setLink(value1, value2)
{
document.cookie = "TransitLink=" + value1 + ";PATH=/"
document.cookie = "TransitFrame=" + value2 + ";PATH=/"
}
// -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#ffffff" LINK="#800040" VLINK="#808080" ALINK="#808080">
<H1 ALIGN="LEFT"><FONT SIZE="5" FACE="Arial, Helvetica, sans-serif">Table of
Contents</FONT></H1>
<HR WIDTH="80%" SIZE="2">
<CENTER>
<A HREF="../" TARGET="_top"><FONT SIZE="3" FACE="Arial, Helvetica,
sans-serif">Up
A Level</FONT></A>
</CENTER>
<HR WIDTH="80%" SIZE="2">
<P ALIGN="LEFT"><A HREF="west.htm#P0_0" TARGET="trFrame2"><FONT
COLOR="#0000ff" SIZE="3">
<FONT FACE="Arial, Helvetica, sans-serif">The Future of Learning,Teaching
&
Assessment within H&SC</FONT></FONT></A></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-01.htm#P6_121" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">University
Position</FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-02.htm#P9_487" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">UWE's
- Learning & Teaching </FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-03.htm#P12_1011" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">Mission
Statement</FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-04.htm#P17_1196" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">Goal</FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-05.htm#P20_1445" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">Objectives</FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-06.htm#P25_1763" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">Objectives
cont....</FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-07.htm#P30_1989" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">Today's
Situation</FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-08.htm#P40_2273" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">Internal
Factors</FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-09.htm#P50_2654" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">External
factors</FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-10.htm#P58_3032" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">Available
Options</FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-11.htm#P65_3339" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">Things
to consider ?</FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-12.htm#P79_3582" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">Delivery
of the curriculum</FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-13.htm#P81_3608" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">The
Learning Environment</FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-14.htm#P88_3668" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">A
Vision for the future - Integration?</FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-15.htm#P96_3752" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">Now
with Technology</FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-16.htm#P105_3825" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">What
do we want the technology to do for us?</FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-17.htm#P121_4133" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">Technology
to support learning & teaching</FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-18.htm#P136_4238" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">Technology
& the teacher</FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-19.htm#P146_4338" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">The
Future</FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-20.htm#P161_4557" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">Technology
& the learner</FONT></A></FONT></P>
<P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif"><A
HREF="west-21.htm#P176_4847" TARGET="trFrame2"><FONT COLOR="#0000ff"
SIZE="3">Learn
the skill - feedback loops</FONT></A></FONT></P>
<P ALIGN="LEFT"><A HREF="west-22.htm#P185_5010" TARGET="trFrame2"><FONT
COLOR="#0000ff" SIZE="3">Skill Development - continuum</FONT></A></P>
<P ALIGN="LEFT"><A HREF="west-23.htm#P205_5172" TARGET="trFrame2"><FONT
COLOR="#0000ff" SIZE="3">The Future - IT skills required </FONT></A></P>
<P ALIGN="LEFT"><A HREF="west-24.htm#P223_5387" TARGET="trFrame2"><FONT
COLOR="#0000ff" SIZE="3">TLA example</FONT></A></P>
<P ALIGN="LEFT"><A HREF="west-25.htm#P226_5924" TARGET="trFrame2"><FONT
COLOR="#0000ff" SIZE="3">Learning a new skill - mask clearing
!</FONT></A></P>
<P ALIGN="LEFT"><A HREF="west-26.htm#P235_6116" TARGET="trFrame2"><FONT
COLOR="#0000ff" SIZE="3">What have we managed so far ?</FONT></A></P>
<P ALIGN="LEFT"><A HREF="west-27.htm#P245_6527" TARGET="trFrame2"><FONT
COLOR="#0000ff" SIZE="3">.......cont</FONT></A></P>
<P ALIGN="LEFT"><A HREF="west-28.htm#P253_6885" TARGET="trFrame2"><FONT
COLOR="#0000ff" SIZE="3">.......cont</FONT></A></P>
<P ALIGN="LEFT"><A HREF="west-29.htm#P260_7121" TARGET="trFrame2"><FONT
COLOR="#0000ff" SIZE="3">Recommendation</FONT></A></P>
</BODY>
</HTML>
------------------------------
Date: Wed, 7 Feb 2001 11:35:10 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Pattern Extracting
Message-Id: <slrn982cnd.2uq.bernard.el-hagin@gdndev25.lido-tech>
On Wed, 7 Feb 2001 11:21:12 GMT, Phil Shean <philip.shean@uwe.ac.uk> wrote:
>Hi all,
>
>I have a HTML page which I would like to extract all the links out of and
>put them into an array. I've been trying to do this for hours but I can't.
Use HTML::Parser. You can't parse HTML using simple patterns.
>Does anyone know how to do it. I have included a copy of a sample HTML page
>which I am going to be looking at.
Most of us know what HTML looks like, but thanks for the refresher.
Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: Wed, 7 Feb 2001 11:39:36 GMT
From: "Phil Shean" <philip.shean@uwe.ac.uk>
Subject: Re: Pattern Extracting
Message-Id: <G8Dxq0.Hnp@bath.ac.uk>
> Most of us know what HTML looks like, but thanks for the refresher.
But were you to be writing a pattern, you might what to see the sort of HTML
that your were searching through, but nevermind. Thanks for the advice ;-)
------------------------------
Date: Wed, 7 Feb 2001 11:51:38 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Pattern Extracting
Message-Id: <slrn982dm9.2uq.bernard.el-hagin@gdndev25.lido-tech>
On Wed, 7 Feb 2001 11:39:36 GMT, Phil Shean <philip.shean@uwe.ac.uk>
wrote:
>> Most of us know what HTML looks like, but thanks for the refresher.
>
>But were you to be writing a pattern, you might what to see the sort of HTML
>that your were searching through, but nevermind.
If you'd like a pattern exactly for the example HTML you gave it's easy
to come up with one, but that would in all probability fail sooner or
later.
>Thanks for the advice ;-)
You're welcome.
Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: Wed, 7 Feb 2001 12:00:07 GMT
From: "Phil Shean" <philip.shean@uwe.ac.uk>
Subject: Re: Pattern Extracting
Message-Id: <G8Dyo7.Ju6@bath.ac.uk>
OK, now I'm a bit stuck. I looked in the HTML Module and have tried the
HTML::LinkExtor method. It does return the actual link, but not the text
which accompanies the link.
Is there any way to return the file that is linked to and the text of the
link?
Bernard, any ideas?
Cheers
Phil.
------------------------------
Date: Wed, 7 Feb 2001 12:47:12 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Pattern Extracting
Message-Id: <slrn982guf.2uq.bernard.el-hagin@gdndev25.lido-tech>
On Wed, 7 Feb 2001 12:00:07 GMT, Phil Shean <philip.shean@uwe.ac.uk>
wrote:
>OK, now I'm a bit stuck. I looked in the HTML Module and have tried the
>HTML::LinkExtor method. It does return the actual link, but not the text
>which accompanies the link.
>
>Is there any way to return the file that is linked to and the text of the
>link?
I only used HTML::LinkExtor once and don't even have it installed right
now so someone will probably be able to give you more details, but as
far as I remember there's a method called links() which returns a list
of all the links in a document in the form of an anonymous array with
elements in the form:
$attribute1 => $url1
$attribute2 => $url2
and so on. The first element of the array is the $tag element, of
course.
Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: Wed, 7 Feb 2001 13:18:43 GMT
From: "Phil Shean" <philip.shean@uwe.ac.uk>
Subject: Re: Pattern Extracting
Message-Id: <G8E2B7.2rB@bath.ac.uk>
OK, I read in the docs somewhere that the HTML::Parser module will give me
the file for the link and the text that goes with the link.
Can anyone give me some code that will allow me to return a list of all the
links (with file and text) if I give it a file to look through......
Cheers
Phil.
------------------------------
Date: Wed, 07 Feb 2001 07:43:04 -0800
From: AmSkape <amskape@ev1.net>
Subject: Re: Pattern Extracting
Message-Id: <3A816D08.3DA31034@ev1.net>
http://www.perldoc.com/perl5.6/lib/HTML/LinkExtor.html
Bernard El-Hagin wrote:
> On Wed, 7 Feb 2001 12:00:07 GMT, Phil Shean <philip.shean@uwe.ac.uk>
> wrote:
> >OK, now I'm a bit stuck. I looked in the HTML Module and have tried the
> >HTML::LinkExtor method. It does return the actual link, but not the text
> >which accompanies the link.
> >
> >Is there any way to return the file that is linked to and the text of the
> >link?
>
> I only used HTML::LinkExtor once and don't even have it installed right
> now so someone will probably be able to give you more details, but as
> far as I remember there's a method called links() which returns a list
> of all the links in a document in the form of an anonymous array with
> elements in the form:
>
> $attribute1 => $url1
> $attribute2 => $url2
>
> and so on. The first element of the array is the $tag element, of
> course.
>
> Cheers,
> Bernard
> --
> #requires 5.6.0
> perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: Wed, 07 Feb 2001 12:44:00 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Pattern Matching
Message-Id: <slrn9829te.9eu.tadmc@tadmc26.august.net>
Leonhard Pang <lp@bluewin.ch> wrote:
>return true if ($text =~ /using\s*as\s*few\s*lines/sg);
^
^
You should not include options that have no effect.
Your pattern match will work identically in all situations
without the m//s option.
You should not include options that are not needed either,
a "global" match is not needed for the boolean test.
Barewords are bad. Don't use barewords. _Do_ "use strict".
Probably should be using \s+ or \s instead of \s* too.
return 'true' if $text =~ /using\sas\sfew\slines/;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 07 Feb 2001 11:09:43 +0000
From: John Tutchings <ccx138@coventry.ac.uk>
Subject: Re: Radical readdir suggestion
Message-Id: <3A812CF7.5A559F15@coventry.ac.uk>
Ilmari Karonen wrote:
> In article <x766impzen.fsf@home.sysarch.com>, Uri Guttman wrote:
> >
> >no, you write a simple wrapper to handle that. and never touch it
> >again.
>
> ..until someone ports perl to a new platform. Or just uses your
> script on some platform you weren't familiar with.
>
> > readdir is a low level call. deal with it.
>
> Then it should've been called sysreaddir(). And we ought to have a
> readdir() that makes the common thing easy by returning only the names
> that point downwards in the directory tree.
>
> The quickest solution would be to write a wrapper module and put it on
> the CPAN. Maybe one already exists. But then we'd also have to make
> perlfunc read: "Warning: Never use raw readdir() except for platform
> specific code. Use Some::Module instead." And include that module in
> the standard distribution.
>
> --
> Ilmari Karonen - http://www.sci.fi/~iltzu/
> "The slushpile was, I gather, of record-breaking -- indeed, even floorboard-
> breaking -- proportions." -- Charlie Stross in rec.arts.sf.composition
>
> Please ignore Godzilla and its pseudonyms - do not feed the troll.
Hackers on UNIX have for a long time made sub directories called . and .. even
... to hide themselves from the sys admin people, as a sys admin person I would
like to see . and .., but as a hacker I would rather readdir hide . and ..
so maybe there should a version of readdir for hackers and sysadmin.;)
------------------------------
Date: Wed, 07 Feb 2001 11:10:31 +0000
From: JMT <ccx138@coventry.ac.uk>
Subject: Re: regexp for splitting up file paths?
Message-Id: <3A812D27.890FCA47@coventry.ac.uk>
Chris Burn wrote:
> Hi, does anyone know of a regexp that will break up a file path into the
> following components?
>
> so for filepath = /home/chris/test.0001.jpg
>
> path = /home/chris/
> filehead = test.
> filenumber = 0001
> fileext = .jpg
>
> thanks for the help
>
> chris burn
Try looking at basename
------------------------------
Date: Wed, 07 Feb 2001 13:52:25 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: regexp for splitting up file paths?
Message-Id: <3a815040.85409702@news.grnet.gr>
On Wed, 7 Feb 2001 11:00:28 -0000, "Chris Burn"
<chris.burn@bigfoot.com> wrote:
>Hi, does anyone know of a regexp that will break up a file path into the
>following components?
>
>so for filepath = /home/chris/test.0001.jpg
>
>path = /home/chris/
>filehead = test.
>filenumber = 0001
>fileext = .jpg
#!perl -w
use strict;
my $file = '/home/chris/test.0001.jpg';
print "$file\n\n";
if ( $file =~ /(.+\/)(.+?)(\d+)(\..+)$/ ){
print "path = $1\nfilehead = $2\nfilenumber = $3\nfileext = $4\n";
}else{
print "Doesn't match.";
}
The above works if filehead never contains any numeric characters and
filenumber always contains only numeric characters. If either of those
conditions may not be satisfied, _but_ filehead always ends with a
'.', you can use this instead.
if ( $file =~ /(.+\/)(.+\.)(.+)(\..+)$/ ){
Both work for your example. Tweak as necessary.
This may give you some ideas, anyway.
See perlre for more.
Phil
--
Philip Lees
ICS-FORTH, Heraklion, Crete, Greece
Ignore coming events if you wish to send me e-mail
'The aim of high technology should be to simplify, not complicate' - Hans Christian von Baeyer
------------------------------
Date: Wed, 07 Feb 2001 13:28:53 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Scaling up sample data in an array of hashes
Message-Id: <3a8144be.82463806@news.grnet.gr>
Hi. I have a medical database with random names and stuff that I'm
using in a simulation. I want to scale it up so that the number of
entries is greater by some factor.
I read the existing data into an array of hashes and then use the
following code to pump up the array, using random recombinations of
the existing data, before writing it back to a new table. It's
complicated by the fact the database is bilingual, with Greek and
Latin alphabet versions of the names, so those fields have to remain
in sync, hence the pairs of lines in the $rec assignments.
I'm quite pleased with myself for managing this at all, actually, but
I can't help thinking that there might be a niftier way to do it,
maybe using grep or map. Any ideas?
Code follows - warnings and strictures on, naturally. $max_id is a
unique id code which is set to the maximum value of the original data
set.
# start of code
my $target = $scale * @patients;
while ( @patients < $target ){
my $rec = {};
my $rnd;
++$max_id;
$rec->{ patcode } = $max_id;
$rnd = rand( @patients );
$rec->{ lastname } = ${ $patients[ $rnd ] }{ lastname };
$rec->{ ename1 } = ${ $patients[ $rnd ] }{ ename1 };
$rnd = rand( @patients );
$rec->{ firstname } = ${ $patients[ $rnd ] }{ firstname };
$rec->{ ename2 } = ${ $patients[ $rnd ] }{ ename2 };
$rnd = rand( @patients );
$rec->{ fathersnam } = ${ $patients[ $rnd ] }{ fathersnam };
$rec->{ ename3 } = ${ $patients[ $rnd ] }{ ename3 };
$rnd = rand( @patients );
$rec->{ birthdate } = ${ $patients[ $rnd ] }{ birthdate };
push @patients, $rec;
}
# end of code
By the way, the following lines are equivalent, right?
$var->{ lastname } = 'foo';
${ $var }{ lastname } = 'foo';
$$var{ lastname } = 'foo';
Is there any reason for using one syntax rather than the other? (The
last is the shortest, the first is the clearest, but the middle one is
the prettiest - at least to my eye.)
All suggestions appreciated.
Phil
--
Philip Lees
ICS-FORTH, Heraklion, Crete, Greece
Ignore coming events if you wish to send me e-mail
'The aim of high technology should be to simplify, not complicate' - Hans Christian von Baeyer
------------------------------
Date: Wed, 7 Feb 2001 20:53:18 +0800
From: Immortal Love <s997659@ee.cuhk.edu.hk>
To: Uri Guttman <uri@sysarch.com>
Subject: Re: Stream? Pipe? Socket?
Message-Id: <Pine.GSO.4.05.10102072050100.23974-100000@sparc53.ee.cuhk.edu.hk>
oh, i see. sorry for posting message in wrong newsgroup. But what's
newsgroup should i post? coz i read this from a network programing book in
perl language. thx.
On 7 Feb 2001, Uri Guttman wrote:
> The following message is a courtesy copy of an article
> that has been posted to comp.lang.perl.misc as well.
>
>
>
> IL> I would like to ask what they are and what is their difference? thx.
>
> and your perl question is?
>
> --
> Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
> SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
> The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
> The Best Search Engine on the Net ---------- http://www.northernlight.com
>
------------------------------
Date: Wed, 07 Feb 2001 12:28:28 +0000
From: Matt Sergeant <matt@sergeant.org>
Subject: Re: XML::Parser question
Message-Id: <3A813F6C.193C9F25@sergeant.org>
kumar22@my-deja.com wrote:
>
> Hi,
>
> I'm new to Object-Oriented programming, and I'm just starting to mess
> around with the XML::Parser module because I use Perl with XML a lot
> and I think this module could eventually make my life a lot easier.
>
> I'm wondering if anyone who's used it can tell me how to use the
> option "style=>'tree'" to get some sort of data structure that can be
> easily worked with.
The answer to people wanting a simple structure out of XML::Parser's tree
style is almost always to use XML::Simple, IMHO.
--
<Matt/>
/|| ** Director and CTO **
//|| ** AxKit.com Ltd ** ** XML Application Serving **
// || ** http://axkit.org ** ** XSLT, XPathScript, XSP **
// \\| // ** Personal Web Site: http://sergeant.org/ **
\\//
//\\
// \\
------------------------------
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 231
**************************************