[18130] in Perl-Users-Digest
Perl-Users Digest, Issue: 290 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 14 18:06:07 2001
Date: Wed, 14 Feb 2001 15:05:14 -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: <982191914-v10-i290@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 14 Feb 2001 Volume: 10 Number: 290
Today's topics:
calling clock ! <nowayandnohow@hotmail.com>
Re: calling clock ! <shino_korah@yahoo.com>
Re: comp.infosystems.www.authoring.cgi (David H. Adler)
Re: comp.infosystems.www.authoring.cgi <walt@myxa.com>
comp.lang.perl does not exist (was: File stat's) nobull@mail.com
DBI <crazzeto@hotmail.com>
Re: DBI (John Joseph Trammell)
Re: DBI <joe+usenet@sunstarsys.com>
Re: Fastest way to parse a XML-document? (Eric Bohlman)
Re: GUI problem <aqumsieh@hyperchip.com>
Re: Hashes of Arrays <bart.lateur@skynet.be>
Re: Hashes <uri@sysarch.com>
Re: How do I translate a Cobol WORKING-STORAGE SECTION <russ_jones@rac.ray.com>
Re: how to find cpu time usage from within perl nobull@mail.com
Re: how to find cpu time usage from within perl <sorryno@email.at.all>
Re: Newbie: How do I make my home Win2k IIS system run <nowayandnohow@hotmail.com>
Re: opening files (Rob - Rock13.com)
Re: OT:status of the reorg of The Perl Journal <uri@sysarch.com>
Re: OT:status of the reorg of The Perl Journal <comdog@panix.com>
perl -e '$a='*'' What's wrong with it ? (Ian Moltke)
Re: perl -e '$a='*'' What's wrong with it ? <uri@sysarch.com>
Re: perl -e '$a='*'' What's wrong with it ? (Abigail)
Proper sorting - alphanumeric values? <pobbard@hotresponse.com>
Re: Proper sorting - alphanumeric values? <aqumsieh@hyperchip.com>
Re: Question <copenhagen@copenhagen.com>
Re: regex experts <terrence.brannon@oracle.com>
Re: regex experts <uri@sysarch.com>
Re: regex experts <bart.lateur@skynet.be>
Re: regex experts <jdf@pobox.com>
Screen with - screen height <polaris@wanadoo.be>
Re: Screen with - screen height <tony_curtis32@yahoo.com>
Re: Screen with - screen height <bjoern@hoehrmann.de>
Re: Screen with - screen height <jdb@ga.prestige.net>
Smart truncating of text <jesse@uchicago.edu>
Re: split Qustion <godzilla@stomp.stomp.tokyo>
Using Modules <shino_korah@yahoo.com>
Re: XS -- "array subscript is not an integer" <Jonathan.L.Ericson@jpl.nasa.gov>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 14 Feb 2001 20:46:34 GMT
From: "nowayandnohow" <nowayandnohow@hotmail.com>
Subject: calling clock !
Message-Id: <K8Ci6.21$is3.12330@typhoon2.ba-dsg.net>
How do i get the time from my NT server into my perl script ? And how do i
convert it to a value ?
// Jo
------------------------------
Date: Wed, 14 Feb 2001 12:52:11 -0800
From: "terminalsplash" <shino_korah@yahoo.com>
Subject: Re: calling clock !
Message-Id: <96er5s$f9p@news.or.intel.com>
$start = time();
print "the time is" scalar localtime($start)"\n";
"nowayandnohow" <nowayandnohow@hotmail.com> wrote in message
news:K8Ci6.21$is3.12330@typhoon2.ba-dsg.net...
> How do i get the time from my NT server into my perl script ? And how do i
> convert it to a value ?
>
> // Jo
>
>
------------------------------
Date: 14 Feb 2001 19:21:49 GMT
From: dha@panix2.panix.com (David H. Adler)
Subject: Re: comp.infosystems.www.authoring.cgi
Message-Id: <slrn98lmmd.e5r.dha@panix2.panix.com>
On Wed, 14 Feb 2001 11:39:29 -0600 (CST), BUCK NAKED1
<dennis100@webtv.net> wrote:
> We're forced to post our perl CGI questions here now, like it or not.
No you are not. Just because you can't get to a particular newsgroup is
in *no* way justification for posting off topic questions in another
one.
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"Anybody's apt to trip."
"Not over a sofa!" - The Lady Eve
------------------------------
Date: 14 Feb 2001 14:33:09 -0500
From: Walt Mankowski <walt@myxa.com>
Subject: Re: comp.infosystems.www.authoring.cgi
Message-Id: <lnbss5m556.fsf@myxa.com>
dennis100@webtv.net (BUCK NAKED1) writes:
> What's wrong with this sister group? No posts there since Feb 4.
"Sister group"?
------------------------------
Date: 14 Feb 2001 18:48:17 +0000
From: nobull@mail.com
Subject: comp.lang.perl does not exist (was: File stat's)
Message-Id: <u9ofw5f6d5.fsf_-_@wcl-l.bham.ac.uk>
"Darryl Olthoff" <olthoff@multiboard.com> writes:
> > comp.lang.perl is a bogus group. It officially does not exist. Your
> > news admin needs to be flogged for carrying it.
>
> Perhaps none of us exist either. We all seem to be reading and posting in
> something that doesn't exist.
Who is "we all"? There are small isolated pockets of people who use
bogus groups.
> I guess the real question would be, if you
> feel that this group doesn't exist, then why the hell do you feel it
> necessary to waste my time posting here?
No, a better question would be Why the hell do you feel it necessary
to waste our time posting here (comp.lang.perl.misc)?
If you want to waste your own time posting to newsgroups that do not
exist except within the confines of your misconfigured systems then
fine, go ahead. However please do not crosspost between newsgroups
that exist and ones that don't.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 14 Feb 2001 16:38:37 -0800
From: "Carlo Razzeto" <crazzeto@hotmail.com>
Subject: DBI
Message-Id: <96ets5$bg6$1@walter.acs.nmu.edu>
I'm not sure if DBI is dicussed here, but I'll give it a shot. I am writing
a simple to do list in perl CGI which stores items in a mysql database along
with a unique ID number. in the following code:
if ($temp = $sth1->fetchrow_array())
{
$marker = 1;
while($marker != 0)
{
$sth->prepare ("select id from to_do where id = $marker");
$sth->execute();
if(!($temp = $sth->fetchrow_array()))
{
$marker = 0;
}
}
}
I get an error informing me that prepare could not be located via package
DBI::st with in the while loop. I have used $sth for a query before, is it
neccessary to unset the previouse value (some how) from $sth? In previouse
programs I was albe to use $sth, $sth1 and $sth2, but if I try $sth2 ($sth1
is also used in this program) I get "Can't call method "prepare" on an
undefined value". If anyone can offer insite it would be appriciated.
------------------------------
Date: Wed, 14 Feb 2001 22:18:09 GMT
From: trammell@bayazid.hypersloth.net (John Joseph Trammell)
Subject: Re: DBI
Message-Id: <slrn98luui.bg3.trammell@bayazid.hypersloth.net>
On Wed, 14 Feb 2001 16:38:37 -0800, Carlo Razzeto <crazzeto@hotmail.com> wrote:
> $sth->prepare ("select id from to_do where id = $marker");
Should be 'my $sth2 = $dbh->prepare(...);' or similar.
$sth and $dbh are different beasts. Perldoc DBI for more.
------------------------------
Date: 14 Feb 2001 17:52:49 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: DBI
Message-Id: <m366icj2ri.fsf@mumonkan.sunstarsys.com>
"Carlo Razzeto" <crazzeto@hotmail.com> writes:
> if ($temp = $sth1->fetchrow_array())
Since fetchrow_array returns a list, it might be better to
reflect this in your code (unless you really mean for $temp to
catch the last element in the list instead of the first. It's
probably academic here, though.)
if ( my ($temp) = $sth1->fetchrow_array )
> {
> $marker = 1;
^^
my
> while($marker != 0)
> {
> $sth->prepare ("select id from to_do where id = $marker");
^^^^
You didn't define $sth, so it has no methods to call. Besides,
you can't call prepare on a DBI::st object. prepare is
a DBI::db method. (See below).
Perhaps you meant to write
my $sth = $dbh->prepare(...) or die $DBI::errstr;
instead?
> $sth->execute();
>
> if(!($temp = $sth->fetchrow_array()))
Definitely academic here :)
if (! my ($tmp) = $sth->fetchrow_array ) {
[...]
> I get an error informing me that prepare could not be located
> via package DBI::st with in the while loop. I have used $sth for
> a query before, is it neccessary to unset the previouse value (some
> how) from $sth?
If by this you mean:
"$sth is used earlier in my code, so do I need to unset it first?
Will that fix it?",
then no. Reassigning it to another statement handler like
$sth = $dbh->prepare("select a from A");
$sth = $dbh->prepare("select b from B"); # replaces first handle
will work fine. But you *should* be using "my" far more often than
you appear to be. Strictures ("use strict;") and warnings (-w flag
or "use warnings;" on 5.6) are also a good habit, in case you're not
already using those.
> In previouse programs I was albe to use $sth, $sth1 and $sth2, but if
> I try $sth2 ($sth1 is also used in this program) I get "Can't call
> method "prepare" on an undefined value". If anyone can offer insite it
> would be appriciated.
DBI really has a lot of packages that are associated with it, but
the two chief ones are DBI::db and DBI::st. Respectively, they define
the interfaces for _database_ handle (usually $dbh in your code) and
_statement_ handle (usually $sth) objects. A typical sequence starts
something like this:
use DBI;
my $dbh = DBI->connect( # returns a DBI::db object
$dsn, $user, $passwd, {RaiseError => 1} );
my $sth = $dbh->prepare($sql); # returns a DBI::st object
$sth->execute( @params ); # tells backend database to run query
...
Note that the database handler and statement handler are in different
packages, so they have different methods available to them. You should
not call "prepare" on a DBI::st object ($sth) any more than you should
call "connect" on it. Ditto for trying to "execute" a DBI::db object
(although there are shortcuts available). See the DBI and DBD::mysql
documentation for details:
% man DBI
% man DBD::mysql
HTH
--
Joe Schaefer "Language is the dress of thought."
-- Samuel Johnson
------------------------------
Date: 14 Feb 2001 21:48:12 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Fastest way to parse a XML-document?
Message-Id: <96eues$bik$1@bob.news.rcn.net>
Matt Sergeant <matt@sergeant.org> wrote:
> Sadly not for documents of that size, no. The problem is that Perl XML
> parsers use expat in XS code to do their work. In order to pass events back
> to Perl you need to change the C variables into Perl ones (called SVs at the
> XS level) for every event. This is slow compared to either remaining all in
> Java or all in C. Needless to say, doing it all in C is the fastest
> solution, with Java being about 3 times or more slower.
It occurs to me that with a large document, the majority of events
returned by expat are likely to be character data events. As we all know,
expat will often return multiple character data events for a run of
characters, which is the fastest way to do things if you're using it
directly but causes a lot of "thrashing" between the Perl and C levels.
Has anyone (I'm not volunteering; too much on my hands now) investigated
whether some buffering at the XS level could reduce the number of
transitions? Obviously this wouldn't help much with documents that have a
very high ratio of markup to text (e.g. scholarly texts marked up at the
syllable level) but for many typical documents it would probably cut down
on the "crossing" substantially.
------------------------------
Date: Wed, 14 Feb 2001 20:50:36 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: GUI problem
Message-Id: <7a8zn96lb8.fsf@merlin.hyperchip.com>
"terminalsplash" <shino_korah@yahoo.com> writes:
> when i run my gui code,the compiler complains ::No -label at ....widget.pm
> at line 240
> this is my code (part of it)
> $menubar = $top->Frame()->pack(side=>'top');
> $search_mb = $menubar->Menubutton(text =>'Search',relief
> =>'raised',borderwidth =>2,)->pack(side=>'top',padx=>2);
> ####################################error here
> $search_mb->command ( label => 'Find',accelerator
> =>'Meta+F',underline=>0,command=>sub {print "find\n"});
> ###########################################
> $search_mb->seperator();
You should prefix all your options with a '-'. Example:
->pack(-side => 'top')
IIRC, in older versions of Tk, dashes were not required, but then they
were added and some of the classes still work without them, but not
all. Try that and see if it fixes your problem.
And, there is a Perl/Tk specific newsgroup next door. It is called
comp.lang.perl.tk. There, you will get more responses to your Tk
questions.
--Ala
------------------------------
Date: Wed, 14 Feb 2001 20:16:17 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Hashes of Arrays
Message-Id: <hopl8t8a7agevla3phmurvg2vuqpvuqglh@4ax.com>
LXQ wrote:
>$user{$id}{job => [2, 300, 5]}
>
>Then the data is from the database. The first call to the database will
>get all user id and job number. The @row is set of: $id and job. It is
>possible for the user with same id to have some job numbers, so I want to
>push them all in the array job. How can I do this? I tried:
>
>while (@row = $sth->fetchrow_array()){
> $user{$row[0]}{@job} = $row[1];
>}
Despite everybody's love of saying: "show us what you've got", I'll
igbore what you've got, and tell you how you can access the contents of
the field 'job' as an array.
@{$user{$id}{job}}
There. Try:
print $user{$id}{job}[1];
and you'll see "300". Same with:
print $user{$id}{job}->[1];
print ${$user{$id}{job}}[1];
So $user{$id}{job} is an array reference.
push @{$user{$id}{job}}, "foo";
I guess you can take it from there.
--
Bart.
------------------------------
Date: Wed, 14 Feb 2001 19:08:34 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Hashes
Message-Id: <x7d7clm6a5.fsf@home.sysarch.com>
>>>>> "MS" == Matti Särkisilta <drifter@clix.pt> writes:
MS> Uri Guttman wrote:
>> $is_leap = $year % 4 == 0 && $year % 100 || $year % 400 == 0 ;
MS> Ahhem,
ahem, did you HAVE TO QUOTE 160 lines just to comment on one?
MS> $year % 4 == 0 && $year % 100 || $year % 400 == 0?29:28
MS> as it works in code:
MS> %DaysInMonth =
MS> (0,31,1,$year % 4 == 0 && $year % 100 || $year % 400 ==
MS> 0?29:28,2,31,3,30,4,31,5,30,6,31,7,31,8,30,9,31,10,30,11,31);
i wasn't trying to make it work in his code. it would be better to do it
my way anyhow. testing for 28/29 in his code is silly. you just make feb
have 28 days and add the leap year boolean ro it or bump it as
desired. much cleaner. then you have a simple boolean flag to use for
other issue like days of the year, etc.
and his data structure that you keep is not good as it should be an
array.
uri
--
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, 14 Feb 2001 14:38:05 -0600
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: How do I translate a Cobol WORKING-STORAGE SECTION into the format I wanted?
Message-Id: <3A8AECAD.270D5FBE@rac.ray.com>
jck1 wrote:
>
> Russ Jones <russ_jones@rac.ray.com> wrote in message >
> Thanks for your noticing my question :)
>
Taking this to email, since it seems to be leaving the realm of Perl.
--
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747
Te audire non possum. Musa sapientum fixa est in aure. - Plautus
------------------------------
Date: 14 Feb 2001 18:55:28 +0000
From: nobull@mail.com
Subject: Re: how to find cpu time usage from within perl
Message-Id: <u9lmr9f61r.fsf@wcl-l.bham.ac.uk>
Richard Chen <qchen@snet.net> writes:
> The CPAN modules such as Time::HiRes measure actual time passed
> bewteen consecutive calls. This may vary significantly if the system
> is busy. I would like to measure actual cpu times used irrespective
> of the system load.
>
> On unix flatforms there is the system call clock which does that.
No it is not called clock, it is called something else.
> I could not find a perl interface to invoke that.
The Perl interface is a builtin function that has the same name as the
Unix system call.
If you still can't find it then try looking in:
perlfunc/"Perl Functions by Category"/"Time-related functions"
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 14 Feb 2001 21:46:41 -0000
From: "Brian J" <sorryno@email.at.all>
Subject: Re: how to find cpu time usage from within perl
Message-Id: <3a8afeba_2@news2.uncensored-news.com>
"Richard Chen" <qchen@snet.net> wrote in message
news:3A8AD0D9.AFFBC6CA@snet.net...
> The CPAN modules such as Time::HiRes measure actual time passed
> bewteen consecutive calls. This may vary significantly if the system
> is busy. I would like to measure actual cpu times used irrespective
> of the system load.
>
> On unix flatforms there is the system call clock which does that. I
> could not find
> a perl interface to invoke that.
>
> Does anyone know any modules that deal with measuring cpu times
> within perl or some other ways to achieve this?
>
> Platform dependency is ok. I am interested in solaris/linux.
>
> Thanks for any info.
(Delurking)
This may help -
http://www.wdvl.com/Authoring/Languages/Perl/PerlfortheWeb/block.html
--
Brian
______________________________________________________________________
Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com
With Servers In California, Texas And Virginia - The Worlds Uncensored News Source
------------------------------
Date: Wed, 14 Feb 2001 20:45:23 GMT
From: "nowayandnohow" <nowayandnohow@hotmail.com>
Subject: Re: Newbie: How do I make my home Win2k IIS system run Perl scripts?
Message-Id: <D7Ci6.96$G76.11165@typhoon2.ba-dsg.net>
If you installed the activestate perl you should be fine.
All you have to do is go in to the webserver management and allow the
webfolder where the script is "run script"
Do remember that perl scripts and CGI scripts are different from eachother
:-)
a correct script to run to see if it works could be:
print "Content-Type: text/html\n\n";
print "Hello World!\n";
and then call:
http://localhost/name_of_the_script.pl
// Jo
"DaveP" <DavePerkins@bigfoot.com> wrote in message
news:96ek1o$7qq$1@newsg4.svr.pol.co.uk...
> Hello
>
> I have IIS installed on my Win2k (Pro) pc. I also have Activestate Perl
> installed.
>
> How can I make IIS run my Perl scripts? At the moment if I type
> http://Localhost/scripts/hello.pl it brings up the download box.
>
> In IIS, do I have to associate the .pl extension with the perl.exe
> application?
>
> Thanks
>
> David
>
>
------------------------------
Date: 14 Feb 2001 22:26:31 GMT
From: rob_13@excite.com (Rob - Rock13.com)
Subject: Re: opening files
Message-Id: <9048B5CA7rock13com@207.91.5.10>
M Comerford <mcomerf@nortelnetworks.com>:
>Hi, I am new at programming with perl and I was wondering if perl
>scripts can open up files directly over the internet. For
>example, my script is running on one server and I want it to be
>able to open a .txt file that runs on a completely different
>external server. So, in the "open" command I am going to need a
>web address. Is this possible?
No. You need to fetch the file and store it locally before open can
open it.
Use a module like LWP:Simple which will get a file via HTTP. You
wouldn't have to store it locally if you stick the file into an array
for example.
--
Rob - http://rock13.com/
Web Stuff: http://rock13.com/webhelp/
------------------------------
Date: Wed, 14 Feb 2001 19:12:38 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: OT:status of the reorg of The Perl Journal
Message-Id: <x78zn9m63d.fsf@home.sysarch.com>
>>>>> "m" == mothra <mothra@nowhereatall.com> writes:
m> Hello All, I would like to subscribe to "The Perl Journal" but when
m> I went to the web site I found this: Unfortunately, The Perl
m> Journal is undergoing a transition and is not processing new
m> subscriptions or the ordering of back issues at this time. Does
m> anyone know when they will be able to take subscriptions ?
the last poop i heard was that (scum of the) earthweb sold tpj to
internet.com. that data sink has not done nor announced anything
yet. don't hold your breath waiting for it. if jon orwant were probably
not tied by legal stuff, i bet he would start a new publication and not
sell it to some jerk web company. i am sure if/when tpj is resurrected,
that news will be spread rapidly in the perl community.
uri
--
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, 14 Feb 2001 14:16:06 -0800
From: brian d foy <comdog@panix.com>
Subject: Re: OT:status of the reorg of The Perl Journal
Message-Id: <comdog-62F7CB.14160614022001@news.panix.com>
In article <x78zn9m63d.fsf@home.sysarch.com>, Uri Guttman
<uri@sysarch.com> wrote:
> >>>>> "m" == mothra <mothra@nowhereatall.com> writes:
>
> m> Hello All, I would like to subscribe to "The Perl Journal" but when
> m> I went to the web site I found this: Unfortunately, The Perl
> m> Journal is undergoing a transition
> the last poop i heard was that (scum of the) earthweb sold tpj to
> internet.com. that data sink has not done nor announced anything
> yet. don't hold your breath waiting for it. if jon orwant were probably
> not tied by legal stuff, i bet he would start a new publication and not
> sell it to some jerk web company.
hopefully the change in control releases him from his obligation,
if the contract favored Jon in anyway.
there is more rumor on `use Perl;`
http://use.perl.org/articles/01/01/26/2137201.shtml
--
brian d foy <comdog@panix.com>
------------------------------
Date: Wed, 14 Feb 2001 21:56:08 GMT
From: ianmoltke@yahoo.com (Ian Moltke)
Subject: perl -e '$a='*'' What's wrong with it ?
Message-Id: <Y9Di6.494$N12.84318@amsnews02.chello.com>
Can anyone tell me ?
Why
perl -e '$a='*'' is not ok ?
versus
perl -e '$a="*"' which is ok .
But still
perl -e '$a='b'' is ok too !?
I thought the first sentence was the correct one
because of wysiwyg '
I found its also wrong with other special characters like | \ or /
Would really welcome any explanation .
Ian Moltke
ianmoltke@yahoo.com
------------------------------
Date: Wed, 14 Feb 2001 22:07:48 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: perl -e '$a='*'' What's wrong with it ?
Message-Id: <x7zofolxze.fsf@home.sysarch.com>
>>>>> "IM" == Ian Moltke <ianmoltke@yahoo.com> writes:
IM> Can anyone tell me ? Why
IM> perl -e '$a='*'' is not ok ?
IM> perl -e '$a="*"' which is ok .
IM> perl -e '$a='b'' is ok too !?
do you know you are using a shell? and why you quote the -e string?
think about it for a second and ask what does the shell see in those
three lines? and then what does perl see?
uri
--
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: 14 Feb 2001 22:40:33 GMT
From: abigail@foad.org (Abigail)
Subject: Re: perl -e '$a='*'' What's wrong with it ?
Message-Id: <slrn98m2b1.ji5.abigail@tsathoggua.rlyeh.net>
Ian Moltke (ianmoltke@yahoo.com) wrote on MMDCCXXIV September MCMXCIII in
<URL:news:Y9Di6.494$N12.84318@amsnews02.chello.com>:
:: Can anyone tell me ?
:: Why
::
:: perl -e '$a='*'' is not ok ?
::
:: versus
::
:: perl -e '$a="*"' which is ok .
::
:: But still
::
:: perl -e '$a='b'' is ok too !?
It's a shell thing. ' to the shell is nothing more than a toggle, turning
specialness of characters off and on.
So, in
'$a='b''
$a= is prevented from seen special to the shell, while b is interpreted
by the shell. Since that isn't special, it remains just b. So, perl gets
passed
$a=b
as argument, which is valid Perl; b being seen as a bareword. The trailing
'' just tags the empty string to it.
However, the
'$a='*''
is different. Again, quotes protect the shell from interpreting
$a=
but * *is* being interpreted, and expanded to a list of file/directory
names. So, perl will get something like:
$a=Mailbox bin foo frobnitz
which isn't valid Perl, and hence perl will complain.
:: I thought the first sentence was the correct one
:: because of wysiwyg '
WTF is wysiwyg ' ?
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Wed, 14 Feb 2001 15:10:07 -0500
From: "Philip Obbard" <pobbard@hotresponse.com>
Subject: Proper sorting - alphanumeric values?
Message-Id: <96eocj$clu$1@taliesin.netcom.net.uk>
Hi all,
I'm trying to sort an array of hashes on a certain key alphanumerically.
However, if I have a mix of values, like "1", "2", "A", "b", "3f", "21",
etc., I can't seem to get an acceptable sort. Here's my example:
#!/usr/local/bin/perl -w
use strict;
use Data::Dumper;
#Create some dummy hashes in an array
my (@array);
#Add some bogus hashes
push @array, {value => '1b'};
push @array, {value => 'e'};
push @array, {value => '1a'};
push @array, {value => '5'};
push @array, {value => 'b'};
push @array, {value => '22'};
push @array, {value => '99'};
push @array, {value => 'D'};
push @array, {value => '2'};
push @array, {value => '2f'};
push @array, {value => '0.8'};
push @array, {value => 'C'};
push @array, {value => '1'};
push @array, {value => '10'};
print Dumper(\@array);
print "\n\n\n";
#Sort the array on the Hashes
my @tmp = sort { uc($a->{value}) cmp uc($b->{value}) } @array;
#my @tmp = sort { $a->{value} <=> $b->{value} } @array;
print Dumper(\@tmp);
exit;
############
(As you can see, I tried sorting two different ways - the 'cmp' worked OK;
the '<=>' got mad about the letters (as it should).)
The sort order I get from using 'cmp' was:
0.8
1
10
1a
1b
2
22
2f
5
99
b
C
D
e
Letters work fine. Alphanumerics work fine. The big problem here are just
the longer numbers (like 22) which should appear after five, but are instead
sorting alpha (after 2). Same goes for 10 sorting after 1.
My question is: Can I do a smarter sort of this? Can I mix pure numerics AND
alphanumerics and get the numerics to sort correctly, or is that not
possible? Is there a regex combo that might help?
Sorry for the long post. Any help would be appreciated.
Thanks,
Philip
--
--------------
Hotresponse - www.hotresponse.com
W: (646) 375-7845
pobbard@hotresponse.com
------------------------------
Date: Wed, 14 Feb 2001 20:29:53 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Proper sorting - alphanumeric values?
Message-Id: <7ad7cl6m9t.fsf@merlin.hyperchip.com>
"Philip Obbard" <pobbard@hotresponse.com> writes:
> I'm trying to sort an array of hashes on a certain key alphanumerically.
> However, if I have a mix of values, like "1", "2", "A", "b", "3f", "21",
> etc., I can't seem to get an acceptable sort. Here's my example:
Your values seem suspiciously similar to hexadecimal numbers. Are they?
If they are, then you can use the hex() function in your sort subroutine
and sort numerically:
> #Sort the array on the Hashes
> my @tmp = sort { uc($a->{value}) cmp uc($b->{value}) } @array;
my @tmp = sort { hex($a->{value}) <=> hex($b->{value}) } @array;
--Ala
------------------------------
Date: Thu, 15 Feb 2001 07:38:11 +1000
From: "Copenhagen" <copenhagen@copenhagen.com>
Subject: Re: Question
Message-Id: <eCDi6.30$Ib.9830563@news.randori.com>
"Tore Aursand" <tore@extend.no> wrote in message
news:MPG.14f47e8a5e34b61d9898ad@news.online.no...
> In article <21si6.296$yps1.42336308@news.randori.com>,
> copenhagen@copenhagen.com says...
[SNIP
]> Now back to the problem; How do you know what to select? I'm not sure
> that you are giving us all the details on the problem, or is it me that
> can't understand what you're meaning?
>
>
Here is the actual code.
my $id = $q->param('id');
my @entry = queryrow("SELECT * FROM customer, billing_address WHERE
customer.id = '$id' and billing_address.id = '$id'");
my @servicetype = queryrow("SELECT * FROM phone_service where id = '$id'");
my @options = queryrow("SELECT * FROM options where id ='$id'");
my $sth = $dbh->prepare("SELECT * FROM switch WHERE id = '$id'");
$sth->execute();
@switch = $sth->fetchrow_array;
my
($sid,$imsi,$msidsn,$msisdn,$mscat,$ts1,$ts2,$ts3,$piccide,$substatus,$ts1p,
$ts2p,$ts3p,$boca,$bocint,$bocpi,$bocssc,$bocintexclhplmn,$bocpe,$bica,
$bicroam,$cfscfu,$cfscfb,$cfscfnr,$cfscfun,$udbcbdbsc,$udbboaoc,$udbbooic,
$udbbooicetthc,$udbboaic,$udbboaicwroh,$ccdcw,$ccdch,$mpdmp,$lidclipd,$lidcl
ird) = @switch;
$sth->finish;
#generate the <select><option> for each yes no item of the switch table.
my %hash =
(1,"ts1p",2,"ts2p",3,"ts3p",4,"boca",5,"bocint",6,"bocpi",7,"bocssc",8,"boci
ntexclhplmn",
9,"bocpe",10,"bica",11,"bicaroam",12,"cfscfu",13,"cfscfb",14,"cfscfnr",15,"c
fscfun",
16,"udbcbdbsc",17,"udbboaoc",18,"udbbooic",19,"udbbooicetthc",20,"udbboaic",
21,"udbboaicwroh",
22,"ccdcw",23,"ccdch",24,"mpdmp",25,"lidclipd",26,"lidclird");
my $num = 1;
my $item;
my
($box_1,$box_2,$box_3,$box_4,$box_5,$box_6,$box_7,$box_8,$box_9,$box_10,$box
_11,
$box_12,$box_13,$box14,$box15,$box16,$box_17,$box_18,$box_19,$box_20,$box_21
,
$box_22,$box_23,$box_24,$box_25,$box_26)='';
foreach ($ts1p,$ts2p,$ts3p,$boca,$bocint,$bocpi,$bocssc,$bocintexclhplmn,
$bocpe,$bica,$bicroam,$cfscfu,$cfscfb,$cfscfnr,$cfscfun,$udbcbdbsc,
$udbboaoc,$udbbooic,$udbbooicetthc,$udbboaic,$udbboaicwroh,
$ccdcw,$ccdch,$mpdmp,$lidclipd,$lidclird) {
$item = $hash{$num};
if ($thing eq "Y") {
$box."_".$num .= "<select size=\"1\" name= $item>";
$box."_".$num .= "<option value=\"Y\" selected>Yes</option>";
$box."_".$num .= "<option value=\"N\">No</option>";
$box."_".$num .= "</select>";
} else {
$box."_".$num .= "<select size=\"1\" name= $item>";
$box."_".$num .= "<option value=\"Y\">Yes</option>";
$box."_".$num .= "<option value=\"N\" selected>No</option>";
$box."_".$num .= "</select>";
}
$num++;
}
Now that I am showing the BIGGER picture of what I need here maybe you can
help. Sorry bout b4 as my mind doesn't always work at 2AM as it should.
what I want is the following
if $ts1p is equal to Y then i want
<select size = "1" name = "ts1p">
<option> value = "Y" selected>Yes</option>
<option> value = "N">Yes</option>
</select>
but if $ts1p not equal to Y
<select size = "1" name = "ts1p">
<option> value = "Y">Yes</option>
<option> value = "N" selected>Yes</option>
</select>
and I need to do this for each of the 26 items that I am pulling from the
array but instead of creating a if/then/else for each or the 26 items I know
that it can be done with a loop just not quite shure how to do it. Again
thanks for any help.
------------------------------
Date: Wed, 14 Feb 2001 12:18:42 -0800
From: Terrence Monroe Brannon <terrence.brannon@oracle.com>
Subject: Re: regex experts
Message-Id: <3A8AE822.48CBF547@oracle.com>
"Géry" wrote:
> Hi
>
> say that I have the following regex:
> pattern:key1=0.16;key2=0.18;
>
> I want to check the validity of this pattern, the rules being
> - the first item must be a word (here: 'pattern')
therefore you want \w+ instead of simply \w as you have in your regexp
>
> - the second must be a colon
>
> then the sequence goes:
> - a key composed of anything (inc any funny character, figures, letters...)
then you want a character class which is defind by the use of square braces
instead of parentheses
>
> - the equal symbol
> - a decimal value
> - a semi-colon
>
> there is an indefined number of such a sequence thereafter.
>
> /^\w:(.=\d+\.\d+$;)+/
>
> I tried the regex above, as a validation match, but this does not work, any
> ideas?
ask for a complete solution on www.PERLMONK.org or read "Mastering Regular
Expressions" by Jefferey Freidl
>
>
> --
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> Géry
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
------------------------------
Date: Wed, 14 Feb 2001 20:22:25 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: regex experts
Message-Id: <x766idm2v2.fsf@home.sysarch.com>
>>>>> "TMB" == Terrence Monroe Brannon <terrence.brannon@oracle.com> writes:
TMB> ask for a complete solution on www.PERLMONK.org
why would he have to go there? he got several good and complete answers
here. plugging a site is one thing but claiming only that site would
give a complete answer is stupid.
uri
--
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, 14 Feb 2001 20:33:42 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: regex experts
Message-Id: <oaql8t059m5i90u4hp474pj1pjpc1k605r@4ax.com>
Géry wrote:
>say that I have the following regex:
>pattern:key1=0.16;key2=0.18;
>
>I want to check the validity of this pattern, the rules being
>- the first item must be a word (here: 'pattern')
>- the second must be a colon
>
>then the sequence goes:
>- a key composed of anything (inc any funny character, figures, letters...)
>- the equal symbol
>- a decimal value
>- a semi-colon
>
>there is an indefined number of such a sequence thereafter.
>
>/^\w:(.=\d+\.\d+$;)+/
>
>I tried the regex above, as a validation match, but this does not work, any
>ideas?
Basically, you forgot a few "+" signs.
/^\w+:(.+?=\d+\.?\d*;)+$/
Assuming "key3=3" is also ok.
Note that this does NOT extract the various fields. Annoying, IMO, but
this only does a global check. Can fields names also contin semicolons?
For extracting individual items, do something like:
if(/^(\w+):/g) {
$word = $1;
while(/(.+?)=(\d+\.?\d*);/g) {
push @pairs, [ $1, $2 ];
}
local $" = ', ';
print "<$word>: (@{[ map \"[ @$_ ]\", @pairs ]})\n";
}
--
Bart.
------------------------------
Date: 14 Feb 2001 16:36:47 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: regex experts
Message-Id: <u25x2bgw.fsf@pobox.com>
Uri Guttman <uri@sysarch.com> writes:
> >>>>> "TMB" == Terrence Monroe Brannon <terrence.brannon@oracle.com> writes:
>
> TMB> ask for a complete solution on www.PERLMONK.org
>
> why would he have to go there? he got several good and complete answers
> here. plugging a site is one thing but claiming only that site would
> give a complete answer is stupid.
Gee, does Uri have an axe to grind?
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Wed, 14 Feb 2001 22:11:25 +0100
From: "Carlo Vandecraen" <polaris@wanadoo.be>
Subject: Screen with - screen height
Message-Id: <96esac$nkb$1@buty.wanadoo.nl>
How can I check the screen width/height in a cgi script running on a
webserver written in Perl?
I want to check the screen width/height for getting statistics for the user
on the website?
Thanx, Carlo.
------------------------------
Date: 14 Feb 2001 16:17:57 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Screen with - screen height
Message-Id: <87lmr8nc2y.fsf@limey.hpcc.uh.edu>
>> On Wed, 14 Feb 2001 22:11:25 +0100,
>> "Carlo Vandecraen" <polaris@wanadoo.be> said:
Hi,
> How can I check the screen width/height in a cgi script
> running on a webserver written in Perl?
> I want to check the screen width/height for getting
> statistics for the user on the website?
What's the screen width and/or height of a bot from a
search engine site?
The question is meaningless. It can't be done.
hth
t
--
The avalanche has already started.
It is too late for the pebbles to vote.
------------------------------
Date: Wed, 14 Feb 2001 23:25:16 +0100
From: Bjoern Hoehrmann <bjoern@hoehrmann.de>
Subject: Re: Screen with - screen height
Message-Id: <3a9e059e.27934718@news.bjoern.hoehrmann.de>
* Carlo Vandecraen wrote in comp.lang.perl.misc:
Thanks for multiposting this into our german Perl newsgroup.
>How can I check the screen width/height in a cgi script running on a
>webserver written in Perl?
You can't.
>I want to check the screen width/height for getting statistics for the user
>on the website?
Maybe.
--
Björn Höhrmann ^ mailto:bjoern@hoehrmann.de ^ http://www.bjoernsworld.de
am Badedeich 7 ° Telefon: +49(0)4667/981028 ° http://bjoern.hoehrmann.de
25899 Dagebüll # PGP Pub. KeyID: 0xA4357E78 # http://learn.to/quote [!]e
~~ Sei Nicht Traurigen Herzens - Liebe Dein Leben ~~
------------------------------
Date: Wed, 14 Feb 2001 21:48:06 GMT
From: "Jeremia d." <jdb@ga.prestige.net>
Subject: Re: Screen with - screen height
Message-Id: <3A8A6145.DE1FE8D1@ga.prestige.net>
I do believe there is some java to do this. If i recollect the url I will post
it
Bjoern Hoehrmann wrote:
> * Carlo Vandecraen wrote in comp.lang.perl.misc:
>
> Thanks for multiposting this into our german Perl newsgroup.
>
> >How can I check the screen width/height in a cgi script running on a
> >webserver written in Perl?
>
> You can't.
>
> >I want to check the screen width/height for getting statistics for the user
> >on the website?
>
> Maybe.
> --
> Björn Höhrmann ^ mailto:bjoern@hoehrmann.de ^ http://www.bjoernsworld.de
> am Badedeich 7 ° Telefon: +49(0)4667/981028 ° http://bjoern.hoehrmann.de
> 25899 Dagebüll # PGP Pub. KeyID: 0xA4357E78 # http://learn.to/quote [!]e
> ~~ Sei Nicht Traurigen Herzens - Liebe Dein Leben ~~
--
A little experience often upsets a lot of theory.
------------------------------
Date: Wed, 14 Feb 2001 16:33:13 -0600
From: Jesse James Jensen <jesse@uchicago.edu>
Subject: Smart truncating of text
Message-Id: <3A8B07A9.B75D2C9E@uchicago.edu>
I have a bunch of strings containing English text that are from 15 to
400 characters long. If the text is too long, I want to truncate it and
put in an ellipsis that links to the whole thing. I don't, however,
want to truncate it if it's only a few words too long. Does this seem
like a respectable solution? Is there a good way to keep this from
choking on a well-placed 30-letter word?
my $ellipsis = qq{<A HREF="script?show=$file">...</A>};
if ( (length($text)) > 120 ) {
$text =~ s[^(.{90,100}?)\s.+][$1 $ellipsis];
}
------------------------------
Date: Wed, 14 Feb 2001 14:08:30 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: split Qustion
Message-Id: <3A8B01DE.D8C76782@stomp.stomp.tokyo>
Xming wrote:
> This is a small fragement I wrote:
> $string = 'title=something';
> $name = ${split('=', $string, 2)}[1];
> print $name;
> When I run the program, Perl does not complain anything,
> but actually I get nothing in $name.
You almost have the right syntax! However, almost
only counts in horseshoes, farts and atomic bombs.
Take a look at my test script below my signature
for some samples of syntax which will accomplish
your task, using syntax much like yours.
My use of [-1] grabs the last pseudo element
of a split regardless of how many items this
split contains. Be careful if something (ha! ha!)
is not where you think.
Godzilla!
--
Kira, Professional Poker Player
http://la.znet.com/~callgirl/android/poker.cgi
Kira, Professional Blackjack Player
http://la.znet.com/~callgirl/android/blakjack.cgi
--
TEST SCRIPT:
____________
#!perl
print "Content-type: text/plain\n\n";
$string = 'title=something';
## Method One - Grab 'something'
$name = (split /=/, $string)[-1];
print "Method One:\n $name";
## Method Two - Grab 'something'
$name = (split /=/, $string)[1];
print "\n\nMethod Two:\n $name";
## Method Three - Grab 'title'
$name = (split /=/, $string)[0];
print "\n\nMethod Three:\n $name";
exit;
PRINTED RESULTS:
________________
Method One:
something
Method Two:
something
Method Three:
title
------------------------------
Date: Wed, 14 Feb 2001 15:02:21 -0800
From: "terminalsplash" <shino_korah@yahoo.com>
Subject: Using Modules
Message-Id: <96f2pt$kfn@news.or.intel.com>
HI
I have a s1.pl script with the following code
#!/usr/bin/perl
package display;
sub screenprint()
{
print "hello world";
}
##########ends here
In another file i have s2.pl
#!/usr/bin/perl
require "s1.pl";
display::screenprint();
What is wrong here?
The compiler complains s1.pl didnot return a true value at s2.pl line 2.
Please help
------------------------------
Date: 14 Feb 2001 20:01:22 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: XS -- "array subscript is not an integer"
Message-Id: <86g0hht4od.fsf@jon_ericson.jpl.nasa.gov>
Jozxyqk <jfeuerst@eecs.tufts.edu> writes:
> Is there some global variable in the innards of XS that's called ax
> or something? It's no big deal; I can change the variable name;
> I just thought it was somewhat humorous, and it spurred my
> curiosity.
"Use the Source, Luke."
$ perl -ne 'print "$ARGV: $_" if /\bax\b/' *.h
XSUB.h: #define ST(off) PL_stack_base[ax + (off)]
XSUB.h: I32 ax = mark - PL_stack_base + 1; \
XSUB.h: #define XSprePUSH (sp = PL_stack_base + ax - 1)
XSUB.h: PL_stack_sp = PL_stack_base + ax + ((off) - 1); \
Jon
------------------------------
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 290
**************************************