[13713] in Perl-Users-Digest
Perl-Users Digest, Issue: 1123 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 19 23:05:42 1999
Date: Tue, 19 Oct 1999 20:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <940388708-v9-i1123@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 19 Oct 1999 Volume: 9 Number: 1123
Today's topics:
Re: 'last' behaviour differences between Perl4 & Perl5 (Eric Kuritzky)
Re: array (Abigail)
Beginner question - chomp <theebh@magix.com.sg>
dot operator weirdness <river@blacksky.net>
Re: dot operator weirdness <jeffp@crusoe.net>
Re: help with substrings <lr@hpl.hp.com>
Re: I pass by reference, but my array is unchanged. <arnej@fc.hp.com>
Re: localtime and The Epoch (Was: THANKS FOR ALL THE HE <lr@hpl.hp.com>
Matching an asterisk <mendlik@pop.dnvr.uswest.net>
Re: Matching an asterisk (Brett W. McCoy)
Re: Matching an asterisk (Abigail)
Re: newbie - counting data lines <r42317@email.sps.mot.com>
Re: Newbie regex question on quoting <lr@hpl.hp.com>
News Script? <slackware@home.com>
Re: News Script? (Abigail)
Re: Output html problem <lr@hpl.hp.com>
Re: Output html problem (Brett W. McCoy)
Re: parsewords <makkulka@cisco.com>
Re: Perl certification? (Martien Verbruggen)
Re: Perl certification? (Matthew Bafford)
Re: Perl certification? <lr@hpl.hp.com>
Re: Problem w/ PERL and SQL sabentle@hotmail.com
Re: Q: Truncate string length? (Charles DeRykus)
Re: REGEXP for SQL code replacement query. <email@arf.net>
Re: shifting a hash <lr@hpl.hp.com>
Re: Thread::Signal troubles mike_lottridge@mentorg.com
Re: Trimming down file names for all files in dir <makkulka@cisco.com>
Want to CGI for checking Domain name at Internic (Akkadate Siripongwattana)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 20 Oct 1999 02:06:51 GMT
From: kuritzky@pub-708c-22.math.berkeley.edu (Eric Kuritzky)
Subject: Re: 'last' behaviour differences between Perl4 & Perl5
Message-Id: <7uj83r$bpl$1@agate-ether.berkeley.edu>
In article <380CE9BD.FAD36486@netcom.ca>,
JBreukelman <jbreukelman@netcom.ca> wrote:
>Hello.
>
>I wrote a script a couple of years ago which uses a number of
>subroutines (30 or so). Most of these scripts will return 0 if they
>come across an error. To do this I used the following command;
>
>(return 0, last) if($Error);
>
[perl5 doesn't like this]
>
>Does anyone know of a way I can fix this without rewriting _every_
>subroutine?
Well, if you really wanted the subroutine to return zero to the
calling routine, then rewriting every subroutine will produce cleaner
code, since the 'last' wasn't ever necessary. (In fact, the line
return 0 if $Error;
is perfectly adequate.)
Note that
(return 0, last) if($Error);
is the same as
return(0, last) if($Error);
which is equivalent to
last if($Error);
since the return is never executed (the last transfers control out of
the block first). This may have been different in perl4. Is that
really what you wanted to do?
(Yes, you _can_ use last in a subroutine to exit a loop in the calling
routine... I'm not sure I wanted to know that.)
--Eric Kuritzky
print "Just a wannabe perl hacker\n";
------------------------------
Date: 19 Oct 1999 20:56:43 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: array
Message-Id: <slrn80q8ab.fji.abigail@alexandra.delanet.com>
Mike Salter (msalter@bestweb.net) wrote on MMCCXL September MCMXCIII in
<URL:news:Pine.BSF.4.05.9910191603360.29350-100000@monet.bestweb.net>:
==
== On 19 Oct 1999, GiN wrote:
==
== G>I have an array: @arr = ("weeh", "waah", "wuuh", "wiih", "wooh");
== G>
== G>what is the simpliest way to remove "wuuh" from @arr?
== G>
== G>i am currently using foreach etc..
==
== @ar = map {$_ if !/wuuh/} @ar;
That would delete "furffu wuuhbleh" as well. People always seem to use
regexes in grep, when eq is way better (cargo cult programming?). The
use of map in this case is even more silly.
@ar = grep {$_ ne "wuuh"} @ar;
Abigail
--
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Wed, 20 Oct 1999 10:54:30 +0800
From: Boon Hoo <theebh@magix.com.sg>
Subject: Beginner question - chomp
Message-Id: <380D2EE6.4BDEA0BF@magix.com.sg>
Hi,
I understand that chomp removes newline from the end of a string. I was
trying it one day to format some HTML files(grab each line, remove
newline, and write it to a text-file), when I found out that if I had
earlier "ftp" the files using binary mode, chomp doesn't seem to work -
i saw many ^M control characters instead in my output file. What is the
correct way to remove newlines from textfiles transferred through binary
mode?
TIA,
Jonathan
------------------------------
Date: 19 Oct 1999 19:14:36 PDT
From: Ernest Rojem <river@blacksky.net>
Subject: dot operator weirdness
Message-Id: <380D23CF.72FD7C65@blacksky.net>
This problem occasionally crops up for me while writing code, but I've
never been able to figure out why, so I figured I'd ask here.
Basically, the following line of code is giving me strange results:
my $buf2 = "START " . $buf . "END\n";
When I print $buf2, what I see is the following:
ENDRT <contents of $buf>
Whatever is the last string to be concatenated into the new string,
seems to be overwriting (partially), the first one. I can lengthen or
shorten the final string and the same thing happens. If the length of
$buf exceeds a certain length though, it will print fine. The only way
it seems to be reliable is if I just enclose the entire thing in double
quotes.
It's not a critical issue, just an annoying one. Any insight someone
can shed onto this for me would be greatly appreciated.
Thanks,
Ernest
------------------------------
Date: Tue, 19 Oct 1999 22:36:31 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: dot operator weirdness
Message-Id: <Pine.GSO.4.10.9910192235082.21020-100000@crusoe.crusoe.net>
[posted & mailed]
On Oct 19, Ernest Rojem blah blah blah:
> my $buf2 = "START " . $buf . "END\n";
>
> ENDRT <contents of $buf>
$buf ends with a carriage return. That means your data looks like this:
START jfdskjflkdsjflkdjlkfjsdljf\r
END<-----------------------------
ENDRT jfdskjflkdsjflkdjlkfjsdljf
--
MIDN 4/C PINYAN, USNR, NROTCURPI
jeff pinyan japhy@pobox.com
perl stuff japhy+perl@pobox.com
CPAN ID: PINYAN http://www.perl.com/CPAN/authors/id/P/PI/PINYAN
------------------------------
Date: Tue, 19 Oct 1999 17:20:23 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: help with substrings
Message-Id: <MPG.1276aaa2940bb40998a0bf@nntp.hpl.hp.com>
In article <7uiqde$rt$1@nnrp1.deja.com> on Tue, 19 Oct 1999 22:13:10
GMT, Johannes <jspangen@my-deja.com> says...
> In article <380B817A.1045A3F1@unity.ncsu.edu>,
> kpmonroe@unity.ncsu.edu wrote:
...
> >
> > open(NEW, "< /path/to/file.txt") or die "Can't open file.txt: $!";
> >
> > @data = <NEW>;
> This reads only the first line in the first element of @data,
Heck, no, Johannes. It reads the entire file into @data.
From perlop:
If a <FILEHANDLE> is used in a context that is looking for a list, a
list consisting of all the input lines is returned, one line per list
element. It's easy to make a LARGE data space this way, so use with
care.
> you can directly use a simple $line eg.
That is usually better, for the reason given above.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 19 Oct 1999 16:44:53 -0600
From: Arne Jamtgaard <arnej@fc.hp.com>
Subject: Re: I pass by reference, but my array is unchanged.
Message-Id: <380CF464.34F@fc.hp.com>
Jeff Moser wrote:
>
> # I want to pass an array reference to a gah() and have gah()
> # make changes to the array. Since the array is being passed
> # by reference, I expect that any changes made in gah() will
> # actually occur to @blorg in subroutine blah(). That's not
> # what is happening though.
>
> # The output of this program is
> # a
> # b
> # c
> # a
> # b
> # c
>
> # I expected the output of this program to be:
> # a
> # b
> # c
> # 0
> # 1
> # 2
>
> #!/usr/bin/perl -w
>
> use strict;
>
> blah();
> exit 0;
>
> sub blah()
> {
> my @blorg = ("a","b","c");
> gah(\@blorg);
>
> my $i;
> for $i (0 .. $#blorg){
> print "$blorg[$i]\n";
> }
> }
>
> sub gah()
> {
> my $foo = shift;
So $foo is a reference to an array. Good...
> my @arr = @$foo;
Here you set one array equal to another. I don't think this
is doing what you think it is.
After that, you just mess with the local array @arr. Of course
nothing will make its way back to the calling routine.
> my $i;
This is actually unnecessary, as the default for a for-index is
to keep it local to the for-loop.
> for $i ( 0 .. $#arr ){
> print "$arr[$i]\n";
> $arr[$i] = $i;
> }
Try this instead:
for $i ( 0 .. $#{$foo} ){
print "$$foo[$i]\n";
$$foo[$i] = $i;
}
> }
>
> # Thanks a lot for the help.
I hope that helps. It worked when I prototyped it.
Arne
--
"If you take cranberries and stew them like applesauce, they
taste much more like prunes than rhubarb does." -Groucho Marx
------------------------------
Date: Tue, 19 Oct 1999 07:52:46 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: localtime and The Epoch (Was: THANKS FOR ALL THE HELP)
Message-Id: <MPG.12762592dd3b801698a0bb@nntp.hpl.hp.com>
In article <2OWO3.5$mZ1.510@vic.nntp.telstra.net> on Tue, 19 Oct 1999
18:55:18 +0930, Wyzelli <wyzelli@yahoo.com> says...
> Craig Berry <cberry@cinenet.net> wrote in message
> news:s0l5n6snr0186@corp.supernews.com...
> > kstephan (kstephan@my-deja.com) wrote:
> > : Reading through the threads, I noticed the line
> > :
> > : $thisyear = $year + 1900;
> > :
> > : What happens on 1 January 2000???
...
> localtime et al returns the number of years since the epoch, to which we add
> 1900 to ensure y2k accuracy.
'The Epoch' is an arbitrary event that is defined differently by various
operating systems. The localtime() function returns years since 1900.
This is the same on all systems.
> Are there many occasions are there where the number of years since the epoch
> is actually used? Particularly outside the current century?
No, but this question is irrelevant.
> Would it be terribly difficult for localtime to return the number of years
> since the epoch + 1900?
It would be a different specification, hence a different function.
> Assuming localtime returned 'years since epoch plus 1900' would not those
> cases of 'years since epoch' then be adequately served by 'localtime - 1900'
No.
> Not proposing any changes (compliance, old scripts etc) just wondering out
> loud.
It's not clear to me what you are wondering about.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 19 Oct 1999 19:54:36 -0600
From: Adam Mendlik <mendlik@pop.dnvr.uswest.net>
Subject: Matching an asterisk
Message-Id: <380D20DC.831E3A9B@pop.dnvr.uswest.net>
I can't seem to write the code that will match if and only
if an asterisk appears
as the last character in a string. I have tried several
variations:
($text =~ /$*/) #The obvious first try
($text =~ /$\x2A/); #Match the hex for '*'
($text =~ /$\052/); #Match the octal for '*'
($text =~ /$\Q*\E/); #Disable metacharacters
($text =~ /$$asterisk/); #Define a variable for '*'
None of these seem to work. Does any one have any
suggestions?
Please e-mail to mendlik@uswest.net
-Thanks
------------------------------
Date: Wed, 20 Oct 1999 02:39:06 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: Matching an asterisk
Message-Id: <slrn80qb2o.frt.bmccoy@moebius.foiservices.com>
Also Sprach Adam Mendlik <mendlik@pop.dnvr.uswest.net>:
>I can't seem to write the code that will match if and only
>if an asterisk appears
>as the last character in a string. I have tried several
>variations:
>
> ($text =~ /$*/) #The obvious first try
> ($text =~ /$\x2A/); #Match the hex for '*'
> ($text =~ /$\052/); #Match the octal for '*'
> ($text =~ /$\Q*\E/); #Disable metacharacters
> ($text =~ /$$asterisk/); #Define a variable for '*'
The last character in a a string?
text =~ /.*\*$/;
You have your $ in the wrong place. ^ at the beginning, $ at the end.
You also need to escape it since * means match the previous atom 0 or more
times. .* means match any character 0 or more times.
--
Brett W. McCoy bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek) http://www.foiservices.com
FOI Services, Inc./DIOGENES 301-975-0110
---------------------------------------------------------------------------
------------------------------
Date: 19 Oct 1999 21:51:18 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Matching an asterisk
Message-Id: <slrn80qbgl.fji.abigail@alexandra.delanet.com>
Adam Mendlik (mendlik@pop.dnvr.uswest.net) wrote on MMCCXLI September
MCMXCIII in <URL:news:380D20DC.831E3A9B@pop.dnvr.uswest.net>:
** I can't seem to write the code that will match if and only
** if an asterisk appears
** as the last character in a string. I have tried several
** variations:
**
** ($text =~ /$*/) #The obvious first try
** ($text =~ /$\x2A/); #Match the hex for '*'
** ($text =~ /$\052/); #Match the octal for '*'
** ($text =~ /$\Q*\E/); #Disable metacharacters
** ($text =~ /$$asterisk/); #Define a variable for '*'
**
** None of these seem to work. Does any one have any
** suggestions?
$ matches the end of the string, or the end of the string before a
newline. Since * isn't a newline, how do you expect anything to
be after the end of the string?
You only want to match one character on a specific place. No need to use
a regex for that.
if (substr ($text, -1) eq '*') { ... }
Alternatively, use rindex:
if (rindex ($text => '*') == length ($text) - 1) { ... }
If, for some reason, you insist on using a regex, then it's simple.
You first want to see the *, then the end of the string. Since $ can
match before a newline, and you don't want to match "*\n", use \z:
if ($text =~ /\*\z/) { ... }
Abigail
--
sub A::TIESCALAR{bless\my$x=>A};package B;@q=qw/Hacker Another
Perl Just/;use overload'""'=>sub{pop @q};sub A::FETCH{bless\my
$y=>B}; tie my $shoe => 'A';print "$shoe $shoe $shoe $shoe\n";
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Wed, 20 Oct 1999 08:52:12 +0800
From: Noira Hadi <r42317@email.sps.mot.com>
To: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: newbie - counting data lines
Message-Id: <380D123C.5F2E61B0@email.sps.mot.com>
Alex,
Thanks for the sample script.
------------------------------
Date: Tue, 19 Oct 1999 17:30:24 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Newbie regex question on quoting
Message-Id: <MPG.1276acf775d71d3b98a0c0@nntp.hpl.hp.com>
In article <36452.5826617977BAjustooltries@4.22.39.85> on 19 Oct 1999
21:02:10 GMT, Gordon <nospam@today.com> says...
> jhagerty@my-deja.com wrote in
> <7uiag1$l24$1@nnrp1.deja.com>:
...
> >$string =~ s/\*//gs;
> >
> >However, this is matching the entire
> >string and leaving me nothing.
> >
> >Help?
>
> No idea, works just fine for me:)
Obviously. But worth a couple of comments:
The /s suffix does nothing, because there are no '.' metacharacters in
the regex. See perlre.
The thing could/should be done cleaner and faster using tr():
$string =~ tr/*//d;
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 20 Oct 1999 02:10:39 GMT
From: "Slackware Genius" <slackware@home.com>
Subject: News Script?
Message-Id: <zw9P3.2086$3_5.74937@news2.rdc1.on.home.com>
Hi Everyone,
I am relatively new to Perl, and am looking to create a web-based form for
posting news updates to my site. What I am looking to do is have it so you
can enter the date, and some comments then have it submitted to the webpage
in a specific font/color/etc ..
ie :
Date: (input date)
Comments: (input comments)
SUBMIT <-- upon clicking will update my page(s) with the news in the proper
format ....
ANY suggestions/help/links would be greatly appreciated. Thanks everyone.
--
Truly,
Christopher J. Perry
---------------------------------------
http://www.cperry.com
cperry@cperry.com
---------------------------------------
------------------------------
Date: 19 Oct 1999 21:53:32 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: News Script?
Message-Id: <slrn80qbks.fji.abigail@alexandra.delanet.com>
Slackware Genius (slackware@home.com) wrote on MMCCXLI September MCMXCIII
in <URL:news:zw9P3.2086$3_5.74937@news2.rdc1.on.home.com>:
:: Hi Everyone,
::
:: I am relatively new to Perl, and am looking to create a web-based form for
:: posting news updates to my site. What I am looking to do is have it so you
:: can enter the date, and some comments then have it submitted to the webpage
:: in a specific font/color/etc ..
::
:: ie :
::
:: Date: (input date)
:: Comments: (input comments)
:: SUBMIT <-- upon clicking will update my page(s) with the news in the proper
:: format ....
::
:: ANY suggestions/help/links would be greatly appreciated. Thanks everyone.
Well, what have you done so far, and where do you get stuck?
Or haven't you done anything yet? In that case, I suggest starting with
'man vi'.
Abigail
--
perl -wle 'print "Prime" if (0 x shift) !~ m 0^\0?$|^(\0\0+?)\1+$0'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Tue, 19 Oct 1999 17:36:45 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Output html problem
Message-Id: <MPG.1276ae7ae117d25e98a0c2@nntp.hpl.hp.com>
In article <s0pu63gtr016@corp.supernews.com> on Tue, 19 Oct 1999
16:05:08 -0700, First Look Computer <1stlook@axion.net> says...
> Hi I would be the ultimate newbie : Enough said!!
You did well by finding this newsgroup, but you would do better first to
find and read the rich Perl documentation on your local hard disk.
> I'm trying to get an output from a print statement that would allow me to
> format text in proper html. However I don't know how to get around the
> double quotes issue in the font formatting. Can anyone help???
>
> print "<H3><font color="#004080" size="7">Some Text Like This</h3>"
There are several ways. Read the section "Quote and Quote-like
Operators" in the 'perlop' document that comes with your Perl
installation.
> Thanks please respond to charden@home.com
If that's what you wanted, you should have set the 'Reply-To:' header.
I'm too lazy to type it in instead of what you posted from.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 20 Oct 1999 02:41:36 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: Output html problem
Message-Id: <slrn80qb7e.frt.bmccoy@moebius.foiservices.com>
Also Sprach First Look Computer <1stlook@axion.net>:
>Hi I would be the ultimate newbie : Enough said!!
>
>I'm trying to get an output from a print statement that would allow me to
>format text in proper html. However I don't know how to get around the
>double quotes issue in the font formatting. Can anyone help???
>
>print "<H3><font color="#004080" size="7">Some Text Like This</h3>"
Time to hit the documentation, dude! Look for the qq// operator. The
rest is left as an exercise for the reader.
--
Brett W. McCoy bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek) http://www.foiservices.com
FOI Services, Inc./DIOGENES 301-975-0110
---------------------------------------------------------------------------
------------------------------
Date: Tue, 19 Oct 1999 18:03:44 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: parsewords
Message-Id: <380D14F0.312FF7FD@cisco.com>
Etruscan wrote:
> The end result should look like
>
> 0041-7332 000035250 07019924761
Actually it should look like
0041-7332 0000353250 07019924761
> Please let me know what I should look up (new to perl).
look up perldoc -f split.
see some sample code below.
--
while (<DATA>)
{
@F= split ( ' ', $_);
print join ' ', ( $F[0], '0'x(10-length $F[1]) . $F[1] , $F[2].$F[3] ) ,
"\n" ;
}
__DATA__
0041-7332 353250 070199 24761
0041-7332 353854 070199 12479
--
------------------------------
Date: Wed, 20 Oct 1999 00:19:57 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl certification?
Message-Id: <NU7P3.184$kk1.2991@nsw.nnrp.telstra.net>
On Tue, 19 Oct 1999 19:13:46 GMT,
bing-du@tamu.edu <bing-du@tamu.edu> wrote:
> Hello all...
>
> Is there any certification exam for Perl?
Answer the following questions:
1 -
a) Where is the perl documentation?
b) Does it include frequently asked questions?
2 -
a) Does pack/unpack scare you?
b) When was the last time you used a Schwartzian transform (modified or
not)?
3 -
a) When you sleep, do you dream of regular expressions?
b) When you're awake, do you dream of regular expressions?
c) When you sleep, do you dream of a desirable person of the sex that
you're most interested in?
4 -
a) Do you tell your collegues and boss that that Java crap is
unstable, unreliable, hardly useful, and not nearly as crossplatform
as the hype tells you?
b) Do you tell your boss and your collegues that Perl could do the
same job 100 times faster and more reliable?
i) Do you re-use your old C code by writing XS interfaces to it?
If you answered 'Duh' or 'Blue' to any of the above questions, you can
have a perl certificate. But first you must answer this:
5 -
What do you think is the use of a Perl certification?
a) It'll fit neatly with my Microsoft Access and Excel certificates
b) It'll impress my Boss
c) It'll look nice on my resume
d) It'll impress other Perl programmers
If you believe that c) or d) are true, then I would think again. I
normally see it as a negative thing when I read a resume that includes
'certification' thingies. The applicants will have to work harder to
get the job than someone who does not have that sort of crud in
her/his resume.
Oh, what the hell.. I'm feeling generous today. You can have one.
-----------------------------------------------------------------------
--- Perl Certificate ---
The unofficial Perl Certification Institute hereby declares that
bing-du@tamu.edu <bing-du@tamu.edu>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Answered 'Duh' at least once, and 'Blue' no less than three times
to the highly selective questions posed in the Perl Certification
Programme.
We hereby declare
bing-du@tamu.edu
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
certified.
Signed:
ScribbleScribble
-----------------------------------------------------------------------
Martien
--
Martien Verbruggen |
Interactive Media Division | This matter is best disposed of from
Commercial Dynamics Pty. Ltd. | a great height, over water.
NSW, Australia |
------------------------------
Date: Wed, 20 Oct 1999 01:42:01 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Perl certification?
Message-Id: <slrn80q5fb.19n.*@dragons.duesouth.net>
'Perl certification' posted by Martien Verbruggen on Wednesday, October
20th, @00:19:57 from the 'but-ma-it-looks-nice' dept:
: a) Does pack/unpack scare you?
No, but after at least 2 years, I still can't use them without
consulting the documentation to find out if I need pack or unpack.
: b) When was the last time you used a Schwartzian transform (modified or
: not)?
This message is posted with A ST.
: Martien Verbruggen |
--Matthew
------------------------------
Date: Tue, 19 Oct 1999 17:32:55 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Perl certification?
Message-Id: <MPG.1276ad95571d0ab198a0c1@nntp.hpl.hp.com>
In article <7uifsu$p2h$1@nnrp1.deja.com> on Tue, 19 Oct 1999 19:13:46
GMT, bing-du@tamu.edu <bing-du@tamu.edu> says...
>
> Is there any certification exam for Perl?
You can get a useless certificate from Tekmetrics for free, and worth
every penny.
The certificate I really value cost me $3.00 at the Perl Conference 2.0:
Certifiable Perl Pornographer
Now that is worth something!
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 19 Oct 1999 23:59:08 GMT
From: sabentle@hotmail.com
Subject: Re: Problem w/ PERL and SQL
Message-Id: <7uj0k6$4vl$1@nnrp1.deja.com>
In article <ZtIO3.14464$E_1.853723@typ11.nn.bcandid.com>,
kragen@dnaco.net (Kragen Sitaker) wrote:
> In article <380b6397.2603734@news.vnet.net>, <mirak63@yahoo.com>
wrote:
> >I know this may not be the right forum for this question
> >and if it isn't please direct me to a NG that is better suited...
> >
> >When I push a scaler in to a SQL database (SQL 7)
> >the data shows up OK. However, when I retrieve the same
> >data using PERL, the data is truncated to 255 characters.
> >
> >Does anyone have any ideas as to why?
>
> Many databases have arbitrary limits on the size of data you can store
> in them. (It's called the "80-column mind" syndrome.) Some SQL
> interfaces also have arbitrary limits on the size of data that can be
> passed each way. You should try to figure out whether it's sending
the
> data to the database, storing the data in the database, or retrieving
> the data from the database that causes the problem.
>
> It sounds like you're sure it's the third, because you've retrieved
the
> data by other means. Are you linking via ODBC, or native DBD, or
what?
> --
> <kragen@pobox.com> Kragen Sitaker
<http://www.pobox.com/~kragen/>
> Sun Oct 17 1999
> 23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
> <URL:http://www.pobox.com/~kragen/bubble.html>
>
Yes, I am using ODBC (more specifically, the Win32::ODBC module) to
connect to my MS SQL Server via perl. The original data is coming from a
form that I am parsing out and sending to the DB. I am having the
problem with a large text area (field is set to 1000 chars max in the
db). The data goes into the db in full, but when I retreive it to
populate a new form, it gets truncated somewhere along the way.
Susan Bentley (sabentle@hotmail.com)
ps--this msg orig. posted by mirak63@yahoo.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 20 Oct 1999 00:06:56 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Q: Truncate string length?
Message-Id: <FJvKBK.F8L@news.boeing.com>
In article <7uds59$ljn$1@nnrp1.deja.com>, <emlyn_a@my-deja.com> wrote:
>I understand truncating files, but how does one truncate a string? To
>limit the length of a field to, say, 500 characters?
>
>I started with;
>
>if (length($TheField) > 500){
>length($TheField) = what goes here?
>}
>
>But length($TheField) just is a number like 538 - but what can I do with
>that?
>
>Do I need to count from 0 to 500 the number of characters in the string
>and throw out the rest, or is there a way to just slice off anything
>occurring past 500 without counting each one, like:
>
>substr($TheField, 0, 500) don't know what goes next
>
I'm suprised that C<s> hasn't been mentioned:
$TheField =~ s/(.{500}).*/$1/;
--
Charles DeRykus
------------------------------
Date: Tue, 19 Oct 1999 21:45:58 -0500
From: test <email@arf.net>
Subject: Re: REGEXP for SQL code replacement query.
Message-Id: <uQ9P3.775$j4.50324@news.uswest.net>
Web Research wrote:
>
[ snip ]
> Problems...
>
> 1) There is not always a space before 'THING WHERE' .. it can appear as
> 'WHERE (no space after single quote) or...
> '(sp)WHERE' one space before quote.
>
> My first pass...
>
> $pagelines =~ s/(\;.*?)(SELECT)(.*?)(\'||\s*)WHERE(.*?sIsolation.*?\;)/$1\'
> \+ DM1\.TriDef1\.sNoLock \+ \'WHERE$2/sg;
>
To fix the problems below I think you just need to change the code
before the WHERE
from: (\'||\s*)WHERE
to: (\'\s*||\s+)WHERE
This will handle a \' with or without space and the \s+ handles just
space.
>
> This got alot of them.. however we really screwed up with the case of 'WHERE
> verses ' WHERE (backups.. of course!) We should probably test for...
>
> 'WHERE - quote no space
> ' WHERE - quote with space
> WHERE - just space
>
> What might I do here to and an OR situation and conditional replacement on
> that OR to get the overall code I am looking for?
>
> Also.. how did I do for my first 'more difficult' regexp?
>
Looks great!
> Rusman
------------------------------
Date: Tue, 19 Oct 1999 18:27:06 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: shifting a hash
Message-Id: <MPG.1276ba44eac1458598a0c3@nntp.hpl.hp.com>
In article <x3ypuybbjcn.fsf@tigre.matrox.com> on Tue, 19 Oct 1999
08:55:37 -0400, Ala Qumsieh <aqumsieh@matrox.com> says...
> Uri Guttman <uri@sysarch.com> writes:
> > >>>>> "KS" == Kragen Sitaker <kragen@dnaco.net> writes:
> > KS> According to Larry and Uri's paper, reverse sort @x is faster than sort
> > KS> {$b cmp $a} @x for large @x, by a factor of two or three, I think.
This is true. See below.
> That's interesting, but certainly counter-intuitive. I would assume
> that the default sort would actually insert a { $a cmp $b } block and
> then do the sort. In this case, I don't see any reason why this should
> be any faster that specifying { $b cmp $a } as your sort() block. But
> I don't know enough of perlguts to conclude for sure, and it seems
> logical to optimize this case to do a C strcmp() rather than resort to
> calling the Perl block.
You have to do that yourself, by not having a Perl block to call.
> But, my benchmarks (on 5.005_03) proved that indeed a
>
> sort { $b cmp $a} @a
>
> is faster than
>
> reverse sort @a;
Sorry, they really don't prove that at all.
> The benchmark is attached below. I am sure I am doing something wrong
> with it. Please correct me if you figure it out.
Yes. See below.
...
> Here's the benchmark:
>
> Benchmark: timing 10000 iterations of by_flipping_ab, by_reverse, overhead...
> by_flipping_ab: 19 wallclock secs (18.59 usr + 0.00 sys = 18.59 CPU)
> by_reverse: 22 wallclock secs (21.10 usr + 0.00 sys = 21.10 CPU)
> overhead: 12 wallclock secs ( 9.69 usr + 0.00 sys = 9.69 CPU)
<SNIP> of benchmark code -- look at the previous posts.
Here is your original benchmark, run on my machine:
Benchmark: timing 10000 iterations of by_flipping_ab, by_reverse,
overhead...
by_flipping_ab: 20 wallclock secs (19.95 usr + 0.00 sys = 19.95 CPU)
by_reverse: 23 wallclock secs (22.20 usr + 0.00 sys = 22.20 CPU)
overhead: 10 wallclock secs (10.45 usr + 0.00 sys = 10.45 CPU)
So on the surface, one would think you are right. However, you have not
done anything with the result of the function. Here is the better test:
sub overhead {
my @a = ('a' .. 'z', 'aa .. az');
fisher_yates_shuffle(\@a);
my @b = @a;
}
sub by_flipping_ab {
my @a = ('a' .. 'z', 'aa' .. 'az');
fisher_yates_shuffle(\@a);
my @b = sort { $b cmp $a } @a;
}
sub by_reverse {
my @a = ('a' .. 'z', 'aa' .. 'az');
fisher_yates_shuffle(\@a);
my @b = reverse sort @a;
}
Benchmark: timing 10000 iterations of by_flipping_ab, by_reverse,
overhead...
by_flipping_ab: 39 wallclock secs (29.20 usr + 0.00 sys = 29.20 CPU)
by_reverse: 30 wallclock secs (24.66 usr + 0.00 sys = 24.66 CPU)
overhead: 12 wallclock secs (11.36 usr + 0.00 sys = 11.36 CPU)
Now, let's get *serious* about large data sets -- I change your array to
my @a = ('aaa' .. 'zzz');
and the number of iterations to 100.
Benchmark: timing 100 iterations of by_flipping_ab, by_reverse,
overhead...
by_flipping_ab: 150 wallclock secs (147.92 usr + 0.75 sys = 148.67 CPU)
by_reverse: 116 wallclock secs (115.17 usr + 0.84 sys = 116.02 CPU)
overhead: 94 wallclock secs ( 92.17 usr + 0.94 sys = 93.11 CPU)
So 'by_reverse' takes 23 sec to sort, while 'by_flipping_ab' takes 56
sec to sort. 56 / 23 is 2.4 times faster. 'Nuff said?
Some final notes on these benchmarks:
I found that to get useful results, it helps to preallocate the arrays
statically outside of the benchmarks. Then the storage-allocation
overhead goes away.
Arrays of one- or two-character strings don't really test the software
realistically.
Benchmarking is tough. I really *should* get the benchmarks used for
our paper presentable, and post them on my web site as promised in June.
RSN. :-(
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 19 Oct 1999 23:03:03 GMT
From: mike_lottridge@mentorg.com
Subject: Re: Thread::Signal troubles
Message-Id: <7uitb0$2ru$1@nnrp1.deja.com>
In article <7svkdb$a25$1@news.ox.ac.uk>,
mbeattie@sable.ox.ac.uk (Malcolm Beattie) wrote:
<<snipped>>
you get a warning when building perl with threading support that its not
recommended for production use - is this an outdated message? I assume
you need to rebuild perl with threading to use this module?
> On the contrary, the Thread::Signal module exists precisely in order
to
> make signal handlers free to do pretty much anything they want. The
> catch is that your signal handlers run in a different thread and so
> some of the games you might like to play, with SIGCHLD signals for
> example, don't have quite the affect you might otherwise expect.
>
> --Malcolm
>
> --
> Malcolm Beattie <mbeattie@sable.ox.ac.uk>
> Oxford University Computing Services
> "I permitted that as a demonstration of futility" --Grey Roger
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 19 Oct 1999 18:10:17 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Trimming down file names for all files in dir
Message-Id: <380D1679.1D4A23C5@cisco.com>
Dutch McElvy wrote:
> Would like to extract for example $2 and $4 but do this for each file in the
> directory.
perldoc -f readir
perdoc -f rename
opendir(DIR, $your_dir ) || die "can't opendir $some_dir: $!";
@filenames = readdir(DIR);
closedir DIR;
foreach ( @filenames )
{
my $newname = $_ ; # actually you will operate on $_ before assigning
to $newname
rename ( $_, $newname ); #check return status
}
--
------------------------------
Date: Wed, 20 Oct 1999 09:50:19 +0700
From: akkadate.s@tfb.co.th (Akkadate Siripongwattana)
Subject: Want to CGI for checking Domain name at Internic
Message-Id: <MPG.1277a0b64016cab1989683@news.loxinfo.co.th>
I creating my homepage.
I want have from for checking Domain name.
How can I do it?
Please,Help
------------------------------
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 V9 Issue 1123
**************************************