[22299] in Perl-Users-Digest
Perl-Users Digest, Issue: 4520 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 6 09:08:39 2003
Date: Thu, 6 Feb 2003 06:06:50 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 6 Feb 2003 Volume: 10 Number: 4520
Today's topics:
Re: Build my own perl html help docs <bart.lateur@pandora.be>
Re: Build my own perl html help docs (Helgi Briem)
Re: Calling subroutines from scalars (Jay Tilton)
Re: Calling subroutines from scalars <tassilo.parseval@post.rwth-aachen.de>
Re: How do i use pidof (Anno Siegel)
Re: just installed ActivePerl5.8, then? (Ben Morrow)
Re: just installed ActivePerl5.8, then? <tassilo.parseval@post.rwth-aachen.de>
Re: just installed ActivePerl5.8, then? <bart.lateur@pandora.be>
Re: just installed ActivePerl5.8, then? (Anno Siegel)
Optimizing subroutine (Dimitri)
Re: Optimizing subroutine <sfandino@yahoo.com>
Re: Optimizing subroutine (Anno Siegel)
Re: Optimizing subroutine <nobull@mail.com>
Re: Perl Search Engine Script (Anno Siegel)
Re: Perl Search Engine Script (Sam Holden)
Re: Please help a beginner in PEARL and CGI! <me@privacy.net>
pushing elements into multidimensional array <nospam_stigerikson@yahoo.se>
Re: pushing elements into multidimensional array <spikey-wan@bigfoot.com>
Re: pushing elements into multidimensional array <bongie@gmx.net>
Re: pushing elements into multidimensional array (Anno Siegel)
Re: pushing elements into multidimensional array <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: pushing elements into multidimensional array <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: pushing elements into multidimensional array <novastar@dtdns.net.nospam>
Re: pushing elements into multidimensional array (Jay Tilton)
Re: pushing elements into multidimensional array <mpapec@yahoo.com>
Regex Multiple occurances of a pattern in multiple line (Anton)
Re: Seeking HTML crunching tool (Allan Cady)
Re: sort, my concoction of <abigail@abigail.nl>
Re: string in datei (Ben Morrow)
Re: string in datei (Helgi Briem)
Re: string in datei (Anno Siegel)
Re: Wrap a line at x characters <bhjp@spookyworld.dnsalias.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 06 Feb 2003 10:40:59 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Build my own perl html help docs
Message-Id: <cne44vk9mqatntol1skng5cevkrjdan4ab@4ax.com>
Shing-Fat Fred Ma wrote:
>So I'm wondering of
>the ActivePerl installation puts files into its own
>self contained directory tree.
Yes.
The effect of installing ActivePerl on your PC is minimal: just one
directory tree under c:\perl, and as Helgi wrote: association of .pl
with perl.exe, and adding c:\perl\bin to PATH. No OLE class
registration... nothing your can't undo, or redo, manually.
--
Bart.
------------------------------
Date: Thu, 06 Feb 2003 12:56:13 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Build my own perl html help docs
Message-Id: <3e425ab7.679347149@news.cis.dfn.de>
On 5 Feb 2003 16:44:46 GMT, Shing-Fat Fred Ma
<fma@doe.carleton.ca> wrote:
> So I'm wondering of
>the ActivePerl installation puts files into its own
>self contained directory tree.
Yes. C:/perl or /usr/local/ActivePerl-XXX/
by default, but you can choose any directory.
>A few more question, if you don't mind....is the
>installation pretty robust and straightforward
>for solaris 8 (sun box)?
Yes. Very easy.
> I would be building
Activeperl is prebuilt for the OS. No building
is necessary or possible.
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: Thu, 06 Feb 2003 08:07:46 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Calling subroutines from scalars
Message-Id: <3e421475.5552834@news.erols.com>
Benjamin Goldberg <goldbb2@earthlink.net> wrote:
: Jay Tilton wrote:
: [snip]
: > my @call = \( undef, &dnc1, &dnc2, &dnc3 );
:
: While it's clear what you intend here, I don't think that that
: works...
It does.
: (though I haven't tested to find out if it does or doesn't).
I did. :)
: I would suggest that you write it out the normal way:
:
: my @call = ( undef, \&dnc1, \&dnc2, \&dnc3 );
Agreed. Clarity is a Good Thing. The "reference to a list" shortcut
will probably only confuse a neophyte.
------------------------------
Date: 6 Feb 2003 08:21:59 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Calling subroutines from scalars
Message-Id: <b1t5v7$agm$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Benjamin Goldberg:
> Jay Tilton wrote:
> [snip]
>> my @call = \( undef, &dnc1, &dnc2, &dnc3 );
>
> While it's clear what you intend here, I don't think that that
> works...(though I haven't tested to find out if it does or doesn't).
Odd, the same thoughts crossed my mind. I would have expected that perl
would set a reference to the _return_values_ of each of these functions.
My fingers itched to point that out to Jay but then I decided to test it
before and had to withdraw defeated. ;-)
But it shows one thing: Namely that you should not use ampersands in
ordinary function-calls. Beginners (who seem to like ampersanded
function-calls) would probably confront themselves with an unsolvable
problem if they did the above and expecting the other behaviour.
> I would suggest that you write it out the normal way:
>
> my @call = ( undef, \&dnc1, \&dnc2, \&dnc3 );
Considering the confusion that Jay's idiom caused this is a good advice.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 6 Feb 2003 14:02:50 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How do i use pidof
Message-Id: <b1tpua$mst$3@mamenchi.zrz.TU-Berlin.DE>
Jan Engelhardt <hirogen2@gmx.de> wrote in comp.lang.perl.misc:
> >I am trying to test for the presence of a PID for a program.
> >If it is nit running, then start it
> >How would I do this ?
> >
> >#!/usr/bin/perl
> >@andy = `pidof xastir`;
> >if (xxxxxxxxxx)
>
> Under Linux and similar (not Win32 ugh) you can do the following:
>
> $existant = `ps -h $pid` ne "";
>
> (-h strips the " PID TTY STAT TIME
> COMMAND" header, which is normally returned in any case.)
That supposes that you already have a pid. If so,
$existent = signal( 0, $pid);
is more portable (the ps command isn't).
However, the OP wants to know if a particular program is running
under any pid, using the external program "pidof". Another posting
has already gone into that.
Anno
------------------------------
Date: Thu, 6 Feb 2003 09:48:42 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: just installed ActivePerl5.8, then?
Message-Id: <b1tb1q$6o5$1@wisteria.csv.warwick.ac.uk>
mgjv@tradingpost.com.au wrote:
>On Wed, 5 Feb 2003 21:58:54 +0000 (UTC),
> Ben Morrow <mauzo@mimosa.csv.warwick.ac.uk> wrote:
>> samj@eisa.net.au (samphdauto) wrote:
>
>[snip lots of confusion]
>
>> I would apologise for the facetiousness[1] but you don't seem to have tried
>> very hard to find out. If finding such things out is really beyond you then
>> may I suggest that Perl may well be as well?
>
>> [1] sp? That's what /usr/share/dict/words says, but I thought it had an ae in.
>> Is this a UK/US thing, or am I just wrong?
>
>It is not a US/UK thing. facetious is the correct spelling on both
>sides of that pond, as well as here.
>
>Did you think it was faecetious? If that was a word, it'd probably be
>derived from faeces, and it would probably mean something slightly,
>but not alltogether, different.
No, I thought it was facaetious. I don't have a Shorter Oxford to hand to
check the actual derivation...
Ben
------------------------------
Date: 6 Feb 2003 10:13:49 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: just installed ActivePerl5.8, then?
Message-Id: <b1tcgt$ikd$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Ben Morrow:
> mgjv@tradingpost.com.au wrote:
>>On Wed, 5 Feb 2003 21:58:54 +0000 (UTC),
>>It is not a US/UK thing. facetious is the correct spelling on both
>>sides of that pond, as well as here.
>>
>>Did you think it was faecetious? If that was a word, it'd probably be
>>derived from faeces, and it would probably mean something slightly,
>>but not alltogether, different.
>
> No, I thought it was facaetious. I don't have a Shorter Oxford to hand to
> check the actual derivation...
Checking the online Merriam-Webster (which is American English
admittedly, http://www.m-w.com/), it doesn't list "facaetious". I think
it would if it existed in this spelling as well (be it even British
spelling). As for the derivation: It appears to stem from the Latin word
"facetia".
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Thu, 06 Feb 2003 11:17:20 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: just installed ActivePerl5.8, then?
Message-Id: <g0h44vkvrglf9es63knndsrme7qdvi40qp@4ax.com>
Ben Morrow wrote:
>I don't have a Shorter Oxford to hand to
>check the actual derivation...
<http://www.webster.com/> will do...
--
Bart.
------------------------------
Date: 6 Feb 2003 12:01:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: just installed ActivePerl5.8, then?
Message-Id: <b1tiqn$ihv$1@mamenchi.zrz.TU-Berlin.DE>
Ben Morrow <mauzo@mimosa.csv.warwick.ac.uk> wrote in comp.lang.perl.misc:
[facetious]
> [1] sp? That's what /usr/share/dict/words says, but I thought it had an ae in.
> Is this a UK/US thing, or am I just wrong?
Etymology wouldn't justify an "ae". It's from latin "facetia" via
Middle French "facetie". Of course, that doesn't prove anything...
Anno
------------------------------
Date: 6 Feb 2003 04:51:23 -0800
From: mauroid@csi.forth.gr (Dimitri)
Subject: Optimizing subroutine
Message-Id: <a3ebf7b8.0302060451.7511ba5e@posting.google.com>
Hello,
About 40% of the time in my program is taken in the following
subroutine. I am looking for ways to make it more efficient.
Feel free to suggest anything that works faster.
sub clean_ctrl {
my ($data) = @_;
my ($i);
my $len = length($data);
my $out = "";
for ($i = 0; $i < $len; $i += 2) {
if (ord(substr($data, $i, 1)) < 128) {
$out .= substr($data, $i, 2);
} else {
$out .= sprintf("%02x", ord(substr($data, $i + 1, 1)));
}
}
$out;
}
Thanks a lot for any help!
-Dimitri
------------------------------
Date: Thu, 06 Feb 2003 14:19:38 +0000
From: =?ISO-8859-1?Q?Salvador_Fandi=F1o_Garc=EDa?= <sfandino@yahoo.com>
Subject: Re: Optimizing subroutine
Message-Id: <3E426EFA.4000307@yahoo.com>
Hi,
try something like this:
$out=$data;
$out=~s{(.)(.)}{$1 lt "\x80" ? $1.$2 : sprintf("%02x", ord($2)) }ge
Bye,
- Salva
Dimitri wrote:
> Hello,
>
> About 40% of the time in my program is taken in the following
> subroutine. I am looking for ways to make it more efficient.
> Feel free to suggest anything that works faster.
>
> sub clean_ctrl {
> my ($data) = @_;
> my ($i);
> my $len = length($data);
> my $out = "";
>
> for ($i = 0; $i < $len; $i += 2) {
> if (ord(substr($data, $i, 1)) < 128) {
> $out .= substr($data, $i, 2);
> } else {
> $out .= sprintf("%02x", ord(substr($data, $i + 1, 1)));
> }
> }
>
> $out;
> }
>
> Thanks a lot for any help!
> -Dimitri
------------------------------
Date: 6 Feb 2003 13:28:41 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Optimizing subroutine
Message-Id: <b1tnu9$mst$1@mamenchi.zrz.TU-Berlin.DE>
Dimitri <mauroid@csi.forth.gr> wrote in comp.lang.perl.misc:
> Hello,
>
> About 40% of the time in my program is taken in the following
> subroutine. I am looking for ways to make it more efficient.
> Feel free to suggest anything that works faster.
>
> sub clean_ctrl {
> my ($data) = @_;
> my ($i);
> my $len = length($data);
> my $out = "";
>
> for ($i = 0; $i < $len; $i += 2) {
> if (ord(substr($data, $i, 1)) < 128) {
> $out .= substr($data, $i, 2);
> } else {
> $out .= sprintf("%02x", ord(substr($data, $i + 1, 1)));
> }
> }
>
> $out;
> }
This is at least shorter, I'd expect it to be faster too:
sub clean_ctrl {
join '', map ord() < 128 ? $_ : sprintf( '%02x', ord substr( $_, 1)),
shift() =~ /../g;
}
Anno
------------------------------
Date: 06 Feb 2003 13:03:19 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Optimizing subroutine
Message-Id: <u965rxwnlb.fsf@wcl-l.bham.ac.uk>
mauroid@csi.forth.gr (Dimitri) writes:
> About 40% of the time in my program is taken in the following
> subroutine. I am looking for ways to make it more efficient.
> Feel free to suggest anything that works faster.
>
> sub clean_ctrl {
> my ($data) = @_;
> my ($i);
> my $len = length($data);
> my $out = "";
>
> for ($i = 0; $i < $len; $i += 2) {
> if (ord(substr($data, $i, 1)) < 128) {
> $out .= substr($data, $i, 2);
> } else {
> $out .= sprintf("%02x", ord(substr($data, $i + 1, 1)));
> }
> }
>
> $out;
> }
I've not benchmarked it but I'd guess...
sub clean_ctrl {
(my $out = shift) =~ s/\G((?:..)*?)[\x80-\xFF](.)/$1 . sprintf '%02x', ord $2/eg;
$out;
}
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 6 Feb 2003 10:14:08 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl Search Engine Script
Message-Id: <b1tchg$cd6$2@mamenchi.zrz.TU-Berlin.DE>
Tyler Cruz <tylercruz@hotmail.com> wrote in comp.lang.perl.misc:
> Hi,
>
> Here is my problem. This is a portion from a search engine for reviews. The
> problem is that our title of reviews are in the format: "The Matrix" for
> example, so when somebody searches for Matrix, they can see Matrix easily.
> However if they search for The Matrix, there is no title called The Matrix.
Huh? You probably wanted to say the titles are in the format "Matrix, The",
or similar.
> To try this out, you can go to http://www.movie-vault.com and see for
> yourself.
>
> So what I want to do is put an if statement, questioning if the title begins
> with "the " and if it does, then just search for everything after it. I know
s/^The\s+//;
Anno
------------------------------
Date: 6 Feb 2003 11:22:42 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl Search Engine Script
Message-Id: <slrnb44hc2.ecr.sholden@flexal.cs.usyd.edu.au>
On Thu, 06 Feb 2003 07:56:34 GMT, Tyler Cruz <tylercruz@hotmail.com> wrote:
>
> So what I want to do is put an if statement, questioning if the title begins
> with "the " and if it does, then just search for everything after it. I know
> this is extremely basic, but I haven't done ANY Perl stuff in years - and
> could really use the help. Here is the code snipit:
s/^the//i
Though in practice you probably want to use soething more robust.
Why are you writing/editing a perl script to run on a publically
accessable web site if you haven't done 'ANY' perl in years???
Maybe you should spend some time refreshing your knowledge (after all
perl has changed a bit :). Or find someone who has the knowledge already.
> { my $grep = $cgi->param("grep");
> my $searchstring = $cgi->param("searchstring");
> my $sth;
> if ($grep eq "Title") {
> $sth = $dbh->prepare("select title, director, writer, year, movieid from
> reviews where title like \"%$searchstring%\" order by 1") || die "Oops";
You really better hope no one enters something like:
blah"; delete from reviews; select * from reviews where title like "
Or something similar (I obviously didn't test :) in that text box...
If the db user doesn't have write permission then even something like:
select * from reviews, reviews, reviews, reviews, reviews
in place of the delete might bring the database to its knees.
Depending on the database your using of course. Note I might have the
syntax all wrong, but the point is valid.
Use placeholders (see the DBI docs), or if your database doesn't
support them, I don't know if any don't though, then at least use
$dbh->quote().
Never trust user data you got from a web browser across the internet...
--
Sam Holden
------------------------------
Date: Thu, 6 Feb 2003 23:30:27 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: Please help a beginner in PEARL and CGI!
Message-Id: <b1tkh4$16ufrn$1@ID-172104.news.dfncis.de>
"TJ" <trond@bwsnett.no> wrote in message
news:b1s63s$169nuc$1@ID-175630.news.dfncis.de...
[snip of repeated question in alt.perl and possibly other groups]
Please read http://www.cs.tut.fi/~jkorpela/usenet/xpost.html
------------------------------
Date: Thu, 06 Feb 2003 11:00:07 +0100
From: stig <nospam_stigerikson@yahoo.se>
Subject: pushing elements into multidimensional array
Message-Id: <b1tbp4$ffi$1@oden.abc.se>
hi
is it possible to push an element onto an multidomensional array?
i try:
$Array[0][0] = "hello";
push $Array[0], "test";
by this (or any other method) i would like to accomplish:
$Array[0][1] = "test";
however perl reports that i must send an array not a slice of an array.
i also tried the method described in perldoc push
for $value (LIST) {
$ARRAY[++$#ARRAY] = $value;
}
in my case i made it look like this:
$Array[0][++$#Array[0]] = "test";
that did not work since it did not manage to read out the length of the
current slice, onle reported ARRAY(0x8066030).
using the scalar function on @Array[0] did not help.
perhaps i missed something out (i am more novice then expert, so to say)
thanks
stig
------------------------------
Date: Thu, 6 Feb 2003 10:48:38 -0000
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Re: pushing elements into multidimensional array
Message-Id: <b1tejs$f6n$1@newshost.mot.com>
> is it possible to push an element onto an multidomensional array?
> i try:
>
> $Array[0][0] = "hello";
Not 100% as I'm a newbie too, but try
$Array{0}{0} = "hello";
R.
------------------------------
Date: Thu, 06 Feb 2003 12:10:43 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: pushing elements into multidimensional array
Message-Id: <1214579.mBp1nt0HUF@nyoga.dubu.de>
stig wrote:
> is it possible to push an element onto an multidomensional array?
> i try:
>
> $Array[0][0] = "hello";
>
> push $Array[0], "test";
push @{$Array[0]}, "test";
$Array[0] is not an array, it's an array reference.
See "perldoc perlref", "perldoc perldsc", and "perldoc perllol" for
details.
Ciao,
Harald
--
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Airplanes are interesting toys but of no military value.
-- Marechal Ferdinand Foch, Professor of Strategy,
Ecole Superieure de Guerre.
------------------------------
Date: 6 Feb 2003 11:13:09 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: pushing elements into multidimensional array
Message-Id: <b1tg05$fah$1@mamenchi.zrz.TU-Berlin.DE>
Richard S Beckett <spikey-wan@bigfoot.com> wrote in comp.lang.perl.misc:
> > is it possible to push an element onto an multidomensional array?
> > i try:
> >
> > $Array[0][0] = "hello";
>
> Not 100% as I'm a newbie too, but try
>
> $Array{0}{0} = "hello";
Newbie or not, you should read the original poster's question. The
code you "corrected" works fine and is only meant to set up the
arrayref in $Array[ 0] (which is unnecessary, but never mind that).
Your "correction" is nonsense.
To the OP:
push @{ $array[ 0]}, 'hello';
Anno
------------------------------
Date: Thu, 6 Feb 2003 11:14:43 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: pushing elements into multidimensional array
Message-Id: <Xns931A7BE2ED9DCelhber1lidotechnet@62.89.127.66>
stig wrote:
> hi
>
> is it possible to push an element onto an multidomensional array?
> i try:
>
> $Array[0][0] = "hello";
>
> push $Array[0], "test";
Since you want $Array[0] to be an array reference tell Perl so:
push @{$Array[0]}, 'test';
I think you should have a look at perldoc perlreftut.
--
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Thu, 6 Feb 2003 11:15:09 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: pushing elements into multidimensional array
Message-Id: <Xns931A7BF5C780elhber1lidotechnet@62.89.127.66>
Richard S Beckett wrote:
>> is it possible to push an element onto an multidomensional array?
>> i try:
>>
>> $Array[0][0] = "hello";
>
> Not 100% as I'm a newbie too, but try
>
> $Array{0}{0} = "hello";
No, don't try that.
--
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Thu, 6 Feb 2003 13:28:58 +0200
From: "George Bouras" <novastar@dtdns.net.nospam>
Subject: Re: pushing elements into multidimensional array
Message-Id: <1044530933.665470@athprx02>
$Array[0][0] = 'hello' ;
push @{$Array[0]} , ' world';
push @{$Array[0]} , ' from Athens';
print $Array[0][1],"\n";
print @{$Array[0]},"\n";
------------------------------
Date: Thu, 06 Feb 2003 11:48:01 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: pushing elements into multidimensional array
Message-Id: <3e4244ab.17896659@news.erols.com>
stig <nospam_stigerikson@yahoo.se> wrote:
: is it possible to push an element onto an multidomensional array?
Yes.
: i try:
:
: $Array[0][0] = "hello";
:
: push $Array[0], "test";
:
: by this (or any other method) i would like to accomplish:
: $Array[0][1] = "test";
$Array[0] is not an array, but an array reference. Mastering the
distinction is crucial.
If you ever find yourself thinking "there's an array somewhere behind
that thing," you've gotten one step ahead of yourself. Isolate the
reference before thinking about dereferencing it.
You can isolate it by assigning its value to an intermediate scalar
variable, then applying rule 1 of "Using References" from perlref.
my $foo = $Array[0];
push @$foo, 'test';
Or you can skip the intermediate variable and apply rule 2.
push @{ $Array[0] }, "test";
: however perl reports that i must send an array not a slice of an array.
Never try to paraphrase error messages. Always copy/paste them
verbatim into your articles.
: i also tried the method described in perldoc push
Reading the docs is good. Unfortunately, there's the problem of
volume. You're studying sections of the docs that won't help. You
will find perlref and perlreftut infinitely more enlightening than
anything perlfunc has to say about push().
------------------------------
Date: Thu, 06 Feb 2003 14:47:24 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: pushing elements into multidimensional array
Message-Id: <vjp44v8pddidh3a324b0jgh7j1gn0tehbe@4ax.com>
X-Ftn-To: stig
stig <nospam_stigerikson@yahoo.se> wrote:
>$Array[0][0] = "hello";
>
>push $Array[0], "test";
>
>by this (or any other method) i would like to accomplish:
>$Array[0][1] = "test";
You have to dereference array:
push @{$Array[0]}, "test";
(check perldoc perlref)
To loop over @{$Array[0]} via index you could
for $i(0..@{$Array[0]}-1) {
print $Array[0][$i];
}
--
Matija
------------------------------
Date: 6 Feb 2003 05:58:25 -0800
From: shianto@hotmail.com (Anton)
Subject: Regex Multiple occurances of a pattern in multiple lines
Message-Id: <afd3c7f3.0302060558.62a1082e@posting.google.com>
I am capuring a error message and I want to extract some info from it.
Unfortunately I cannot seem to get the correct syntax of regex s/ to
extract only the information I require. The message is something like
XXXXXXXX info '<pattern I want to keep>'
XXXXXX info '<pattern I want to keep>'
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
my attempt at the code looks like
$err_msg =~ s/.+?info\'(\w+)\'.+?/$1 /sg
Unfortunately this leaves me with unwanted data after the last
<pattern I want to keep>
Thanks
Anton
Note: As per the example the error message has multiple new lines
embedded in it, but I can't think how to use them, if at all
------------------------------
Date: 6 Feb 2003 00:26:43 -0800
From: allancady@yahoo.com (Allan Cady)
Subject: Re: Seeking HTML crunching tool
Message-Id: <d563b154.0302060026.4f8f59c6@posting.google.com>
Cool, thanks. Onward I go into the Perl jungle...
"J rgen Exner" <jurgenex@hotmail.com> wrote in message news:<KUk0a.1114$5g7.254@nwrddc02.gnilink.net>...
> Allan Cady wrote:
> > I'm looking for a tool of some sort that can be used to perform
> > scripted modifications to HTML files. For example, to remove the
> > first <table>...</table> from each of a set of files, or to remove all
> > table cells with WIDTH=1.
> >
> > Can anyone recommend such a tool? (Or a better group to post this
> > to?)
>
> This Question is Asked Frequently, please consult 'perldoc -q HTML':
> "How do I remove HTML from a string?"
>
> Although the title doesn't seem to match your problem exactly in reality you
> do have the same problem and the answer applies to your question, too.
>
> jue
------------------------------
Date: 06 Feb 2003 08:09:51 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: sort, my concoction of
Message-Id: <slrnb4462f.9nr.abigail@alexandra.abigail.nl>
Martien Verbruggen (mgjv@tradingpost.com.au) wrote on MMMCDXLVI September
MCMXCIII in <URL:news:slrnb43hfa.se5.mgjv@verbruggen.comdyn.com.au>:
&&
&& I am a bit confused about what that achieves or avoids. To me, [a-z]
&& means all characters between a and z, inclusive, and [[:lower:]] means
&& all lowercase characters. In certain locales those two do not map
&& neatly onto each other (and on certain platforms there might even be
&& more problems, but see later). Do you mean to say that Regex::Common
&& uses a-z instead of [[:lower:]] because that's what most people "expect"?
No, it's because many standard are explicite. There are no accented
letters in hostnames. Or in URLs. Nor in zip codes of many countries.
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'
------------------------------
Date: Thu, 6 Feb 2003 09:37:28 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: string in datei
Message-Id: <b1taco$6f2$1@wisteria.csv.warwick.ac.uk>
tadmc@augustmail.com wrote:
>Jürgen Exner <jurgenex@hotmail.com> wrote:
>> Ben Morrow wrote:
>>> abigail@abigail.nl wrote:
>>>> Huh? This isn't en.comp.lang.perl.misc.
>>>
>>> No, this is comp.lang.perl.misc, which is by implication
>>> us.comp.lang.perl.misc.
>>
>> No, by no means! What gave you that idea?
>> This is a world-wide group. If you want a US-only group please feel free to
>> create one.
>>
>> It's statements like these which make Americans appear to be arrogant,
>
>Yep. I'm embarrassed by your attitude in this thread Ben.
OK, I'm sorry. Clearly I was out of line.
Just to make it clear: I am not American. I am English.
Again: I didn't mean either to offend or to appear to exclude anyone. I
apologise if I gave that impression.
Ben
------------------------------
Date: Thu, 06 Feb 2003 13:03:42 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: string in datei
Message-Id: <3e425c8f.679819348@news.cis.dfn.de>
On 05 Feb 2003 20:08:36 GMT, Abigail <abigail@abigail.nl>
wrote:
>$$ ... only english here.
>Huh? This isn't en.comp.lang.perl.misc. It would be unfair to ban
>people to a regional group just because they don't master English.
>I speak a different language than English. Should I monitor other
>Perl groups as well (and hence have less time to answer questions
>here), or are you implying that people who don't master English
>have no right to hear my opinion about their questions?
No, but if someone posts to an international forum
in a language other than English, he will have to be
philosophical about the fact that he is less likely to
receive a useful answer.
I could post questions here in Icelandic all day
long, but I am not optimistic about my chances
of its effectiveness.
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: 6 Feb 2003 13:50:46 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: string in datei
Message-Id: <b1tp7m$mst$2@mamenchi.zrz.TU-Berlin.DE>
Helgi Briem <helgi@decode.is> wrote in comp.lang.perl.misc:
> I could post questions here in Icelandic all day
That would make clpm a still thornier place...
Anno
------------------------------
Date: Thu, 06 Feb 2003 13:30:43 -0000
From: Sean <bhjp@spookyworld.dnsalias.com>
Subject: Re: Wrap a line at x characters
Message-Id: <v44os3qr8i554c@corp.supernews.com>
Walter Roberson <roberson@ibd.nrc-cnrc.gc.ca> wrote:
> s/(.{128})/\1\n/g
> I would have to ask whether you really want to split every 128
> characters? Or do you want to split at "a nice place" (e.g., whitespace)
> with the resulting strings being -at most- 128 characters?
> And if so, what do you want done if there doesn't happen to be a
> word break within 128 characters?
Ahh...I didn't think of that. Yes, it would be better to break at a word than
at a specific character. I'm looking to get the same functionality that is
offered by email programs that wrap text at 74 characters.
Thanks for all of the suggestions -- I will look into the modules mentioned.
Sean
--
\___/ Sean Keplinger
|o,o| skeplin at one dot net
\/ ) http://spookyworld.dnsalias.com
----mm-----------------------------------
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 4520
***************************************