[13237] in Perl-Users-Digest
Perl-Users Digest, Issue: 647 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 26 00:07:50 1999
Date: Wed, 25 Aug 1999 21:05:09 -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, 25 Aug 1999 Volume: 9 Number: 647
Today's topics:
Re: #as 1st Character in Report, <TAB> between fields, <rick.delaney@home.com>
Re: $5 for 1st perl script that prints out most common (brian d foy)
Converting a decimal number to hex <apollock@bit.net.au>
Re: desperate NEWBIE (Abigail)
help on using DBI <leenick@interchange.ubc.ca>
Re: HELP Please!! with a script to query newsgroups <blair_chesnut@ncsu.edu>
Re: How to Address an email using CGI (David Efflandt)
How to Detect that a Process is running already <baghera@mindspring.net>
Re: HTML Tools for perl? (Eric Bohlman)
Jenda's gender [was: newbi: Registry Help under NT] (elephant)
Re: killing my child (Charles DeRykus)
Re: mirror.pl on OS/2 Question (Abigail)
Re: newbie: need help,LEARNING FROM A BOOK <madebeer@igc.apc.org>
Re: perl port for win32 problem (elephant)
Re: Perl without C compiler. <kristian@netscape.net>
Re: Perl without C compiler. <kristian@netscape.com>
Programming Question.. List/Email functions (Delarock)
Re: Programming Question.. List/Email functions (Martien Verbruggen)
redirecting outputs <dcs@NOSPAM.csua.berkeley.edu>
Re: redirecting outputs (Bill Moseley)
Re: Regex Question (J. Moreno)
Re: Server Side Include Parameters (Abigail)
Re: Spawn a Web process (Abigail)
SSN format <blair_chesnut@ncsu.edu>
Re: SSN format (Larry Rosler)
Re: SSN format (Larry Rosler)
Re: SSN format (Abigail)
Strange -e behaviour.. (Alex Krohn)
Re: The extent of double-quotish interpolation (Ilya Zakharevich)
Re: Want to try perl-cgi on UNIX (David Efflandt)
Re: YAREQ (yet another regexp question) (Bill Moseley)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 26 Aug 1999 02:49:27 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: #as 1st Character in Report, <TAB> between fields, and Current Date at TOP
Message-Id: <37C4AB20.F431F4D8@home.com>
[posted & mailed]
Tomatocans wrote:
>
> None of the books I am referencing including the
> Perl Cookbook state:
> 1)How the first character of output can be # without
> the line being interpretted as a comment line.
You do this the same way you would get a '^' or '@', as documented in
perlform.
format STDOUT =
@This is not a comment
'#'
.
> 2)How to put a timestamp for the date to display
> automatically on the report
$date = localtime;
format STDOUT_TOP =
Run on @<<<<<<<<<<<<<<<<<<
$date
.
> 3)How to set the information to tab between fields.
You can't really get tabs in formats but I'm not sure why you'd want
to. The whole point of format is to make fixed width reports. Maybe
you'd be better off using printf.
See what the Warnings section of perlform has to say about whitespace
characters.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Wed, 25 Aug 1999 20:09:04 -0700
From: brian@pm.org (brian d foy)
Subject: Re: $5 for 1st perl script that prints out most common phrases
Message-Id: <brian-2508992009050001@55.san-francisco-13-14rs.ca.dial-access.att.net>
In article <7ppqjk$1gj$4@dailyplanet.wam.umd.edu>, theoblit@wam.umd.edu (Dr. Jason A. Taylor) wrote:
>I am looking for a cgi/perl/C/sed script/program that outputs the most
>common phrases in a file. Doing this for single words is very easy
>using sed and sort. However, I want something that does this for
>phrases composed of one or more words.
the travesty.pl program in the pink camel would have done this and
you could have saved $5.
--
brian d foy
------------------------------
Date: Thu, 26 Aug 1999 13:05:24 +1000
From: "Andrew Pollock" <apollock@bit.net.au>
Subject: Converting a decimal number to hex
Message-Id: <37c4aeee@news.ausmail.com>
Hi,
I need to convert a decimal number to hex (and store the string
representation of the hex number in a variable).
I can go
printf("%x", time)
but that doesn't store it anywhere and I'm trying to go
pack("h*", time)
but that isn't working properly as far as I can tell.
Can someone help me please? I've never been able to get my head around
pack...
Thanks in advance
Andrew
------------------------------
Date: 25 Aug 1999 22:30:55 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: desperate NEWBIE
Message-Id: <slrn7s9d94.lhu.abigail@alexandra.delanet.com>
Ilya (ilya@speakeasy.org) wrote on MMCLXXXV September MCMXCIII in
<URL:news:rs8un2ssh9765@corp.supernews.com>:
<> Jonathan Stowe <gellyfish@gellyfish.com> wrote:
<> > GiN <wablief@freemail.nl> wrote:
<> >> the following sub should return 1 when port is open and 0 when port is
<> >> closed or if something times out ( port filtered).
<> >> but it won't work!!!
<> >> who can help me out??
<> >>
<>
<> > You have already posted this question.
<>
<> If he asking again, don't you think it is fairly obvious he is not satisfied
<> with the first response, if any?
No. Otherwise he would reply to the answer and ask further questions.
Abigail
--
perl -wlpe '}$_=$.;{' file # Count the number of lines.
-----------== 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, 25 Aug 1999 20:52:55 -0700
From: Nick Lee <leenick@interchange.ubc.ca>
Subject: help on using DBI
Message-Id: <37C4BA17.BB41C004@interchange.ubc.ca>
Hi,
I have the following code:
---------------------------
#! /usr/bin/perl -w
use DBI;
$dbName = 'DBI:ODBC:MyDatabase';
$dbUsername = 'admin';
$dbPassword = '';
$dbh = DBI->connect($dbName, $dbUsername, $dbPassword);
---------------------------
But when I execute it, I got the following error message:
---------------------------
install_driver(ODBC) failed: Can't locate DBD/ODBC.pm in @INC at line
3. Perhaps the DBD::ODBC perl module hasn't been fully installed, or
perhaps the captialization of 'ODBC' isn't right.
Available drivers: ADO, ExampleP, Proxy at line 9. (the last line)
---------------------------
I presume the error message means that I have to install the DBD::ODBC
module. So I go into the PPM (perl package manager. I'm using
ActivePerl), and try to install DBD::ODBC. But then PPM said it cannot
locate a PPD file for package DBD::ODBC.
What's wrong?????????
Could the problem be related to the OS's DB registration? I'm using MS
Access and Win95.
Any help is greatly appreciated,
Nick
------------------------------
Date: Wed, 25 Aug 1999 16:42:39 -0400
From: "Blair Chesnut" <blair_chesnut@ncsu.edu>
Subject: Re: HELP Please!! with a script to query newsgroups
Message-Id: <7q1kg1$qud$1@uni00nw.unity.ncsu.edu>
Get the Net::NNTP module from CPAN.
niki wrote in message <37C45674.C13D04ED@nirvanet.net>...
>
>I am in dire need for a perl script which can query a NNTP server and
>count the number of headers for different newsgroups. The number of
>headers should then be stored in a text file (or html file).
>
------------------------------
Date: 26 Aug 1999 03:01:08 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: How to Address an email using CGI
Message-Id: <slrn7s9bno.lu.efflandt@efflandt.xnet.com>
On Wed, 25 Aug 1999 22:35:45 +0100, news <news@news.news> wrote:
>Try this:
Almost, but not quite. The double newline should come after the last
header line so the Reply-to: should be moved up above the Subject: unless
you only want it in the body of the message. There are also modules that
can be used like Mail::Sendmail or CGI.pm along with MIME::Lite for
sending a file upload as an attachment.
>open (MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n";
>print MAIL "To: $recipient\n";
>print MAIL "Cc: $carboncopy\n";
>print MAIL "Bcc: $blindcarboncopy\n";
>print MAIL "From: $sender\n";
>print MAIL "Subject: Test email ... etc\n\n";
>print MAIL "Reply-to: $user\n";
>print MAIL
>"------------------------------------------------------------\n";
>print MAIL "$FORM{'first_name'} $FORM{'last_name'} sent the following\n";
>
>etc
>
>
>Tom Renic wrote:
>
>> I'm trying to set up a cgi script that will send out an email. I'm
>> having a problem trying to set it up so that a variable ($testrecipient)
>> is set in the "To" section and variables ($recipient, $recipient1,
>> $recipient2) are set in the "Cc" section as well as setting the
>> "Subject". Can someone PLEASE tell me how to do this? I can't get it to
>> run on HP-UX10 machine. HELP!!!!
>
>
>
--
David Efflandt efflandt@xnet.com http://www.xnet.com/~efflandt/
http://www.de-srv.com/ http://cgi-help.virtualave.net/
------------------------------
Date: Wed, 25 Aug 1999 20:38:57 -0400
From: John Nolt <baghera@mindspring.net>
Subject: How to Detect that a Process is running already
Message-Id: <37C48CA0.C05CB617@mindspring.net>
Hi,
I'm hoping that this is a simple question.
I want to create a CGI that runs a perl script. However, if that perl
script is already running, I want to pop up a message that says
something to the effect of "I'm sorry, the script is already running.
Try again later."
So, I need to detect if the perl script is running. How do I do that?
The camel book chapter on IPC didn't really clue me in as to detecting
instances of scripts.
I realize that I may be jumping the gun since I haven't done much
development on this little application, but I would like to get an idea
in my head for this piece of the puzzle if possible.
Thanks for any help,
John
------------------------------
Date: 26 Aug 1999 02:13:30 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: HTML Tools for perl?
Message-Id: <7q27sa$75k@dfw-ixnews12.ix.netcom.com>
voxelman (voxelman@my-deja.com) wrote:
: I'm wondering if there is a tool for perl similiar to Zope(www.zope.org)
: which is for python. Essentially I need a tool that will allow my to
: keep the HTML as seperate as possible from the CGI code...this is so
: that graphics people working on the layouts do not deal with the code in
: anyway. I've written some tools to substitute variables embedded in the
: HTML as the script runs but perhaps there is a better way out there. If
: anyone could point me to some tools I would greatly appreciate it.
: Thanks in advance.
Go to CPAN and look at the Text::* and HTML::* modules. There are
several templating systems there, with varying capabilities and philosophies.
------------------------------
Date: Thu, 26 Aug 1999 13:05:33 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Jenda's gender [was: newbi: Registry Help under NT]
Message-Id: <MPG.122f5a09aa928d3f989c80@news-server>
David Cassell writes ..
>Jenda Krynicky wrote:
>[snip of gender error]
>> HIS site!
>>
>> Oh well. I guess I should put a picture of me online or at least
>> specify my sex on my site.
>>
>> Never mind :-)
>
>Just keep repeating these three words:
> Americans.. are.. stupid.
>
>David, proud to be stupid^WAmerican
only problem is that I'm not American .. neither am I female (another
common reason for assuming someone else is female in my experience)
I'm Australian .. I just guessed at Jenda's gender .. it's not the first
time - and I'm sure it will not be the last - that those Czech (s?)
names screw me up .. my culturally-inept apologies Jenda
( I guess I'll have to go back to dreaming about Abigail *8^)
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Thu, 26 Aug 1999 02:42:04 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: killing my child
Message-Id: <FH1wu4.Ezy@news.boeing.com>
In article <MPG.122846fcc0a31d749896cb@nntp1.ba.best.com>,
Bill Moseley <moseley@best.com> wrote:
>open (PIPE, "$command_line|") || die $!;
>
>Do I need to do anything else besides close( PIPE ) if I want to
>properly kill the program before I've read all its output?
>
No.
>There's a paragraph in perlipc about setting $SIG{CHLD} but I'm unclear
>if that applies here. And perlipc also says the above open is better
>than backticks because it lets me 'kill off the child process early.'
>But then I don't see where it explicitly says how.
>
The C<close> will reap the child process; although you could capture
the child pid and dispatch the offspring directly:
my $pid = open (PIPE, "$command_line|") || die "can't fork: $!;
...
kill ('TERM', $pid) or "can't kill $pid: $!";
hth,
--
Charles DeRykus
------------------------------
Date: 25 Aug 1999 22:32:12 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: mirror.pl on OS/2 Question
Message-Id: <slrn7s9dbh.lhu.abigail@alexandra.delanet.com>
David D. Huff Jr. (huffd@nls.net) wrote on MMCLXXXVI September MCMXCIII
in <URL:news:37C48EAB.6E3177F3@nls.net>:
'' How do I make mirror.pl delete files on the target
'' server that do not exist on the source server?
You would use the magic word "please".
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\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, 25 Aug 1999 18:41:13 -0700 (PDT)
From: Michael de Beer <madebeer@igc.apc.org>
Subject: Re: newbie: need help,LEARNING FROM A BOOK
Message-Id: <APC&1'0'50775d9b'a4d@igc.apc.org>
Oops. More than 2 typos in 4 lines of code.
I used to have $10, but I lost it amidst my typos ;)
-Michael "good thing there is -w" de Beer
------------------------------
Date: Thu, 26 Aug 1999 13:52:01 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: perl port for win32 problem
Message-Id: <MPG.122f64ed8c5c584989c81@news-server>
[ item posted to comp.lang.perl.misc and CCed to vladisx@usa.net ]
vladisx@usa.net writes ..
>HELP - I need the perl 500560 build for win32 binary.
>
>I could compile with no problems for unix and linux
>but on windows I get only errors...
>
>can anyone help me and send me these binaries or point me
>to a place I can get them (or have an experience doing this...)
>
>PLZ I need this as soon as possible!!!
I also couldn't build this 5.005_60 source on WinNT .. it was the first
development build that I've done - so I assumed that I must just have
screwed something up .. so I put it on the back burner
seeing your post now makes me think perhaps it wasn't just me .. my
error was
NMAKE : fatal error U1073: don't know how to make 'defsubs.h'
Stop.
NMAKE : fatal error U1077: 'D:\bin\vstudio\vc\bin\NMAKE.EXE' : return
code '0x2'
Stop.
there's no defsubs.h anywhere on my machine .. and the small attempts
that I made to get around this failed
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Thu, 26 Aug 1999 03:24:07 GMT
From: John Kristian <kristian@netscape.net>
Subject: Re: Perl without C compiler.
Message-Id: <7q2c0d$u8e$1@nnrp1.deja.com>
Jon Peterson <jpeterson@office.colt.net> wrote:
> Serguei Goumeniouk <serguei.goumeniouk@midwal.ca> wrote:
> > 1) Is it possible to install perl without C compiler (just copy
> > a file structure from one computer to another)?
>
> Yes, it is, although you would want the two machines to be identical
> in as many other respects as possible (OS version, hardware etc).
Moving Perl to an OS version newer than the one on which it was built
often works better than the reverse. So, build it on the oldest version
of the OS.
> Also, if you use any dynamic libraries, you'll need those available
> on the target machine
On many Unixes, the dynamic libraries must also be in the same places
(have the same pathnames) as on the target machine. Either that, or
environment variables must be set, to inform the runtime loader where
to find them. On Solaris it's $LD_LIBRARY_PATH; see `man ld`.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 25 Aug 1999 20:29:56 -0700
From: John Kristian <kristian@netscape.com>
To: Jon Peterson <jpeterson@office.colt.net>
Subject: Re: Perl without C compiler.
Message-Id: <37C4B4B2.3F3812B@netscape.com>
Is there a binary (pre-compiled) distribution of dynamic Perl for Solaris? For
NT? Where can I get copies?
I mean public Perl, not ActiveState. By 'dynamic' I mean compiled into shared
libraries.
Jon Peterson wrote:
> ... there may be pre-compiled versions of Perl available in a native package
> format for your platform.
------------------------------
Date: 26 Aug 1999 02:48:16 GMT
From: netdevilx@aol.com (Delarock)
Subject: Programming Question.. List/Email functions
Message-Id: <19990825224816.08941.00004558@ng-bg1.aol.com>
I'm using Perl 4.0.
How do you put a variable (or a list of variables) into a perl email syntax?
(open MAIL, print MAIL, close MAIL)
Any help with these commands would be appreciated.
------------------------------
Date: Thu, 26 Aug 1999 03:02:48 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Programming Question.. List/Email functions
Message-Id: <s72x3.3203$hf4.42689@nsw.nnrp.telstra.net>
In article <19990825224816.08941.00004558@ng-bg1.aol.com>,
netdevilx@aol.com (Delarock) writes:
> I'm using Perl 4.0.
perl 4 is dead. It is not supported. Almost no one still uses it. Most
people here have long, long ago moved on to newer versions, and are
probably not very good at helping out with perl 4 problems anymore.
Do yourself a favour, and install perl 5.005_03
> How do you put a variable (or a list of variables) into a perl email syntax?
perl does not have an email syntax.
> (open MAIL, print MAIL, close MAIL)
For perl 5:
# perldoc -f open
# perldoc -f print
# perldoc -f close
for perl 4:
# man perl
That manual page contains a descritption of all of those. You should
also use dejenaews to look for this sort of stuff. This quesiton comes
up so often that it's really a nuisance.
Martien
--
Martien Verbruggen |
Interactive Media Division | In the fight between you and the world,
Commercial Dynamics Pty. Ltd. | back the world - Franz Kafka
NSW, Australia |
------------------------------
Date: Wed, 25 Aug 1999 20:06:51 -0700
From: Dan Schneider <dcs@NOSPAM.csua.berkeley.edu>
Subject: redirecting outputs
Message-Id: <Pine.BSF.4.10.9908252000060.24651-100000@soda.CSUA.Berkeley.EDU>
Hi, I'm a Perl newbie...sorry if I'm wasting ppl's time, but:
I can't seem to solve this problem: I want STDERR to be redirected into
STDOUT, so that if I do a piped "open" on a Unix program, its STDERR will
also be piped and not output to the terminal. I can do this using the
shell's 2>&1 thingie but I would like a way to have Perl do this if
possible.
Thanks,
dcs@csua.berkeley.edu
------------------------------
Date: Wed, 25 Aug 1999 20:21:44 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: redirecting outputs
Message-Id: <MPG.122e52a8c63fbb759896d6@nntp1.ba.best.com>
Dan Schneider (dcs@NOSPAM.csua.berkeley.edu) seems to say...
> I can't seem to solve this problem: I want STDERR to be redirected into
> STDOUT, so that if I do a piped "open" on a Unix program, its STDERR will
> also be piped and not output to the terminal. I can do this using the
> shell's 2>&1 thingie but I would like a way to have Perl do this if
> possible.
Take a look at
perldoc IPC::Open3
NAME
IPC::Open3, open3 - open a process for reading, writing, and
error handling
Not sure if that exactly what you want or not. Good luck.
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: Wed, 25 Aug 1999 21:48:07 -0400
From: planb@newsreaders.com (J. Moreno)
Subject: Re: Regex Question
Message-Id: <1dx42wg.vi7t7myim0swN@roxboro0-0052.dyn.interpath.net>
Samay <samay1NOdzSPAM@hotmail.com> wrote:
> Hi, I am looking for some simple regex solution.
> I have some files which contain multiple lines instead of
> single lines for a single piece..
>
> ex.
> Start this
> is
> the ok End
>
> Start this is
> the ok2
> End
>
> I want to have
>
> Start this is the ok End
> Start this is the ok2 End
>
> Thus I would like to remove all new lines between Start and
> End
I don't know how to do it in one step, but it's easy using two.
m/Start(.+\n.+?)End/s;
$old=$1;
$new=$old;
$new =~ s/\n//g;
s/Start($old)(End)/Start$new$2/;
IIRC (I haven't used it) this ought to be an easy one liner with the
latest version.
--
John Moreno
------------------------------
Date: 25 Aug 1999 22:36:11 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Server Side Include Parameters
Message-Id: <slrn7s9dj0.lhu.abigail@alexandra.delanet.com>
Ed Robisheaux (eroby@webpositioning.com) wrote on MMCLXXXVI September
MCMXCIII in <URL:news:250819992006168957%eroby@webpositioning.com>:
%%
%% Does anyone know the syntax for passing parameters from a web page to a
%% perl script when using the exec cmd with server side includes turned
%% on?
And your Perl question is?
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\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: 25 Aug 1999 22:37:23 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Spawn a Web process
Message-Id: <slrn7s9dl8.lhu.abigail@alexandra.delanet.com>
David T. Cannon (good@drinking.eng.sun.com) wrote on MMCLXXXV September
MCMXCIII in <URL:news:37C47651.4FD99C60@drinking.eng.sun.com>:
??
?? I have a Perl cgi program that I would like to start a new
?? process(to run a report). However, using system() doesn't seem to work.
Yeah, that's because there's a bug in line 17. It should be the
other way around.
Abigail
--
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\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, 25 Aug 1999 16:35:44 -0400
From: "Blair Chesnut" <blair_chesnut@ncsu.edu>
Subject: SSN format
Message-Id: <7q1k32$pvj$1@uni00nw.unity.ncsu.edu>
What's an "efficient" way to format an integer into an SSN string?
For example, 12345 -> "000-01-2345".
Thanks
------------------------------
Date: Wed, 25 Aug 1999 20:03:59 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: SSN format
Message-Id: <MPG.122e4e7be5cf080d989ea7@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7q1k32$pvj$1@uni00nw.unity.ncsu.edu> on Wed, 25 Aug 1999
16:35:44 -0400, Blair Chesnut <blair_chesnut@ncsu.edu> says...
> What's an "efficient" way to format an integer into an SSN string?
> For example, 12345 -> "000-01-2345".
#!/usr/local/bin/perl -w
use strict;
$_ = 12345;
($_ = '0' x (9 - length) . $_) =~ s/(...)(..)(....)/$1-$2-$3/;
print;
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 25 Aug 1999 20:53:59 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: SSN format
Message-Id: <MPG.122e5a2687780b36989ea8@nntp.hpl.hp.com>
In article <MPG.122e4e7be5cf080d989ea7@nntp.hpl.hp.com> on Wed, 25 Aug
1999 20:03:59 -0700, Larry Rosler <lr@hpl.hp.com> says...
> In article <7q1k32$pvj$1@uni00nw.unity.ncsu.edu> on Wed, 25 Aug 1999
> 16:35:44 -0400, Blair Chesnut <blair_chesnut@ncsu.edu> says...
> > What's an "efficient" way to format an integer into an SSN string?
> > For example, 12345 -> "000-01-2345".
What I posted was "efficient". The following is "efficienter" :-).
#!/usr/local/bin/perl -w
use strict;
use Benchmark;
my $x = 12345;
timethese(1 << (shift || 0), {
Length => sub {
($_ = '0' x (9 - length $x) . $x) =~ s/(...)(..)(....)/$1-$2-$3/; $_ },
Longer => sub { "00000000$x" =~ /(...)(..)(....)$/; "$1-$2-$3" }
});
__END__
Benchmark: timing 65536 iterations of Length, Longer...
Length: 8 wallclock secs ( 7.90 usr + 0.00 sys = 7.90 CPU)
Longer: 3 wallclock secs ( 2.96 usr + 0.00 sys = 2.96 CPU)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 25 Aug 1999 23:00:53 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: SSN format
Message-Id: <slrn7s9f18.lhu.abigail@alexandra.delanet.com>
Blair Chesnut (blair_chesnut@ncsu.edu) wrote on MMCLXXXV September
MCMXCIII in <URL:news:7q1k32$pvj$1@uni00nw.unity.ncsu.edu>:
|| What's an "efficient" way to format an integer into an SSN string?
|| For example, 12345 -> "000-01-2345".
That's depends what you find "efficient". If you don't mind a bit
of preprocessing, and the use of some memory, a lookup table
is the fastest.
my @table = map {my $a = $_; map {"$_-$a"} '0000' .. '9999'}
map {my $a = $_; map {"$_-$a"} '00' .. '99'}
'000' .. '999';
print $table [12345];
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\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: Thu, 26 Aug 1999 02:51:09 GMT
From: alex@krohn.org (Alex Krohn)
Subject: Strange -e behaviour..
Message-Id: <37c4a863.548911933@news.supernews.com>
Hi,
Why does:
hits:~$ perl
use CGI;
print $CGI::VERSION, "\n";
2.53
hits:~$
work, but:
hits:~$ perl -MCGI -e "print $CGI::VERSION"
hits:~$
not work with 5.005_02 on linux? Is this a bug in earlier versions of
perl? As on my NT system with Activestates build 517:
C:\>perl -MCGI -e "print $CGI::VERSION"
2.46
C:\>
Thanks for any ideas..
------------------------------
Date: 26 Aug 1999 04:02:01 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: The extent of double-quotish interpolation
Message-Id: <7q2e7p$bae$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Alan Curry
<pacman@defiant.cqc.com>],
who wrote in article <Z50x3.25010$x04.1484087@typ11.nn.bcandid.com>:
> I'm trying to get at some clear, unambiguous documentation of what gets
> interpolated and what doesn't.
Clear, unambiguous documentation assumes clear, unambiguous
behaviour. Perl's is not. I do not remember whether string
interpolation includes any voting between different interpretations,
but REx interpolation definitely does.
Leave all hope whoever comes here. perlop/"Gory details..." for details.
Ilya
------------------------------
Date: 26 Aug 1999 03:31:23 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Want to try perl-cgi on UNIX
Message-Id: <slrn7s9dge.lu.efflandt@efflandt.xnet.com>
On Wed, 25 Aug 1999 20:23:18 GMT, thumpsup@my-deja.com
<thumpsup@my-deja.com> wrote:
>
>I am learning to write a perl-cgi programs. I work in the windows/PC
>environment and want to know if there is any free unix server available
>somewhere where I can upload my Unix Perl programs to test them and see
>the output in my windows browser. If you know any, please let me know
>how it works.
Any further discussion on this topic should be directed to a more suitable
newsgroup on *.cgi or possibly *.servers.unix.
The problem with free websites is that they usually do not have telnet
access so you cannot test your scripts from the shell first to see what
the errors are. Although, it is easy enough to write a CGI form to
execute shell commands once you have some experience. Such sites are also
very busy, so it is difficult to connect with ftp (which often has time
limits) and sometimes so busy that CGI is slow to respond at times. For
example last time I looked on www.virtualave.net, they had 170,000+ sites
and growing, which is enough to choke any server.
You are probably better off to install Linux on your PC. While it is free
for download, that can take overnight and you wouldn't have a clue what
you need. So first timers should get Linux on CD with a book explaining
how to set it up. It comes with a boot loader which I use to boot to
Linux or Win95.
--
David Efflandt efflandt@xnet.com http://www.xnet.com/~efflandt/
http://www.de-srv.com/ http://cgi-help.virtualave.net/
------------------------------
Date: Wed, 25 Aug 1999 19:22:52 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: YAREQ (yet another regexp question)
Message-Id: <MPG.122e44d31d524deb9896d5@nntp1.ba.best.com>
Larry Rosler (lr@hpl.hp.com) helped solve another problem and then says:
> s/[$qchars](?=\**$)//; # With an /o if $end_chars doesn't change.
my $ignorelast = '])-';
my $end_re = qr/[$ignorelast](?=\*?$)/o;
s/$end_re//o foreach @words;
|
^
Does this 'o' have any effect if 'o' is used in the qr// in the
line above?
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu.
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 647
*************************************