[6565] in Perl-Users-Digest
Perl-Users Digest, Issue: 190 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 27 10:07:13 1997
Date: Thu, 27 Mar 97 07:00:26 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 27 Mar 1997 Volume: 8 Number: 190
Today's topics:
Re: base conversion (for unix rgb/hex converter) <merlyn@stonehenge.com>
CGI Perl: How to get FORM name?? (Jete Software Inc.)
Re: crypt (Michael Guitton)
Re: crypt <merlyn@stonehenge.com>
Dbase and CGI <martin-s@mnplan.state.mn.us>
Re: Directory Listing in Perl (I R A Aggie)
Re: Directory Listing in Perl <merlyn@stonehenge.com>
Does perl have constants? (Robb Shecter)
Re: Functions and operators <tchrist@mox.perl.com>
Re: Get a week number from a file <flg@vhojd.skovde.se>
Re: Has anyone heard the rumour that Microsoft have bou (Clay Irving)
Re: Need help CGI scripting HTML forms to email cynthian@thecybercenter.com
Re: Newbie asks how do I format a numeric output? <ontwikmm@pi.net>
Re: NewbieQ: flow control while in while loop (Tad McClellan)
Re: Operating System Variable? <seay@absyss.fr>
Re: perl for.... (Tad McClellan)
Please repost Answer: Re: Q: How to search _VERY_ long <mystery@itis.com>
Re: Regular Expresion question. <seay@absyss.fr>
Re: Regular Expresion question. (Tad McClellan)
Re: regular expression for check lower case <seay@absyss.fr>
Re: trivial perl question from an ignoramus <flg@vhojd.skovde.se>
Re: trivial perl question from an ignoramus <merlyn@stonehenge.com>
URL verification <scs@huron.net>
Re: URL verification <aas@bergen.sn.no>
Re: What's a good Perl book? <merlyn@stonehenge.com>
Re: Who makes more $$ - Windows vs. Unix programmers? <mlindo@ix.netcom.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 27 Mar 1997 07:22:43 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: das@panix.com (David Staschover)
Subject: Re: base conversion (for unix rgb/hex converter)
Message-Id: <8cafnp8le4.fsf@gadget.cscaper.com>
>>>>> "David" == David Staschover <das@panix.com> writes:
David> I want to write a unix shell command to convert from rgb to hex. Is there
David> a function
David> in perl to convert bases?
Not generally, but since you mentioned "hex":
$value = hex($hexstring);
$hexstring = sprintf "%x", $value;
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 523 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 26 Mar 1997 11:28:08 -0500
From: jete@dgs.dgsys.com (Jete Software Inc.)
Subject: CGI Perl: How to get FORM name??
Message-Id: <5hbiqo$qdf@DGS.dgsys.com>
I apoligize if this is more of an CGI question than perl.
In the HTML code:
<FORM NAME="name" ACTION="action" METHOD="POST">
How can I later access this form name ?? Is it available as an environmental
variable??
-- Norman
------------------------------
Date: Thu, 27 Mar 1997 15:01:30 +0200
From: webmaster@cardshow.com (Michael Guitton)
Subject: Re: crypt
Message-Id: <webmaster-2703971501300001@paris23-228.paris.worldnet.fr>
In article <3339B12B.4818@fgidec1.tuwien.ac.at>, Mercedes Arredondo
<mercedes@fgidec1.tuwien.ac.at> wrote:
>I use the comand 'crypt' when checking the password entered by a user in
>an HTML form. The user also is asked to introduce his/her name in order
>to get from the system his/her real password. This function is supposed
>to encrypt the password entered and compare this encripted password with
>the correspondet password (the real password)of the user logged in. If
>success the user is allowed to access...
>But it never matches, the result of the 'crypt' function is always false
>even with my own password (which I am sure is a correct password).
>
>any suggestions???
>
while (<>) {
if (/^$form{'username'}:/o) { # find username
chop;
($username, $encrypted) = split(/:/);
if ($encrypted ne crypt($form{'password'}, $encrypted)) {
## Failure
}
else {
## Success
}
last;
}
}
## Hope this helps!
--
Michael Guitton
webmaster@cardshow.com
"Learn as if you would live forever, Live as if you would die tomorrow."
-- Mahatma Gandhi
------------------------------
Date: 27 Mar 1997 07:20:37 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: crypt
Message-Id: <8cd8sl8lhm.fsf@gadget.cscaper.com>
>>>>> "David" == David Alan Black <dblack@icarus.shu.edu> writes:
David> Here's an example from the perfunc manpage:
David> $pwd = (getpwuid($<))[1];
David> $salt = substr($pwd, 0, 2);
Actually, in spite of it being on the perlfunc manpage that way,
there's no need for the substr()...
David> system "stty -echo";
David> print "Password: ";
David> chop($word = <STDIN>);
David> print "\n";
David> system "stty echo";
David> if (crypt($word, $salt) ne $pwd) {
... because you can hand crypt the entire $pwd in place of $salt
here. It uses just the first two chars anyway.
David> die "Sorry...\n";
David> } else {
David> print "ok\n";
David> }
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 523 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Thu, 27 Mar 1997 08:21:25 -0600
From: Stephanie Martin <martin-s@mnplan.state.mn.us>
Subject: Dbase and CGI
Message-Id: <333A8265.619A@mnplan.state.mn.us>
I've got a problem!!
I need to be able to open a dbase file (sitting on a unix system) on an
index associated with it (the .mdx file), then be able to seek in that
file on that index. The problem is that I need to do this with a cgi
script (inperl) (unless there is another option?!). I've been using the
Xbase.pm perl module but it will only open a straight dbf file not by an
index. Our server is a Linux box.
Is anyone familiar enough with Xbase.pm to suggest how to modify the
open and seek functions? Does anyone have any other suggestions about
how to do this?
Thanks, Stephanie
------------------------------
Date: Tue, 25 Mar 1997 22:33:59 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: Directory Listing in Perl
Message-Id: <fl_aggie-ya02408000R2503972233590001@news.fsu.edu>
In article <01bc391a$088b2180$9d02a8c0@192.168.2.1.ims.ltd.uk>, "Paul
Denman" <pdenman@ims.ltd.uk> wrote:
+ I would like to also display the date each file was created - Is this so
+ simple that I'm missing it?
Try 'stat' on each file.
James - 'man perlfunc' should do nicely...
--
Consulting Minster for Consultants, DNRC
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: 27 Mar 1997 07:10:54 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Directory Listing in Perl
Message-Id: <8civ2d8lxt.fsf@gadget.cscaper.com>
>>>>> "Eric" == Eric Bohlman <ebohlman@netcom.com> writes:
Eric> Tom Phoenix (rootbeer@teleport.com) wrote:
Eric> : On 25 Mar 1997, Sriranga R. Veeraraghavan wrote:
Eric> : > for($a=0;$a<=$#files;$a++){print "$files[$a]\n";}
Eric> : Maybe you meant this? :-)
Eric> : for (@files) { print "$_\n" }
Eric> Or even
Eric> print join("\n",@files),"\n";
Ugh. How about
print map "$_\n, @files;
But the foreach solution is still faster. (Gut level feel here.
Building a single string looks like work [join]. Building a list
looks like less work [map]. But simply walking the list is fastest
[foreach]. If someone would care to prove me wrong, I'll certainly
listen. :-)
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 523 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 27 Mar 1997 15:23:23 +0100
From: rshecter@faculty.ed.umuc.edu (Robb Shecter)
Subject: Does perl have constants?
Message-Id: <5hdvsr$bmd@faculty.ed.umuc.edu>
Hi,
For the life of me, I can't find out how to declare (and use) constants in
perl. (I happen to be working in Perl4, but haven't seen anything in
Perl5, either.) Does perl support the standard, run-of-the-mill constant?
I'm suprised that there's no mention of this in books like "Programming perl",
for example.
- Robb
--
-
Robb Shecter PGP Fingerprint:
University of Maryland, European Division 5F 70 B1 A7 B9 F9 42 67
Information Systems and Administrative Computing 11 27 47 EE 35 80 04 AA
------------------------------
Date: 27 Mar 1997 14:47:42 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Functions and operators
Message-Id: <5he1ae$oer$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Tom Phoenix <rootbeer@teleport.com> writes:
:Is there a way to tell functions from non-functions and operators from
:non-operators? Are there some things which are both functions and
:operators? And isn't this a messy can of worms? :-)
I believe the programming public is most comfortable calling all the
prefix alphabetic ones "functions", and calling all the infix, postfix,
circumfix, and nonalphabetic ones "operators". I follow that usage to
avoid freaking them out. Thus int($x) is applying a function, but ++$x
is applying an operator. Does that make sense? Is it not a reasonable
distinction?
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
Interestingly enough, since subroutine declarations can come anywhere,
you wouldn't have to put BEGIN {} at the beginning, nor END {} at the
end. Interesting, no? I wonder if Henry would like it. :-) --lwall
------------------------------
Date: Thu, 27 Mar 1997 13:45:20 +0100
From: Fredrik Lindberg <flg@vhojd.skovde.se>
To: John Jiang <jiangj@bnr.ca>
Subject: Re: Get a week number from a file
Message-Id: <333A6BE0.1E56@vhojd.skovde.se>
>>>> John Jiang wrote:
> How can I get a week number of the time when a file is
> created. The week number would be something like what we got from
> shell "date -u +%W". Thanks.
(Can you really get the "creation time"?)
Heres one way of doing it (I am using the modification date of
the file in this example)
#!/usr/bin/perl
#
use POSIX;
$filename = shift; # get filename from commandline
# stat returns a lot of information, "man perlfunc" for more
# information about the return values
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks) = stat($filename);
# A shorter version of the above call would be
#
# $mtime = (stat($filename))[9]; # Modification date
# $ctime = (stat($filename))[10]; # I-node change date
#
# Note the paranthesis around the call.
# Now translate this time into something strftime can handle.
# you will find information about localtime() in the perlfunc
# man page
($sec,$min,$hour,$mday,$mon,$year) = localtime($mtime);
# And finally call strftime .. check out "man strftime" for
# more information about this function
print strftime("%W", $sec, $min, $hour, $mday, $mon, $year);
__END__
Hope this helps
/Fredrik
------------------------------
Date: 27 Mar 1997 08:37:02 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Has anyone heard the rumour that Microsoft have bought Perl?
Message-Id: <5hdt5u$atk@panix.com>
In <01bc3a03$d955c100$0600000a@salmon> "Jonathan Tracey" <jont@uunet.pipex.com> writes:
>I have it on good authority that Microsoft have aquired the rights to
>future versions of Perl. If so how long before we get Visual Perl?
>Any thoughts.
I'm sorry. Your message has been rejected by the Perl Cabal. Repost again
on April 1st.
--
Clay Irving See the happy moron,
clay@panix.com He doesn't give a damn,
http://www.panix.com/~clay I wish I were a moron,
My God! Perhaps I am!
------------------------------
Date: Thu, 27 Mar 1997 07:21:08 -0600
From: cynthian@thecybercenter.com
Subject: Re: Need help CGI scripting HTML forms to email
Message-Id: <859468053.24814@dejanews.com>
In article <Pine.GSO.3.96.970326173332.1174O-100000@kelly.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:
>
> On Tue, 25 Mar 1997, Sheldon Rampton wrote:
> " I can't figure out how to make Perl send email..."
Hi. Get out the books... Or try the CGI wonder programs created by
WebGenie Software Pty Ltd. from Australia. Ref: http://www.webgenie.com/
In mere moments CGI*StarPro can generate the bin using your form with
multiple email addresses. For a look at recent customization using these
amazingly easy tools, go to http://www.hazlehurst.org/page16.html/ or
http://www.hazlehurst.org/page38.html/ for a first class CGI/Java based
Guest Book that's getting a rave review using WebGenie's new
Guestbook*Star.
These interactive solutions have gotten me through where the teaching
books didn't, but the job had to be done well and fast!
Cynthia
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Thu, 27 Mar 1997 14:09:27 +0100
From: ontwikmm <ontwikmm@pi.net>
Subject: Re: Newbie asks how do I format a numeric output?
Message-Id: <333A7187.1433@pi.net>
Russ wrote:
>
> Hi,
>
> I'm sure the solution to this is very simple but I can't find out how to
> format the result of a calculation. I using a perl script to multiply say
> 7.99 by 2 and I am getting a result of 15.980000000000000426. How can I
> limit this to 2 decimal places?
>
> Thanks
>
> Russ Walton
$out = sprintf(FORMAT, $in);
where FORMAT could be "%5.2f" , in your case, to generate a 5 char wide
string with 2 chars after the decpoint
By the way, all this is in the man-pages and any book on perl.
Harro de Gouw
------------------------------
Date: Thu, 27 Mar 1997 06:41:18 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: NewbieQ: flow control while in while loop
Message-Id: <etpdh5.kn.ln@localhost>
Brett Longworth (blongwor@student.umass.edu) wrote:
: Hello,
: Sorry about the confusing subject line, I couldn't think of a better way
: to explain my problem quickly.
: I know this is a simple one, but I can't seem to find the answer
: anywhere. While using a while loop to grab stuff I want from a text
: file, I'd like to try to grab a line that may or may not occur between
: two matches of a regex a few lines apart. If it is there, it should be
: associated with the regex a few lines before it, if it's not, it
: shouldn't be.
: Bleah, that previous paragraph is longer than my problem. Right now,
: I'm trying to append the "in-between" line to the same variable that
: contains the first line, and then sort it all out later. If anyone
: understood my poor explanation of what I'm trying to do, a push in the
^^^^^^^^^^^^^^^^^^^
: right direction or suggestion of a good consruct to get this done would
: be great.
Why not just supply some sample data, and tell us what you
want to extract from it...
Code is much easier to understand than English ;-)
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Thu, 27 Mar 1997 14:19:28 +0000
From: Douglas Seay <seay@absyss.fr>
To: deb@marinbridge.com
Subject: Re: Operating System Variable?
Message-Id: <333A81F0.3C22@absyss.fr>
Debbie Whitten wrote:
>
> Hello,
>
> is there a built-in variable or way of getting the operating system
> in Perl 5? I have written a script that could be run on Unix or
> VMS. Right now I'm checking that /etc/passwd exists - if so, it's
> Unix, if not, it's VMS. I don't like that solution.
>
> I've looked through the Camel book but couldn't find it. A co-worker
> told me to use $^O or $OSNAME but that didn't work.
>
> Thanks!
>
> Deb
I'd use 'osname' from Config.pm, but maybe I'm
overly fond of Config.
------------------------------
Date: Thu, 27 Mar 1997 06:39:03 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: perl for....
Message-Id: <7ppdh5.kn.ln@localhost>
Rod MacLean (Rod_MacLean@ibm.net) wrote:
: Can someone point me to where I can download the perl interpreter
^^^^^^^^^^^
: for SunOS & Solaris.
new Perl FAQ (part 2)
-----------------------------------
=head2 What machines support Perl? Where do I get it?
The standard release of Perl (the one maintained by the perl development
team) is distributed only in source code form. You can find this at
http://www.perl.com/CPAN/src/latest.tar.gz, which is a gzipped archive
in POSIX format. This source builds with no porting whatsoever on most
Unix systems (Perl's native environment), as well as Plan 9, VMS, QNX,
OS/2, and the Amiga.
Although it's rumored that the (imminent) 5.004 release may build
on Windows NT, this is yet to be proven. Binary distributions
for 32-bit Microsoft systems and for Apple systems can be found
http://www.perl.com/CPAN/ports/ directory. Because these are not part of
the standard distribution, they may and in fact do differ from the base
Perl port in a variety of ways. You'll have to check their respective
release notes to see just what the differences are. These differences
can be either positive (e.g. extensions for the features of the particular
platform that are not supported in the source release of perl) or negative
(e.g. might be based upon a less current source release of perl).
A useful FAQ for Win32 Perl users is
http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html
=head2 How can I get a binary version of Perl?
If you don't have a C compiler because for whatever reasons your
vendor did not include one with your system, the best thing to do is
grab a binary version of gcc from the net and use that to compile perl
with. CPAN only has binaries for systems that are terribly hard to
get free compilers for, not for Unix systems.
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Thu, 27 Mar 1997 08:55:43 -0500
From: Prince Mystery <mystery@itis.com>
Subject: Please repost Answer: Re: Q: How to search _VERY_ long scalars for recurring patterns?
Message-Id: <333A7C5F.1CFB@itis.com>
Tad McClellan wrote:
>
> John Kodis (kodis@kodis.jagunet.com) wrote:
> : Previously, Kenneth W. Lee wrote:
>
> : >How do you process an _extremely_ looooong scalar file
> : >(i.e. a 3 meg ascii text file with no newlines) that has
> : >a unique recurring regexp? (Imagine a very large
> : >fixed-length ascii table... and now imagine that
> : >that table has all the newline characters removed...yuck)
>
> : Of course, the real mystery here is why anyone in their right mind
> : would format a file in such an unusable manner in the first place.
> ^^^^^^^^^^^^^^^
>
> It's perfectly usable for a computer. I expect it was intended to
> be used by a computer.
>
> The concept of 'lines' is just a convenience for humans...
Hey, what was the answer to this guys' question??? I've got this exact
same problem...my basic need is to extract specific values from
subpattern matches and store those values in a
hash...news{$date}{$title} = $text; without using an involved set of
loops and numerous pattern matches. My current solution grabs 30% of
CPU time away from a Sun Sparc10 4xprocessor machine -- I don't think
it's too workable.
Thomas
------------------------------
Date: Thu, 27 Mar 1997 13:58:44 +0000
From: Douglas Seay <seay@absyss.fr>
To: abennett@stonehill.edu
Subject: Re: Regular Expresion question.
Message-Id: <333A7D14.4BB5@absyss.fr>
Aaron Bennett wrote:
> print "Content type: text/html", "\n\n";
> if ($mail_form{'email'} =~ /\@{1}.+/) {
> print "<H1>Email is valid ", %mail_form{'email'}, "</H1>"; }
^
eh, shouldn't this be a $ instead of a %
> I'm a moron :) or at least a slow learner.
Don't worry, we all start kinda slow. Just hang
in there and let -w be your friend, plus stick
with "use strict;" when possible.
------------------------------
Date: Thu, 27 Mar 1997 06:32:51 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Regular Expresion question.
Message-Id: <jdpdh5.kn.ln@localhost>
Aaron Bennett (abennett@stonehill.edu) wrote:
: Aaron Bennett wrote:
:
: Many many thanks for all the replies and gentle but constructive
: criticism.
: Of course, I had a syntax error: (boot to the head!)
: > print "Content type: text/html", "\n\n";
: > if %mail_form{'email'} =~ /\@{1}.+/ {
: > print "<H1>Email is valid ", %mail_form{'email'}, "</H1>"; }
: Syntactically should have read
: print "Content type: text/html", "\n\n";
: if ($mail_form{'email'} =~ /\@{1}.+/) {
^^^^^^^^^^^^^^^^^^^
Good.
: print "<H1>Email is valid ", %mail_form{'email'}, "</H1>"; }
^
^
Still funky ;-)
: I'm a moron :) or at least a slow learner.
: More importantly, many people explained to me the futility of attempting
: to validate email addresses. I agree, I just want to put them through
: some preliminary screening to trap obvious typos like
: bennett@stonehilledu or bennett.stonehill.edu. So I settled on
: m/@[^.@]+\.+/, which by looking for one or more @'s followed by any
^^^^^^^^^^^^^
: character besided and @ followed by at least one period, should cut out
It will match 'bennett@stonehill..edu' too.
Seems a likely typo that should be caught...
: extremely obvious problems while allowing bizzare email address
: conventions to pass through.
: Thanks to all for the help and directional pointers.
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Thu, 27 Mar 1997 14:14:35 +0000
From: Douglas Seay <seay@absyss.fr>
Subject: Re: regular expression for check lower case
Message-Id: <333A80CB.1CB4@absyss.fr>
Eric Bohlman wrote:
>
> Randal Schwartz (merlyn@stonehenge.com) wrote:
>
> : Don't use a regular expression:
>
> : if ($thing eq lc $thing) {
> : # it's OK!
> : }
>
> : This has the advantage of being locale-safe for international character
> : sets.
>
> Doesn't this suggest that we badly need two new metacharacters, one that
> matches any uppercase letter in the current locale, and one that matches
> any lowercase letter?
I second the motion.
As I've never dealt with anything outside of the regular
ASCII set (0-127 decimal), today's system works well
enough for me. But I can see where the current system
is lacking for many.
But what would be better: define new symbols that use
the context, or to let the locale alter the meaning
of existing symbols? The second would be my preference,
but I could see how that could break lots of things
and produce hard to find bugs.
- doug
------------------------------
Date: Thu, 27 Mar 1997 13:17:58 +0100
From: Fredrik Lindberg <flg@vhojd.skovde.se>
To: "Robert R. Tucci" <tucci@ar-tiste.com>
Subject: Re: trivial perl question from an ignoramus
Message-Id: <333A6576.41BF@vhojd.skovde.se>
Robert R. Tucci wrote:
>
> I found a simple perl subroutine on the web that is supposed to add prefix
> zeros to integers< 10. Unfortunately, it doesn't work. Could someone
> please tell me why?
>
>> snap <<
> sub check
> {
> $i=0;
> foreach $i (0 .. $#){
^^
This is wrong, it should read $#_ instead, since the array name you want
to find the last index for is $_
But there is an easier way; You could use a function called sprintf to
format the string:
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
$x_inv_number = sprintf("%d%02d%02d%02d%02d%02d",$year, $mon+1,
$mday, $hour, $min,
$sec);
There aint much help and info about the printf and sprintf in the
perlfunc
man pages, unfortunatly.
Hope this helps
/Fredrik
------------------------------
Date: 27 Mar 1997 07:16:26 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Eric Poindexter <eric@nettown.com>
Subject: Re: trivial perl question from an ignoramus
Message-Id: <8cg1xh8lol.fsf@gadget.cscaper.com>
>>>>> "Eric" == Eric Poindexter <eric@nettown.com> writes:
Eric> $x_inv_number = sprintf '%4%02%02%02%02%02', $year, $true_mon, $mday,
Eric> $hour, $min, $sec;
Of course, what he meant to say was something like:
$stamp = sprintf "%04d/%02d/%02d and so on", $year, $true_mon, $mday;
It'll work a whole lot better that way.
Eric> Check out man sprintf (if in unix) for more information.
Eric> This is a major C function that perl inherited.
Agreed.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 523 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 27 Mar 1997 14:18:26 GMT
From: "Stephen Hill" <scs@huron.net>
Subject: URL verification
Message-Id: <01bc3ab9$5b521cc0$1691e9cd@scs>
I am working on a mini search engine......is there anyway to verify that a
URL actually exists, using perl?
Please email your response, I don't get to read the newsgroups as often as
I would like:-)
scs@huron.net
------------------------------
Date: 27 Mar 1997 15:42:37 +0100
From: Gisle Aas <aas@bergen.sn.no>
Subject: Re: URL verification
Message-Id: <hk9mtbdlu.fsf@bergen.sn.no>
"Stephen Hill" <scs@huron.net> writes:
> I am working on a mini search engine......is there anyway to verify that a
> URL actually exists, using perl?
use LWP::Simple;
print "not " unless head("http://www.sn.no/libwww-perl/");
print "ok\n";
--
Gisle Aas <aas@sn.no>
------------------------------
Date: 27 Mar 1997 07:00:58 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: What's a good Perl book?
Message-Id: <8ck9mt8med.fsf@gadget.cscaper.com>
>>>>> "Paul" == Paul David Fardy <pdf@morgan.ucs.mun.ca> writes:
Paul> Exactly where should we send our comments on the Perl book?
O'Reilly requests that *all* questions about their books (can't find
something, missing something, typo, suggestions for future books) be
routed through *their* people at bookquestions@ora.com (the address
given in the preface of nearly every ORA book). They screen
duplicates and pass on the tougher stuff to us. It's worked so
far. :-)
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 523 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Thu, 27 Mar 1997 07:30:26 -0800
From: "Marc S. Lindo" <mlindo@ix.netcom.com>
Subject: Re: Who makes more $$ - Windows vs. Unix programmers?
Message-Id: <333A9292.5192@ix.netcom.com>
USUARIO wrote:
>
> In article <1387.7010T977T2070@canit.se>, Iggy Drougge <optimus@canit.se> wrote:
> >John Lockwood (johnl@calweb.com) skrev:
> >>"Terje A. Bergesen" <terjeber@eunet.spm-protect.no> wrote:
> >
> >>>> Unix appeals more to me and is more advanced technically, but I am
> >>>> afraid that it is losing the market share to Windows 95.
> >
> >>Unix is more advanced technically? That's interesting. The last time
> >>I installed a modem on Windows NT the OS found it for me. The last
> >>time I tried it on Unix I read about the nine files one had to edit,
> >>then gave up. It seems to me that Unix is losing market share
> >>precisely because end users never make the programmer's mistake of
> >>confusing technical advancement with obtuseness.
> >
> >Why would your computer detect a modem for you? Do you mean it sent out "AT" on
> >the serial port and listened for "OK", or what? When I use modems, I just plug
> >them in into the appropriate sockets.
> >Granted, UNIX can be quite comlicated, but it still has the edge over NT in
> >really power-demanding niches.
> >
> >--
> > __/\________________ __ ______ _____________________________
> > \/ /_ /\__ /\_ _// // //\ /\ / ____________________________\
> > / / / / __/ / / / / // / / // / / // / __ __
> > / /_/ / / __/ / / / // / / // /_/ // / alias | | _ | _ |__|
> > /_____/ /_/ /_/ /_//_/\/_/ \_____\\ \ | |__| |__| .__|
> >________________________________________\ \ D r o u g g e
> >\_________________________________________/
> >
>
> Yes, but, how much is the kilo?
UNIX is now a niche market for programmers, so this means on average the
salary range is higher.
As far as technical superiority, Unix is still dominant when it comes to
the Internet. The foundation and infrastructure for the in Internet is
not based on Windows NT it is based on UNIX. In client/server computing
I think Windows NT is gaining a lot of grounds. But this does not mean
UNIX is dead. This just mean that the UNIX guys has not gotten there act
together yet to develop a more user friendly environment.
Hope this helps.
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". 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". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 190
*************************************