[22763] in Perl-Users-Digest
Perl-Users Digest, Issue: 4984 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 14 14:06:32 2003
Date: Wed, 14 May 2003 11:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 14 May 2003 Volume: 10 Number: 4984
Today's topics:
<html> and reg. expressions <berndt.sommer@gmx.de>
Re: @Array - making it null <bart.lateur@pandora.be>
Re: Can't locate sub.pl <nobull@mail.com>
Re: Conversion systems <kubusieczek@poczta.onet.pl>
dblib dbsqlexec return value user@domain.invalid
delete an element from an array? <bing-du@tamu.edu>
Re: delete an element from an array? (Helgi Briem)
Re: delete an element from an array? <nobull@mail.com>
Re: delete an element from an array? <nobull@mail.com>
gotta be a better way (rab)
Re: In search of elegant code - running code within a l <dodger@dodger.org>
Re: is there a built in mathematical type "dot product" <abigail@abigail.nl>
Re: measuring web resource loading time (Lawrence Tierney)
module to generate locations based on address ? (dan baker)
Re: mysql DBI ? relaced by NULL (William R. Mattil)
Re: MYSQL images <nobull@mail.com>
Newbie question <pvdh@xs4all.nl>
Re: Newbie question <joe@blowme.com>
Re: Newbie question <emschwar@pobox.com>
Re: Newbie question <TruthXayer@yahoo.com>
Re: Newbie question <kosh@babylon5.space>
Re: No data entering @array from open(DATA...) <wksmith@optonline.net>
tools to make perl scripts an EXE executables?? (Kenjis Kaan)
Re: tools to make perl scripts an EXE executables?? <mike_solomon@lineone.net>
Re: Which module to use for ordered hashes? <nobull@mail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 14 May 2003 17:42:03 +0200
From: "berndt.sommer" <berndt.sommer@gmx.de>
Subject: <html> and reg. expressions
Message-Id: <b9tntr$lev$05$1@news.t-online.com>
Hi there,
1. with s/<[^>]+>// I can replace all html tags to nothing. I tried to do
this with
/<[.]+>/ but this does not work. I do not have any idea why.
2. Does this exist? A "form" where I can test reg expressions on real text:
like /</ would display a text like this .... this is a <b><</b>html
text... So the < would be displayed as "bold"
Thanks for any ideas
Regards
Berndt
------------------------------
Date: Wed, 14 May 2003 17:01:20 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: @Array - making it null
Message-Id: <7it4cvclbo3mnnpa04i2ucd3ald6nkpl4g@4ax.com>
Balaji Venkataraman wrote:
>So now that the experts say that undef is not a good thing to do, I
>have a question.
Experts say using undef() is not a good thing on arrays and hashes. No
problem for scalars.
--
Bart.
------------------------------
Date: 14 May 2003 17:46:22 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Can't locate sub.pl
Message-Id: <u97k8tjx29.fsf@wcl-l.bham.ac.uk>
Pierre Couderc <pierre@couderc.cc> writes:
> I have a sporadic error in my mod_perl script:
Do not mix Perl5-style modules and Perl4-style libraries.
More precisely, don't load a Perl4-style library within a Perl5-style
module.
More precisely still, don't load the same Perl4-style library within
two or more different Perl5-style modules.
More precisely still, don't load one or more Perl4-style libraries
using the same filename within two or more different Perl5-style
modules.
Note: CGI sripts running under mod_perl count as modules for these purposes.
To understand why this is bad think about what mod_perl does and what
require() does.
> I have 2 files in /var/www/perl/ directory :
>
> sub.pl
> ------
>
> subroutine mysub{
> ...
> }
>
> main.pl
> -------
>
> require './sub.pl';
> ...
> mysub();
Do not do this!
Did you pick this up awful code from that horribly broken porting guide?
Please ask the author to remove it. If enough people do this perhaps
it will work.
See:
http://groups.google.com/groups?selm=4dafc536.0211211047.5da49e9a%40posting.google.com
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 14 May 2003 19:15:46 +0200
From: "Kuba" <kubusieczek@poczta.onet.pl>
Subject: Re: Conversion systems
Message-Id: <b9ttjn$9m2$1@news.onet.pl>
"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
<news:b9t4vn$2p6$2@mamenchi.zrz.TU-Berlin.DE...> sth like that:
> That is easily done with printf. Perl's printf has conversions for
> all the common formats you mention. See "perldoc -f sprintf" (sic)
> for the details.
>
> Anno
Thank You very much for Your help,
I go for reading manual
Best Regards
Kuba /James/
------------------------------
Date: Wed, 14 May 2003 17:52:39 +0100
From: user@domain.invalid
Subject: dblib dbsqlexec return value
Message-Id: <3EC27457.6080806@domain.invalid>
Im new to this so sorry if it doesnt make sence,
I have the following code that calls Sybase using DBLib
$dbh->dbcmd($sql);
$rc1 = $dbh->dbsqlexec();
if ( $rc1 == FAIL)
{
//do something
}
does $rc1 indicate that the function call worked or didnt work
or (if applicable) the value returned from a stored procedure?
is FAIL a DBLib variable or a Perl Variable?
is there something similar in DBI?
Thanks
joe
------------------------------
Date: Wed, 14 May 2003 10:46:26 -0500
From: Bing Du Test <bing-du@tamu.edu>
Subject: delete an element from an array?
Message-Id: <3EC264D2.7724F85E@tamu.edu>
I know how to delete an element from a hash. What about deleting from
an array if I just know the element value rather than its position in
the array? I've looked 'delete' up in perlfunc, but still have no clear
clue.
Thanks in advance for any help,
Bing
------------------------------
Date: Wed, 14 May 2003 16:11:10 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: delete an element from an array?
Message-Id: <3ec269b4.2942199739@news.cis.dfn.de>
On Wed, 14 May 2003 10:46:26 -0500, Bing Du Test
<bing-du@tamu.edu> wrote:
>I know how to delete an element from a hash. What about deleting from
>an array if I just know the element value rather than its position in
>the array? I've looked 'delete' up in perlfunc, but still have no clear
>clue.
perldoc -f grep
#!perl
use warnings;
use strict;
my @array = qw/one two three/;
my $exclude = 'two';
@array = grep !/^$exclude$/,@array;
print join "\n",@array;
__END__
--
Regards, Helgi Briem
helgi DOT briem AT decode DOT is
------------------------------
Date: 14 May 2003 17:28:17 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: delete an element from an array?
Message-Id: <u9fznhjxwe.fsf@wcl-l.bham.ac.uk>
Bing Du Test <bing-du@tamu.edu> writes:
> I know how to delete an element from a hash. What about deleting from
> an array if I just know the element value rather than its position in
> the array?
It probably means you should have been using a hash not an array.
Even if you are convinced you don't want a hash, are you sure you
really need to delete from the _array_?
Would replacing the contents of the array with a new list that was
equal to the old contents but without the element be sufficient?
@a = grep { $_ ne $e } @a;
This isn't deleting from the array - but for most purposes the
difference is not significant.
> I've looked 'delete' up in perlfunc, but still have no clear
> clue.
Well it tells you - use splice()
If you really want to delete from the array:
for ( reverse $#a .. 0 ) {
splice @a, $_, 1 if $a[$_] eq $e;
}
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 14 May 2003 17:30:26 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: delete an element from an array?
Message-Id: <u9bry5jxst.fsf@wcl-l.bham.ac.uk>
helgi@decode.is (Helgi Briem) writes:
> @array = grep !/^$exclude$/,@array;
@array = grep !/^\Q$exclude\E$/,@array;
Of course more natural is:
@array = grep $_ ne $exclude,@array;
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 14 May 2003 09:57:55 -0700
From: unix@att.com (rab)
Subject: gotta be a better way
Message-Id: <9bb5fc.0305140857.21f8c82f@posting.google.com>
I've had to resort to this:
--------------------------------------
foreach (<AFILE>) {
push(@aim,$_) if /aim/;
push(@ait3p,$_) if /ait3p/;
push(@bsc3270,$_) if /bsc3270/;
push(@cpmhs,$_) if /cpmhs/;
push(@dkap,$_) if /dkap/;
push(@ebim,$_) if /ebim/;
push(@frm,$_) if /frm/;
push(@msm,$_) if /msm/;
} #end foreach my item
if(@aim){foreach (@aim){print "$_\n";}}
if(@ait3p){foreach (@ait3p){print "$_\n";}}
if(@bsc3270){foreach (@bsc3270){print "$_\n";}}
if(@cpmhs){foreach (@cpmhs){print "$_\n";}}
if(@dkap){foreach (@dkap){print "$_\n";}}
if(@ebim){foreach (@ebim){print "$_\n";}}
if(@frm){foreach (@frm){print "$_\n";}}
if(@msm){foreach (@msm){print "$_\n";}}
-------------------------------------------------
but I shouldn't do it that manually.... I **should** be able to
complete all these repetitive tasks by using this (an array of the
arrays) somehow:
my @types=(\@aim,\@ait3p,\@bsc3270,\@cpmhs,\@dkap,\@ebim,\@frm,\@msm);
but how!? I keep getting ARRAY(OxNNNNNNNN) references.
some help?
rab
------------------------------
Date: Wed, 14 May 2003 10:12:51 -0500
From: Dodger <dodger@dodger.org>
Subject: Re: In search of elegant code - running code within a larger Print stmt
Message-Id: <Xns937B53D70D0Edodgerdodgerorg@216.166.71.239>
On 12 May 2003, IneverReadAnythingSentToMe@hotmail.com (David Filmer) in
news:e4c916dd.0305121307.4c3d0270@posting.google.com said something that
resembled:
> (this example refers to CGI.pm functions, but could be generalized)...
>
> I'm creating a webform, and want to include ten upload fields (created
> with CGI.pm's 'filefield' function). I can do something like this:
>
> for (1..10) {push @TEMP, filefield(-name => 'file')};
>
> print
> table({...}, #a CGI.pm function
> ...
> @TEMP, #include previously created tags - YUCK!
> ...
> ); #end table definition and print statement
>
> I would prefer to imbed the code within the print statement (and
> within the table function) like this:
>
> print
> table({...}, #a CGI.pm function
> ...
> ${for (1..10) {print filefield(-name => 'file')}},
> ...
> ); #end table definition and print statement
>
> It does not work as desired, because the interpreter resolves the
> imbedded print statement before it can resolve the larger print
> statement, so my filefields print at the top of my document instead of
> where I want them to go.
>
> How can I properly embed the code within the larger print statement?
>
You're looking for 'map' I think.
print table({...}, map(filefield(-name => 'file'),1..10), ...);
Sound right?
Of course, if there are no differences in the filefields, you can just
multiply it:
print table({...}, filefield(-name => 'file')x10, ...);
The former would be mostly if you want to do something like name them
something different for each number, like:
print table({...}, map(filefield(-name => "file_$_"),1..10), ...);
--
Dodger
------------------------------
Date: 14 May 2003 15:49:27 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: is there a built in mathematical type "dot product" function for arrays in perl? How about composition of Hashes?
Message-Id: <slrnbc4pc7.mth.abigail@alexandra.abigail.nl>
Mitchell Laks (mlaks2000@yahoo.com) wrote on MMMDXLIII September MCMXCIII
in <URL:news:ab3b13db.0305140431.1ed9b00e@posting.google.com>:
** Dear Perl Gurus,
** is there a built in mathematical "dot product" of arrays in perl (ie
** component wise "combination", for each array element) or do we simply
** write the obvious loop?
You'd write the loop.
Abigail
--
perl -Mstrict='}); print "Just another Perl Hacker"; ({' -le1
------------------------------
Date: 14 May 2003 08:36:56 -0700
From: lawrence.tierney@bipcontracts.com (Lawrence Tierney)
Subject: Re: measuring web resource loading time
Message-Id: <17e88dbe.0305140736.2e9f1d5b@posting.google.com>
> >> I was wondering if there is a way to measure the time taken
> >> by a cgi program to execute.
The Benchmark module may be of interest to you,
------------------------------
Date: 14 May 2003 10:52:56 -0700
From: botfood@yahoo.com (dan baker)
Subject: module to generate locations based on address ?
Message-Id: <13685ef8.0305140952.55afc4ee@posting.google.com>
I am wondering if there is a module, or online resource, that will
generate graphics of locations based on addresses. Basically,
something like mapquest except with the ability to pass in a list of
addresses. I need to generate some graphics for locations at the US
national, state, and city zoom levels.
if there is no freebie, is anyone aware of a reasonably priced
graphics program that might import a list and overlay it in a graphics
file? It would be ESPECIALLY good if there is one that could be
installed and run interactively via commandline for dynamic requests.
thanx,
D
------------------------------
Date: 14 May 2003 17:08:47 GMT
From: wrm@rrscfi1.irngtx.tel.gte.com (William R. Mattil)
Subject: Re: mysql DBI ? relaced by NULL
Message-Id: <b9tt6v$8h$1@news.gte.com>
In article <56568be5.0305130336.14772d10@posting.google.com>,
Mike Solomon <mike_solomon@lineone.net> wrote:
>I am using DBI and mysqlPP to insert into a database
>If my data includes '?' they get replaced with NULL
>I have tried prefixing ? with \ but that makes no difference
>Any help to resolve this would be much appreciated
Mike,
I am not familar with mysqlPP but ....... with mysql the insert of
a ? character works just fine. Though I did make some very minor changes
to your code. Nothing having to do with the insert though.
mysql> select * from test_table;
+---------+----------+--------------+
| Mike ? | MIKE ? T | ???-???-???? |
+---------+----------+--------------+
Regards
Bill
--
William R. Mattil | Failure is not an Option ... It's bundled
Sr. System Aministrator | with all Microsoft Products
(972) 399-4106 |
------------------------------
Date: 14 May 2003 17:48:51 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: MYSQL images
Message-Id: <u93cjhjwy4.fsf@wcl-l.bham.ac.uk>
Music Man <musicman@hotmail.com> writes:
> In article <3EC1F118.8060401@bbsrc.ac.uk>, simon.andrews@bbsrc.ac.uk
> says...
> > Do you really need to store the images in the
> > database itself. This gives you the overhead of retrieving them and
> > outputting them with a CGI script each time. When I've needed to do
> > this before I usually store the images on disk, and store their location
> > in the database. That way I can add the real image location into the
> > first dynamically generated web page and save myself the extra overhead
> > of a separate CGI call for each image.
>
> Yes, because of the security reasons. You have control over which image
> can be shown. If you have only locations of the images stored in a
> database, than anyone who can guess filename, can actually see it.
Anyone who can guess the HTTP request needed to retrieve the image can
see it. This is inpedendant of how the image is stored. I also has
nothing to do with Perl.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 14 May 2003 16:45:05 GMT
From: Paul van der Heu <pvdh@xs4all.nl>
Subject: Newbie question
Message-Id: <Xns937BBEC2F6A45pvdhNL@194.134.35.159>
I'm just starting out with perl, I have been kooking for
something like Arexx on the Amiga and think that perl should
do nicely.
My question is how do I check on a part of a string while not
taking case into account..
In Arexx this:
if SUBSTR(UPPER($name,4,3))= "SC8"
Would change a three chracter part of $name starting at position 4 to
uppercase and copmpare it to "SC8".
I cannot figure the change to uppercase part .. the rest I have
any help mucho appreciated..
BTW I have Perl for dummies.. any other recommended reading?
Paul
--
De Nederlandse geluidstechniek site is op komst!
check alvast het forum http://forum.geluidstechniek.nl/
------------------------------
Date: Wed, 14 May 2003 10:53:34 -0600
From: "XyZ" <joe@blowme.com>
Subject: Re: Newbie question
Message-Id: <vc4t5q284gur54@corp.supernews.com>
"Paul van der Heu" <pvdh@xs4all.nl> wrote in message
news:Xns937BBEC2F6A45pvdhNL@194.134.35.159...
> I'm just starting out with perl, I have been kooking for
> something like Arexx on the Amiga and think that perl should
> do nicely.
>
> My question is how do I check on a part of a string while not
> taking case into account..
>
> In Arexx this:
>
> if SUBSTR(UPPER($name,4,3))= "SC8"
>
> Would change a three chracter part of $name starting at position 4 to
> uppercase and copmpare it to "SC8".
>
maybe something like this?
use strict;
my $string="ABCDEFG";
if (uc(substr($string,0,3)) eq "ABC"){
print "found a match\n";
};
Rodney
------------------------------
Date: 14 May 2003 11:00:57 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Newbie question
Message-Id: <etoel31foom.fsf@wormtongue.emschwar>
Paul van der Heu <pvdh@xs4all.nl> writes:
> In Arexx this:
>
> if SUBSTR(UPPER($name,4,3))= "SC8"
>
> Would change a three chracter part of $name starting at position 4 to
> uppercase and copmpare it to "SC8".
I hope you meant 'SUBSTR(UPPER($name),4,3)', otherwise I'm seriously
confused.
> I cannot figure the change to uppercase part .. the rest I have
perldoc -f uc
> any help mucho appreciated..
>
> BTW I have Perl for dummies.. any other recommended reading?
http://learn.perl.org/books
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Wed, 14 May 2003 10:05:32 -0700
From: TruthXayer <TruthXayer@yahoo.com>
To: Paul van der Heu <pvdh@xs4all.nl>
Subject: Re: Newbie question
Message-Id: <3EC2775C.C77F1266@yahoo.com>
Paul van der Heu wrote:
>
> I'm just starting out with perl, I have been kooking for
> I cannot figure the change to uppercase part .. the rest I have
> any help mucho appreciated..
perldoc -f uc
------------------------------
Date: 14 May 2003 17:13:27 GMT
From: Kosh <kosh@babylon5.space>
Subject: Re: Newbie question
Message-Id: <Xns937BC3921C468koshb5@194.134.35.159>
Eric Schwartz <emschwar@pobox.com> wrote :
> I hope you meant 'SUBSTR(UPPER($name),4,3)', otherwise I'm seriously
> confused.
:^). they should have debuggers in newsclients..
>> I cannot figure the change to uppercase part .. the rest I have
>
> perldoc -f uc
I found it .. I use this:
unless (index("\U$Name\E","SC8"))
since the string I want is always the first three characters this works as
it returns 0 for a match.
------------------------------
Date: Wed, 14 May 2003 17:47:42 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: No data entering @array from open(DATA...)
Message-Id: <2jvwa.2220$6L5.1289024@news4.srv.hcvlny.cv.net>
"Brad Walton" <sammie@greatergreen.com> wrote in message
news:oZhwa.837397$F1.105601@sccrnsc04...
> This has me stumped. I must be missing something very basic, but I
cannot
> get @currplids to populate with the data from $playeriddb. Anyone see
the
> mistake?
>
> Code:
> ----
> my (@currplids, $playerid, $currplids, $playerupdate);
> #Grab current player id database
> open(CPDATA, ">>$playeriddb") or "cannot open $playeriddb: $! \n";
Open in input (not append) mode.
Refer perldoc -f open
> while (<CPDATA>) {
> @currplids = (@currplids,$_);
> }
>
> #Set variable for next new player id
> $playerid = @currplids;
> print "first $playerid\n@currplids\n";
>
Good Luck,
Bill
------------------------------
Date: 14 May 2003 09:13:26 -0700
From: tivolinewbie@canada.com (Kenjis Kaan)
Subject: tools to make perl scripts an EXE executables??
Message-Id: <6a8ba9f8.0305140813.3c823ec@posting.google.com>
Hi gurus, could someone please tell me if there are tools available
out there that can convert my perl program scripts into executable
programs?? This is because we are having the problems of handing
scripts over to be run on customer environments whereby the perl
interpreter are not readily available and in fact not allowed to be
installed.
By the way what would happens if my programs relies on a lot of
packages (*.pm) object oriented files which I wrote?? Would any PL ->
EXE tool deal with this in a nice way? TIA
------------------------------
Date: Wed, 14 May 2003 17:22:30 +0100
From: "Mike Solomon" <mike_solomon@lineone.net>
Subject: Re: tools to make perl scripts an EXE executables??
Message-Id: <3ec26d04_2@mk-nntp-2.news.uk.tiscali.com>
"Kenjis Kaan" <tivolinewbie@canada.com> wrote in message
news:6a8ba9f8.0305140813.3c823ec@posting.google.com...
> Hi gurus, could someone please tell me if there are tools available
> out there that can convert my perl program scripts into executable
> programs?? This is because we are having the problems of handing
> scripts over to be run on customer environments whereby the perl
> interpreter are not readily available and in fact not allowed to be
> installed.
Try Perl2exe http://www.indigostar.com/perl2exe.htm
It works really well
>
> By the way what would happens if my programs relies on a lot of
> packages (*.pm) object oriented files which I wrote?? Would any PL ->
> EXE tool deal with this in a nice way? TIA
Perl2exe handles modules as well
Regards
Mike Solomon
------------------------------
Date: 14 May 2003 17:52:04 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Which module to use for ordered hashes?
Message-Id: <u9y919ii8b.fsf@wcl-l.bham.ac.uk>
Lechu <kopetnik@s-pam-nie.yahoo.com> writes:
> On Wed, 14 May 2003 14:00:23 +0200, Tore Aursand <tore@aursand.no>
> wrote:
>
> >On Wed, 14 May 2003 13:18:22 +0200, Lechu wrote:
> >> There are some implementations of ordered hashes on CPAN.
> >> [...]
>
> >The Tie::IxHash module from CPAN
> > might also be instructive.
> Unfortunately this module doesn't provide solution for
> multidimensional hashes:
Tied multidimentional hashes are very hard to implement.
To see some of the numerous previous discussions about this:
http://groups.google.com/groups?q=tie+hash+autovivification
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
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 4984
***************************************