[12069] in Perl-Users-Digest
Perl-Users Digest, Issue: 5669 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 15 05:17:12 1999
Date: Sat, 15 May 99 02:00:24 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 15 May 1999 Volume: 8 Number: 5669
Today's topics:
Re: /usr/bin/perl vs /usr/local/bin/perl <gellyfish@gellyfish.com>
5.005_03 install -- anydbm test failed saadiqr@NOJUNK.cs.princeton.edu
Bread ( was Re: Off-topic: France (was Re: Perl "constr <gellyfish@gellyfish.com>
Re: encoding query strings manually? <gellyfish@gellyfish.com>
Re: FAQ 4.26: How do I change the Nth occurrence of som (Larry Rosler)
Re: Finding x^y? <gellyfish@gellyfish.com>
Re: first perl project (Dave Cross)
Re: first perl project <swarren@www.wwwdotorg.org>
Re: Hash arrays <rra@stanford.edu>
Re: how many people have obscure addresses (was Re: Ext <doris&sceptic@gellyfish.com>
Re: how to fix file permission mistakes <swarren@www.wwwdotorg.org>
How to know if a function takes $_ as a default <brannon@quake.usc.edu>
Re: How to know if a function takes $_ as a default (Sam Holden)
Re: Looking for autoresponder script ! <gellyfish@gellyfish.com>
Re: man pages and FAQs: why posted? <jlarke@ans.net>
Re: man pages and FAQs: why posted? (Lee)
open, read,then print a file (Austin Ming)
Re: open, read,then print a file <swarren@www.wwwdotorg.org>
Re: Parameter pass to PERL <swarren@www.wwwdotorg.org>
Re: Perl "constructors" <rra@stanford.edu>
Re: PERLFUNC: hex - convert a string to a hexadecimal n <ebohlman@netcom.com>
Re: Reading a file in variable <ebohlman@netcom.com>
Rename directory <ddaffer@helixelectric~NOSPAM~.com>
Re: Rename directory <rra@stanford.edu>
Re: Rename directory (Larry Rosler)
Re: Sending E-Mail via PERL (CGI) (Dave Cross)
Re: Sending E-Mail via PERL (CGI) <gellyfish@gellyfish.com>
time-ordered file array <pdirksen@shell5.ba.best.com>
Re: time-ordered file array (Larry Rosler)
Re: time-ordered file array <rra@stanford.edu>
Re: uninitialized value <rra@stanford.edu>
Re: Which book do you recommend? <ebohlman@netcom.com>
Win32::ODBC FetchRow problem <murray@ecst.csuchico.edu>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 May 1999 08:00:15 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: /usr/bin/perl vs /usr/local/bin/perl
Message-Id: <7hj9if$130$1@gellyfish.btinternet.com>
On Sat, 15 May 1999 01:36:44 GMT Matthew Bafford wrote:
>
> perl -i -pe 's{^#!/usr/bin/perl}{#!/usr/local/bin/perl}' *.plx
>
Except you left off the '-w' from the substitution ;-}
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sat, 15 May 1999 03:02:52 -0400
From: saadiqr@NOJUNK.cs.princeton.edu
Subject: 5.005_03 install -- anydbm test failed
Message-Id: <373D1C1C.65743B57@NOJUNK.princeton.edu>
I'm running Debian Linux and trying to upgrade from 5.004_05 to 5.005_03
but I'm having a small problem. When I run 'make test' the anydbm test
fails. It's only 1 of the 12 subtests so it's not a huge problem but
I'd like to fix it all the same.
The README.dos file states that for that platform:
"You should see "All tests successful" if you configured a database
manager, and 1 failed test script if not (F<lib/anydbm.t>). If you
configured POSIX you will see 1 additional failed subtest in
F<lib/posix.t>."
I am going to be doing a lot of db stuff so I'd like to sort this out.
Any pointers on configuring a database manager, if that's what I need to
do?
>From the 't' directory ./perl -I../lib harness outputs:
Failed Test Status Wstat Total Fail Failed List of failed
------------------------------------------------------------
lib/anydbm.t 12 1 8.33% 12
4 tests skipped, plus 14 subtests skipped.
Failed 1/190 test scripts, 99.47% okay. 1/6712 subtests failed, 99.99%
okay.
Running just the anydbm test outputs:
dread:~/src/perl5.005_03/t$ ./perl lib/anydbm.t
1..12
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
ok 8
ok 9
ok 10
ok 11
not ok 12
Any help would be appreciated. Thanks.
Saadiq
saadiqr AT princeton DOT edu
------------------------------
Date: 15 May 1999 08:15:11 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Bread ( was Re: Off-topic: France (was Re: Perl "constructors"))
Message-Id: <7hjaef$133$1@gellyfish.btinternet.com>
On Fri, 14 May 1999 13:55:56 -0400 Ala Qumsieh wrote:
>
> Scratchie <upsetter@ziplink.net> writes:
>
>> I once went to France with an (American) friend who couldn't understand
>> why supermarkets sold bread in plastic bags that had little holes in them.
>> "It would stay fresh a lot longer if they'd use a regular bag", he
>> lamented.
>
> I hope I am not being stupid here, but why do the bags have little
> holes in them?
>
The bag is to protect the bread from the exigencies of the world and to
prevent the crumbs from getting everywhere. French bread has a hard crust
that would soften quickly if placed in a polythene bag like that which we
get sliced bread in - this is exascerbated because the bread is often
freshly backed - even in supermarkets. As a matter of information
French Bread sold in UK supermarkets comes in the same bags with holes in.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 15 May 1999 08:33:24 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: encoding query strings manually?
Message-Id: <7hjbgk$143$1@gellyfish.btinternet.com>
On Sat, 08 May 1999 02:39:32 GMT Ken wrote:
> Hello, I have been hunting the net for an answer to my question and have
> yet to find anything so thought I might try here.
>
> I wish to write in my perl a query string thats properly encoded.
> Something like the following:
>
> print "<a href="www.somewhere.com/newscript.pl?(query string)>"
>
> where (query string) is the encoded value of a string that I have. I
> have found lots of information on decoding and lots of information on
> how a form encodes it, but I want to be able to encode it manually in my
> perl script.
>
You might examine the following (as I have been chastized recently for
advocating the over use of modules :)
#!/usr/bin/perl -w
$string = 'this is ? string with stuuf ~ init';
$string =~ s/([^A-Za-z0-9])/sprintf("%%%02X",ord($1))/eg;
print $string;
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sat, 15 May 1999 00:10:56 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: FAQ 4.26: How do I change the Nth occurrence of something?
Message-Id: <MPG.11a6bdd5422a69e4989a6d@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <373d13fa@cs.colorado.edu> on 15 May 1999 00:28:10 -0700, Tom
Christiansen <perlfaq-suggestions@perl.com> says...
...
> How do I change the Nth occurrence of something?
>
> You have to keep track of N yourself. For example, let's say you
> want to change the fifth occurrence of `"whoever"' or `"whomever"'
> into `"whosoever"' or `"whomsoever"', case insensitively.
>
> $count = 0;
> s{((whom?)ever)}{
> ++$count == 5 # is it the 5th?
> ? "${2}soever" # yes, swap
> : $1 # renege and leave it there
> }igex;
The /x is gratuitous -- there is no extended regex there.
The brackets around ${2} are gratuitous -- there is no ambiguity there.
The case insensitivity can produce an ugly result if the words in $_ are
all upper-case, instead of just initials.
Where does it mention $_ in any event?
> In the more general case, you can use the `/g' modifier in a
> `while' loop, keeping count of matches.
>
> $WANT = 3;
> $count = 0;
> while (/(\w+)\s+fish\b/gi) {
> if (++$count == $WANT) {
> print "The third fish is a $1 one.\n";
> # Warning: don't `last' out of this loop
> }
> }
>
> That prints out: `"The third fish is a red one."'
For particular values of $_ that are not specified.
What are the consequences of ignoring the warning? ('Or else ..' what?)
> You can also use
> a repetition count and repeated pattern like this:
>
> /(?:\w+\s+fish\s+){2}(\w+)\s+fish/i;
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 14 May 1999 21:49:42 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Finding x^y?
Message-Id: <7hi5pm$h1$1@gellyfish.btinternet.com>
On 14 May 1999 12:35:54 -0500 Dale Henderson wrote:
>
> (And the basic I learned on
> a C64 uses an eponation character that I can't reproduce on this
> keyboard :)
Yeah , I seem to remember some pointy up arrow thing as well, but that
was a Commodore PET 'bout twenty years or so ago.
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sat, 15 May 1999 08:19:23 GMT
From: dave@dave.org.uk (Dave Cross)
Subject: Re: first perl project
Message-Id: <373e2db2.4727649@news.demon.co.uk>
On Thu, 13 May 1999 13:34:33 -0500, "todd" <thirdaver@inxpress.net>
wrote:
>I need to accomplish the following.
>
>A user logs in
>access the /etc/passwd file and determine when users passwd will expire
>inform user when password will expire
>
>At this point this seems like a mountain, how do I make a first step. I know
>some perl basics, its time to get my feet wet.
Todd,
You should take a look at the 'open' and 'split' functions. They'll
put you on the right path.
perldoc -f open
perldoc -f split
will show you the docs for those two functions.
Dave...
Dave Cross <dave@dave.org.uk>
<http://www.dave.org.uk>
------------------------------
Date: Sat, 15 May 1999 08:55:43 GMT
From: "Stephen Warren" <swarren@www.wwwdotorg.org>
Subject: Re: first perl project
Message-Id: <jEa%2.1508$6x6.2044@news.rdc1.sfba.home.com>
Dave Cross <dave@dave.org.uk> wrote in message
news:373e2db2.4727649@news.demon.co.uk...
> On Thu, 13 May 1999 13:34:33 -0500, "todd" <thirdaver@inxpress.net>
> wrote:
>
> >I need to accomplish the following.
> >
> >A user logs in
> >access the /etc/passwd file and determine when users passwd will
expire
> >inform user when password will expire
>
> You should take a look at the 'open' and 'split' functions. They'll
> put you on the right path.
>
> perldoc -f open
> perldoc -f split
There are also functions in perl for iterating over the password file (and
others). As above, you can read about them by:
perldoc -f getpwent
That said, you might not learn about split and <> that way!
--
Stephen Warren, Snr Systems Engineer, Technology House, San Francisco
mailto:swarren@techhouse.com http://www.techhouse.com/
mailto:swarren@wwwdotorg.org http://www.wwwdotorg.org/
MIME, S/MIME and HTML mail are acceptable
------------------------------
Date: 14 May 1999 23:44:23 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Hash arrays
Message-Id: <ylwvya6ddk.fsf@windlord.stanford.edu>
armchair <armchair@my-dejanews.com> writes:
> Thanks. It seems a bit much, as all I really want to do is check to see
> if the hash has elements:
Then test that. "if (%hash)".
> Do they have a place to post requested enhancements to Perl?
It's usually better to learn Perl first.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 14 May 1999 20:37:45 -0000
From: Jonathan Stowe <doris&sceptic@gellyfish.com>
Subject: Re: how many people have obscure addresses (was Re: Extracting emails from array)
Message-Id: <7hi1ip$gb$1@gellyfish.btinternet.com>
In comp.lang.perl.misc Russell Schulz <Russell_Schulz@locutus.ofb.org> wrote:
>
<snip>
> Again I offer you this: I will stop making this claim if you stop
> using `merlyn@' as your address and switch to your `fred&barney@'
> contrived example.
Its not a contrived example.
Why did it take you 3 weeks to post this response.
I figure you as a troll
*plonk*
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sat, 15 May 1999 08:30:11 GMT
From: "Stephen Warren" <swarren@www.wwwdotorg.org>
Subject: Re: how to fix file permission mistakes
Message-Id: <nga%2.1411$6x6.2126@news.rdc1.sfba.home.com>
BLUESRIFT <bluesrift@aol.com> wrote in message
news:19990514234336.22842.00000872@ng-fv1.aol.com...
> I wasn't paying attention and the following script segment created a
> subdirectory and if I understand it correctly also chmod'd it to 700.
This is
> on a unix server.
>
> $root = "$ENV{'DOCUMENT_ROOT'}";
>
> $datadir = "$root/fanciful/cgi-bin/data";
>
> if (!opendir (DIR, "$datadir")) {
> mkdir ("$datadir", 0700);
> }
>
> Then the script also created files in that directory, one of which is
named
> 1.txt.
>
> My understanding is that the "data" directory and the files therein are
owned
> by the server acting as user "nobody". Based on that knowledge I have
> attempted to write another script to delete the files (one at a time):
Whilst this isn't remotely a Perl question...
I would start out by making a script that systems() off 'ls -lR' on the
directory to check out what its state really is. Also print out things
like the uid the script is running as.
Then, check (using standard Unix filesystem rules) whether the CGI uid can
delete the directory (which is highly likely, since it had enough
permissions to create it). If so, you can always:
system( "rm -rf $dir" ) ;
being *very* careful to set $dir correctly...
Adding -w to the #! line and 'use strict;' might help you catch any errors
too.
--
Stephen Warren, Snr Systems Engineer, Technology House, San Francisco
mailto:swarren@techhouse.com http://www.techhouse.com/
mailto:swarren@wwwdotorg.org http://www.wwwdotorg.org/
MIME, S/MIME and HTML mail are acceptable
------------------------------
Date: 14 May 1999 22:11:51 -0700
From: tbrannon <brannon@quake.usc.edu>
Subject: How to know if a function takes $_ as a default
Message-Id: <ysizvhduex2i.fsf@nunki.usc.edu>
I want to abbreviate my push()es to `push @X' and have them use $_ as
default, but I have no idea which functions use $_ as default...
for $DENDRITE (keys %meanvm) {
@X=(0);
@Y=(0);
for (sort bynumber keys %{$meanvm{$DENDRITE}}) {
push @X, $_;
push @Y,$meanvm{$DENDRITE}{$_});
}
--
Terrence Brannon * brannon@lnc.usc.edu * http://lnc.usc.edu/~brannon
(213) 740-3397 [office] (323) 294-3028 [home]
------------------------------
Date: 15 May 1999 05:40:58 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: How to know if a function takes $_ as a default
Message-Id: <slrn7jq27a.mgs.sholden@pgrad.cs.usyd.edu.au>
On 14 May 1999 22:11:51 -0700, tbrannon <brannon@quake.usc.edu> wrote:
>
>I want to abbreviate my push()es to `push @X' and have them use $_ as
>default, but I have no idea which functions use $_ as default...
Functions are documented in thr perlfunc documentation that comes with
perl. It tells you which functions use $_ in some way. The documentation
for push doesn't mention it so I would assume it does not.
--
Sam
The very fact that it's possible to write messy programs in Perl is also
what makes it possible to write programs that are cleaner in Perl than
they could ever be in a language that attempts to enforce cleanliness.
--Larry Wall
------------------------------
Date: 14 May 1999 20:48:46 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Looking for autoresponder script !
Message-Id: <7hi27e$ge$1@gellyfish.btinternet.com>
On Thu, 13 May 1999 15:45:50 GMT cindycrawford@my-dejanews.com wrote:
> you can find free scripts at
> http://cgi-shop.com
>
Didnt I suggest to you that cease to do this spam ? - There is nothing
to do with 'autoresponders' at your site.
A: *plonk*
B: As I said previously I am go to make an abuse complaint to DejaNews and
to starnets.ro <despite the fact they seem to only connect by satellite>.
Bye Bye
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 15 May 1999 01:32:37 -0400
From: Jason Larke <jlarke@ans.net>
Subject: Re: man pages and FAQs: why posted?
Message-Id: <vat3e0yx5hm.fsf@anthem.aa.ans.net>
>>>>> On 14 May 1999 18:28:46 -0700, Tom Christiansen
>>>>> <tchrist@mox.perl.com> said:
TC> That's a shame. As soon as I put out enough fires and slay
TC> enough alligators, I fully intend, in a rather dispassionate
TC> sort of way, to put a bullet through perldoc's head.
What will replace it? Where *should* we be pointing people?
I want to do the right thing. Please tell me what it is.
------------------------------
Date: Sat, 15 May 1999 00:30:40 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: man pages and FAQs: why posted?
Message-Id: <B36270B096685F70D4@204.112.166.88>
In article <373CC2C0.DB462D67@cts.wustl.edu>,
Elaine Ashton <elaine@cts.wustl.edu> wrote:
>There is already a weekly posting of "Where to find the FAQ" I believe.
>Mr. Christiansen has c.l.p.m. on a 2 hour offset feed of Perl
>documentation which serves as a public review as well as fodder for
>dejanews and other search engines. Think of it as an information IV :)
drip... drip...
Thank you.
Lee
------------------------------
Date: 15 May 1999 07:20:56 GMT
From: austin95002887@yahoo.com (Austin Ming)
Subject: open, read,then print a file
Message-Id: <7hj78o$atj$2@justice.csc.cuhk.edu.hk>
How to open, read,then print a text.txt file to the browser in current
dierectory ?
------------------------------
Date: Sat, 15 May 1999 08:44:17 GMT
From: "Stephen Warren" <swarren@www.wwwdotorg.org>
Subject: Re: open, read,then print a file
Message-Id: <Bta%2.1464$6x6.1885@news.rdc1.sfba.home.com>
Austin Ming <austin95002887@yahoo.com> wrote in message
news:7hj78o$atj$2@justice.csc.cuhk.edu.hk...
>
> How to open, read,then print a text.txt file to the browser in current
> dierectory ?
You might start your script with:
#!/usr/local/bin/perl -w
use strict ;
You might want to read the following:
perldoc -f open
to find out how to open a file
perldoc perlop
and search for "I/O Operators", to learn how to read the file
perlfoc -f close
to find out how to close a file
perldoc -f print
to find out how to print the HTTP headers and file data to the browser.
It sounds like you should might also benefit from getting a good
introductory book on Perl and/or CGI. Reads the FAQS for this newsgroup
and/or comp.infosystems.www.authoring.cgi. Also, there's a current thread
here about which Perl books are good.
--
Stephen Warren, Snr Systems Engineer, Technology House, San Francisco
mailto:swarren@techhouse.com http://www.techhouse.com/
mailto:swarren@wwwdotorg.org http://www.wwwdotorg.org/
MIME, S/MIME and HTML mail are acceptable
------------------------------
Date: Sat, 15 May 1999 08:40:16 GMT
From: "Stephen Warren" <swarren@www.wwwdotorg.org>
Subject: Re: Parameter pass to PERL
Message-Id: <Qpa%2.1449$6x6.2096@news.rdc1.sfba.home.com>
Raymond Ip <rwmip@glink.net.hk> wrote in message
news:7hitpk$o2u$1@unix2.glink.net.hk...
> If I written a perl script to run it under UNIX environment, and want to
> pass some parameter to the perl script.
>
> How do I check how many parameter pass to the script ?
I'm assuming non-CGI here, since you say Unix instead of a Web-server.
There's a variable called @ARGV. You can read all about it by executing:
perldoc perlvar
It's a standard perl array of the command-line parameters.
--
Stephen Warren, Snr Systems Engineer, Technology House, San Francisco
mailto:swarren@techhouse.com http://www.techhouse.com/
mailto:swarren@wwwdotorg.org http://www.wwwdotorg.org/
MIME, S/MIME and HTML mail are acceptable
------------------------------
Date: 14 May 1999 23:39:17 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Perl "constructors"
Message-Id: <ylzp366dm2.fsf@windlord.stanford.edu>
armchair <armchair@my-dejanews.com> writes:
> I can speak to this: connect() and prepare() should be member functions
> and not constructors as a member function can return a status code of
> success or various error codes. A constructor cannot.
Constructors certainly can return various error codes, as well as success
or failure.
> In any event, you can't get around the fact that constructors return a
> blessed reference. It's nice for functions that can fail, to return
> error codes. Or perhaps you are printing error messages and exiting your
> program when your constructors fail??
Have you heard of exceptions?
> I don't think it is too much to ask for a function, a complement to
> "exists" if you will, that tells how many items are in a hash.
What, like $count = keys %hash?
> How about: %hash = ();
> if (entries($hash) > 0 )
Ew.
What about
if (%hash) {
# ...
}
Much, much simpler, and then you don't even have to worry about this
problem.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Sat, 15 May 1999 08:19:00 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: PERLFUNC: hex - convert a string to a hexadecimal number
Message-Id: <ebohlmanFBrLro.6E7@netcom.com>
Tom Christiansen <perlfaq-suggestions@perl.com> wrote:
: NAME
: hex - convert a string to a hexadecimal number
This description is syntactically awkward if not downright misleading;
one could forgive someone who skimmed the description and thought the
function was supposed to create a hex-formatted numeric string. How
about "convert a string of hexadecimal digits to a number"?
------------------------------
Date: Sat, 15 May 1999 07:37:32 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Reading a file in variable
Message-Id: <ebohlmanFBrJuK.4nz@netcom.com>
Stephen Warren <swarren@www.wwwdotorg.org> wrote:
: As far as splitting the lines up into fields, there are three common ways.
: It sounds like all your lines are fixed-length, so the quickest thing to
: do is use substr (perldoc -f substr) and give it the character offsets for
: each field.
In a case like this with lots of fixed-length fields, I'd suggest the
fourth common way: using unpack(). ISTR from benchmarks that it's
slightly faster than multiple substr's (since it involves fewer Perl ops),
but more importantly it's less error-prone because you need to specify
only *one* number (length) per field rather than two (offset and length).
------------------------------
Date: Fri, 14 May 1999 15:28:12 -0700
From: "Dan Daffer" <ddaffer@helixelectric~NOSPAM~.com>
Subject: Rename directory
Message-Id: <7hib8e$4ddr3@news.gomontana.com>
Sorry, I know this must be a simple one. I _have_ looked at the
documentation and couldn't find the answer. I have 3 books and none of them
have anything on renaming directories (throw them out?).
This can be done with perl, right!? The directories may have files in them,
but never any subdirectories. This will be used in a CGI script on a unix
server running Apache and perl5.
Thanks,
Dan Daffer
------------------------------
Date: 14 May 1999 23:55:24 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Rename directory
Message-Id: <ylogjm6cv7.fsf@windlord.stanford.edu>
Dan Daffer <ddaffer@helixelectric~NOSPAM~.com> writes:
> Sorry, I know this must be a simple one. I _have_ looked at the
> documentation and couldn't find the answer. I have 3 books and none of
> them have anything on renaming directories (throw them out?).
rename() will rename directories just fine.
> This can be done with perl, right!? The directories may have files in
> them, but never any subdirectories.
They can have subdirectories too.
You can't, however, rename a directory to a name on a different device
than its original location. In other words, you can only use rename to
move things to other places in the same file system.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Sat, 15 May 1999 00:35:04 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Rename directory
Message-Id: <MPG.11a6c37fb407993f989a6e@nntp.hpl.hp.com>
In article <7hib8e$4ddr3@news.gomontana.com> on Fri, 14 May 1999
15:28:12 -0700, Dan Daffer <ddaffer@helixelectric~NOSPAM~.com> says...
> Sorry, I know this must be a simple one. I _have_ looked at the
> documentation and couldn't find the answer. I have 3 books and none of them
> have anything on renaming directories (throw them out?).
Why? Have the directories done something wrong? Keep them and throw
out the books.
Anyhow, the books are not the Perl documentation, which seems clear
enough that the answer is implementation-dependent (see below).
> This can be done with perl, right!? The directories may have files in them,
> but never any subdirectories. This will be used in a CGI script on a unix
> server running Apache and perl5.
perldoc -f rename
rename OLDNAME,NEWNAME
Changes the name of a file. Returns 1 for success, otherwise. Behavior
of this function varies wildly depending on your system implementation.
For example, it will usually not work across file system boundaries,
even though the system mv command sometimes compensates for this. Other
restrictions include whether it works on directories, open files, or
pre-existing files. Check perlport and either the rename(2) manpage or
equivalent system documentation for details.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 15 May 1999 08:23:07 GMT
From: dave@dave.org.uk (Dave Cross)
Subject: Re: Sending E-Mail via PERL (CGI)
Message-Id: <373f2e89.4942743@news.demon.co.uk>
On Fri, 14 May 1999 17:49:23 -0500, therzog@knotech.com (Tim Herzog)
wrote:
>In article <7hi2nu$rpc$1@news6.svr.pol.co.uk>, "Mug-O-Milk"
><webmaster@*nospam*mugomilk.freeserve.co.uk> wrote:
>
>
>>How do you send E-Mail (i.e. a confirmation e-mail) using Perl?
>>I'm semi new to perl, so a list of commands would be fine, as I don't
>>understand it in me LLAMA book :O(
>
>I'm sure there's a module out there that can do this better (check CPAN),
>but here's the quick and dirty method:
[snip]
>Perhaps someone else can suggest modules that are less platform dependent
>and/or safer and/or more flexible.
Get the MailTools bundle from CPAN. It includes Mail::Mailer and
Mail::Send
Dave...
Dave Cross <dave@dave.org.uk>
<http://www.dave.org.uk>
------------------------------
Date: 15 May 1999 07:57:38 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Sending E-Mail via PERL (CGI)
Message-Id: <7hj9di$12r$1@gellyfish.btinternet.com>
On Fri, 14 May 1999 17:49:23 -0500 Tim Herzog wrote:
> In article <7hi2nu$rpc$1@news6.svr.pol.co.uk>, "Mug-O-Milk"
> <webmaster@*nospam*mugomilk.freeserve.co.uk> wrote:
>
>
>>How do you send E-Mail (i.e. a confirmation e-mail) using Perl?
>>I'm semi new to perl, so a list of commands would be fine, as I don't
>>understand it in me LLAMA book :O(
>
> I'm sure there's a module out there that can do this better (check CPAN),
> but here's the quick and dirty method:
>
> open EMAIL, "|/usr/lib/sendmail -t" or die "Can't open sendmail $!";
>
> print EMAIL<<THEEND
> To: recipient\@somewhere.com
> From: sender\@somewhere.com
> Subject: subject
>
> Text of the message here
> THEEND
>
close(EMAIL) || die "There was an error with sendmail - $?\n";
The error on the open will only tell whether the inital fork() failed.
>
> Perhaps someone else can suggest modules that are less platform dependent
> and/or safer and/or more flexible.
>
In perlfaq9 there is a section on this subject.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 15 May 1999 05:56:26 GMT
From: Pete Dirksen <pdirksen@shell5.ba.best.com>
Subject: time-ordered file array
Message-Id: <373d0c8a$0$204@nntp1.ba.best.com>
I want to create an array of files which are ordered chronologically by
modification time, along the lines of "ls -ltT".
Heres the code which someone suggested for me, which *almost* works, even
tho i'm still wrapping my head around S.T's....can someone figure out
whats going wrong here?
@allfiles = grep !/^\./, readdir BLURBDIR;
@sorted_files = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_,
-A $_ ] } @allfiles;
thanks!
pete
--
"Pistol" Pete Dirksen (pdirksen@best.com)
http://www.pistol.net
Northwestern University, CompSci/Econ '00 ('01?)
------------------------------
Date: Fri, 14 May 1999 23:44:50 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: time-ordered file array
Message-Id: <MPG.11a6b7b01e3941c8989a6c@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <373d0c8a$0$204@nntp1.ba.best.com> on 15 May 1999 05:56:26
GMT, Pete Dirksen <pdirksen@shell5.ba.best.com> says...
> I want to create an array of files which are ordered chronologically by
> modification time, along the lines of "ls -ltT".
>
> Heres the code which someone suggested for me, which *almost* works, even
> tho i'm still wrapping my head around S.T's....can someone figure out
> whats going wrong here?
>
> @allfiles = grep !/^\./, readdir BLURBDIR;
>
> @sorted_files = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_,
> -A $_ ] } @allfiles;
You have the ST right (though folding the code over three lines would
make it more readable).
You have not shown the 'opendir BLURBDIR' statement. Unless that is
also the current directory, you must prefix the directory name to $_
before doing a file test such as -A. (This is about the fourth time
someone has made that mistake here this week!)
And the modification time is given by -M, in any case.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 14 May 1999 23:54:01 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: time-ordered file array
Message-Id: <ylr9oi6cxi.fsf@windlord.stanford.edu>
Pete Dirksen <pdirksen@shell5.ba.best.com> writes:
> I want to create an array of files which are ordered chronologically by
> modification time, along the lines of "ls -ltT".
> Heres the code which someone suggested for me, which *almost* works,
> even tho i'm still wrapping my head around S.T's....can someone figure
> out whats going wrong here?
For future reference, it's much better if you say exactly *what* isn't
working right.
> @sorted_files = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_,
> -A $_ ] } @allfiles;
You're sorting by access time, not modification time. You want -M instead
of -A.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 14 May 1999 23:47:29 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: uninitialized value
Message-Id: <ylu2te6d8e.fsf@windlord.stanford.edu>
ktb <xyf@inetnebr.com> writes:
> Hi, I'm writing this script to search a database. It works fine when I
> search the first split, "$parts[0]" but if I try to search "$parts[1]" I
> get the following errors:
> Use of uninitialized value at ./testst line 19, <BottleFile> chunk
> 11461.
> Use of uninitialized value at ./testst line 19, <BottleFile> chunk
> 11461.
Are you sure that line contains a tab? If it doesn't, $parts[1] won't be
set and you'll get that error.
> open(BottleFile, "botglass.txt");
Always check the return status of open(), just in case.
> @bottle = <BottleFile>;
> foreach $line (@bottle) {
More easily written as:
foreach $line (<BottleFile>) {
or even:
while (<BottleFile>) {
for more efficiency.
> @parts = split(/\t/, $line );
> $PartsFile = $parts[1];
> } continue {
Why do this in a continue block?
> foreach ($PartsFile) {
> if (/\Q$SearchString/i) {
Why use foreach? You can just say:
if ($PartsFile =~ /\Q$SearchString/i) {
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Sat, 15 May 1999 08:03:48 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Which book do you recommend?
Message-Id: <ebohlmanFBrL2C.5sp@netcom.com>
Lacrosse_20 <mcti@my-dejanews.com> wrote:
: Hey guys. I just posted this, but it isn't showing up in my list, so
: I'm reposting. I am planning on buying a new "advanced" perl book, but
: I don't know which book would give me the best instruction for my $.
: The ones I'm looking at are Perl Cookbook; Tom Christiansen, et
: al, Programming Perl, 2nd Edition (covers Perl 5.0); Larry Wall
: (Editor), et al, Mastering Regular Expressions: Powerful Techniques for
: Perl and Other Tools; Jeffrey E. F. Friedl, and Advanced Perl
: Programming; Sriram Srinivasan. Which of these is the best? Maybe
: there's one out there that I didn't list that's better than these...if
: so, what is it? Thanks in advance for your input.
Ideally, you should get all of them. I presume, though, that you don't
have the budget for that (but note that this month O'Reilly is supposed
to be releasing a CD-ROM that has the texts of all those books (except
possibly the Friedl book; check O'Reilly's site for details) and costs
less than any two of them), and therefore need to prioritize them. How
to do this really depends on where you are and where you want to go; I'm
going to guess that you're approximately at the level of having finished
the Llama book.
While _Programming Perl_ (the Camel) is an outstanding reference, you
*could* skip over it for the time being if you're already on (or willing
to get on) intimate terms with Perl's online documentation. If you have
any doubts, though, I'd give it first priority.
If you best learn a language from examples, or just want to be able to
quickly get the answers to a bunch of "how do I do this" questions, then
the _Perl Cookbook_ (the Ram) is for you. It's probably fruitful to look
at the Camel and the Ram as two volumes of one book (the first edition of
the Camel contained many of the code examples in the Ram, but of course
everything then was written for Perl 4).
_Advanced Perl Programming_ (the Panther) is really a collection of
independent in-depth discussions on various Perl topics: references and
data structures, typeglobs and eval, modules and object-oriented
programming, data persistence, networking, GUIs with Tk, code generation,
extending Perl with C functions, and embedding Perl in C programs. If
one or more of those topics is of special interest to you, get the Ram.
_Mastering Regular Expressions_ (the Hip Owls) is one of those books that
you don't really need most of the time, but that occasionally becomes
absolutely essential. If you have a good grasp of Perl regular
expressions and don't routinely need to do extremely tricky pattern
matching, you can put this one off until the need for it hits you in the
face. If you're weak on regexen, I'd make it a goal to afford it.
------------------------------
Date: Fri, 14 May 1999 22:37:37 -0700
From: "Chrissy Murray" <murray@ecst.csuchico.edu>
Subject: Win32::ODBC FetchRow problem
Message-Id: <7hj12s$c1f$1@hubble.csuchico.edu>
Hello,
I'm using Win32::ODBC and SQLServer 6.0
The problem:
Small selections from the database run fine, but when I select large
amounts of data from the database the FetchRow function produces the
following error: [911] [1] [0] "[Microsoft][ODBC Driver Manager] Function
sequence error"
Is there anything I can do to keep the error from occurring?
Any help would be greatly appreciated.
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5669
**************************************