[9216] in Perl-Users-Digest
Perl-Users Digest, Issue: 2811 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 8 12:08:48 1998
Date: Mon, 8 Jun 98 09:00:28 -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 Mon, 8 Jun 1998 Volume: 8 Number: 2811
Today's topics:
Re: - sort with DBM key output... - <james@cydaps.co.uk.NOSPAM>
Re: -d ? 3 : 7 is ambiguous, how comes? (M.J.T. Guy)
Re: -d ? 3 : 7 is ambiguous, how comes? <jdporter@min.net>
Re: [EUREKA] Yes, I think it is (was Re: No, It's Not ( <jdporter@min.net>
Re: accessing Oracle (John D Groenveld)
Day of Week Display for User-defined date <kcl@mindspring.com>
Re: Day of Week Display for User-defined date <tchrist@mox.perl.com>
Re: Day of Week Display for User-Input Date (Mike Stok)
Re: Day of Week Display for User-Input Date <quednauf@nortel.co.uk>
Delete all files in a directory womlake@zip.com.au
Re: Delete all files in a directory <tchrist@mox.perl.com>
Re: Delete all files in a directory (Larry Rosler)
File::Find examples <tchrist@mox.perl.com>
Re: Foreach Efficiency <jdporter@min.net>
Re: I'm having problems: (Tom Grydeland)
Re: I'm having problems: <zenin@bawdycaste.org>
Re: I'm having problems: <mana@technologist.com>
Re: I'm having problems: (Tom Grydeland)
Re: I'm having problems: (I R A Aggie)
Re: Is PERL case sensitive? <jdporter@min.net>
Re: Lotus Notes from perl? murple@erols.com
Mail Headers being set through Mail library <salexson@null.connix.com>
Re: Perl module for doing a unix 'which'? (Stuart McDow)
Re: Perl module for doing a unix 'which'? <tchrist@mox.perl.com>
Re: Problem with re-iterating if loops... (Abigail)
Re: Q: apply func to mutate list; oneliner (M.J.T. Guy)
Re: Question about four-argument select use <lwp@flenser.ibm.net>
Re: question (Abigail)
Script Auto-restart - using -M file test - Cannonical w (Jeremy Mathers)
Re: Script Auto-restart - using -M file test - Cannonic (Matt Knecht)
Re: thumbnails (Abigail)
Re: what's a cross-platform \n please? (Abigail)
Re: Why is there no "in" operator in Perl? (Abigail)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 8 Jun 1998 16:42:11 +0100
From: "James" <james@cydaps.co.uk.NOSPAM>
Subject: Re: - sort with DBM key output... -
Message-Id: <897320654.29089.0.nnrp-08.c2de3f1b@news.demon.co.uk>
James wrote in message
<897229567.5993.0.nnrp-07.c2de3f1b@news.demon.co.uk>...
>Hi,
>
>I was wondering if anyone would be able to help me? I have been though all
>the help files and FAQs etc but with no luck..
Don't worry about this message, I have manged to solve the problem now. :-)
Thanks
James
>
------------------------------
Date: 8 Jun 1998 14:20:34 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: -d ? 3 : 7 is ambiguous, how comes?
Message-Id: <6lgrvi$pkd$1@pegasus.csx.cam.ac.uk>
Larry Rosler <lr@hpl.hp.com> wrote:
>
>Neither my tests on 5.004_03 nor those of Xuming Wang on 5.004_02 show
>that behavior -- it simply does nothing. Is this Yet Another Version
>Problem, in 5.004_04 perhaps? I don't have one at hand (yet) to check
>it myself.
Executing the script 'w' is one way of "doing nothing". Remember that
you don't have -w set. :-)
Mike Guy
------------------------------
Date: Mon, 08 Jun 1998 14:21:16 GMT
From: John Porter <jdporter@min.net>
Subject: Re: -d ? 3 : 7 is ambiguous, how comes?
Message-Id: <357BF4E6.2341@min.net>
LR> And you would probably be wise to type
LR> 'perl -ew' instead of 'perl -e' in any case.
MJTG> Only if you really wanted to execute the script 'w'.
LR> Neither my tests on 5.004_03 nor those of Xuming Wang on
LR> 5.004_02 show that behavior -- it simply does nothing.
That's because the script consisting of the single letter w
does nothing.
1% perl -ew
2% perl -wew
Unquoted string "w" may clash with future reserved word at -e line 1.
Useless use of a constant in void context at -e line 1.
So it's not doing "nothing", exactly...
John Porter
------------------------------
Date: Mon, 08 Jun 1998 15:32:06 GMT
From: John Porter <jdporter@min.net>
Subject: Re: [EUREKA] Yes, I think it is (was Re: No, It's Not (was Re: Yes, it is))
Message-Id: <357C0582.36FA@min.net>
Russell Schulz wrote:
>
> I wonder if the original `Yes it is' was misposted in response to the
> `Is perl case-sensitive' question.
>
> in which case `No, It's Not' is wrong.
I think you're right. I didn't make the connection at the time.
I shouldn't have to -- the fool didn't followup, he posted a
brand new message.
John Porter
------------------------------
Date: 8 Jun 1998 10:31:31 -0400
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: accessing Oracle
Message-Id: <6lgsk3$e24$1@tholian.cse.psu.edu>
>b) I don't have SQL*Net
Get SQL*Net. Its included with the Try-n-Buy version of Oracle Workgroup
server.
John
groenveld@acm.org
------------------------------
Date: Mon, 08 Jun 1998 10:07:41 -0400
From: KC Lucchese <kcl@mindspring.com>
Subject: Day of Week Display for User-defined date
Message-Id: <357BF02D.977101F2@mindspring.com>
Please pardon a question that might have been asked a thousand times
before! I know just enough PERL to be dangerous and to support someone
else's scripts (which is what I'm doing)...
I need to display the day of the week (Sunday, Monday, etc.) for a date
which the user chooses from a drop-down list.
Is there a way to do this????
Thanks!
KC
------------------------------
Date: 8 Jun 1998 14:35:46 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Day of Week Display for User-defined date
Message-Id: <6lgss2$tm$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
KC Lucchese <kcl@mindspring.com> writes:
:Please pardon a question that might have been asked a thousand times
:before! I know just enough PERL to be dangerous and to support someone
:else's scripts (which is what I'm doing)...
:
:I need to display the day of the week (Sunday, Monday, etc.) for a date
:which the user chooses from a drop-down list.
What's a "drop-down list"? Would that be @array or %drop?
:Is there a way to do this????
Of course!!!!!
But you haven't read about dates in the perlfaq, so you don't
know about the Date::Manip module from CPAN.
--tom
--
If God had meant for us to be naked, we would have been born that way.
------------------------------
Date: 8 Jun 1998 16:00:33 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Day of Week Display for User-Input Date
Message-Id: <6lh1r1$gpl@news-central.tiac.net>
If you're using a modern perl then one of the first places to look after
reading likely sections of the supplied documents (man pages & the FAQ -
list of frequently asked questions) is CPAN (the comprehensive perl
archive network). One way to find it is to fillow the CPAN links at
http://www.perl.com
I use the Time-modules already and they are just one of the modules whiche
deal in dates & times. The Time::JulianDay module includes this
documentation:
NAME
Time::JulianDay -- Julian calendar manipulations
SYNOPSIS
use Time::JulianDay
$jd = julian_day($year, $month_1_to_12, $day)
$jd = local_julian_day($seconds_since_1970);
$jd = gm_julian_day($seconds_since_1970);
($year, $month_1_to_12, $day) = inverse_julian_day($jd)
$dow = day_of_week($jd)
print (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[$dow];
I'm not saying that this is the best module, there are aother very
flexible modules on CPAN. On CPAN you can find the README file in the
archives which has been broken out so you can get an idea whether the
module does what you want.
Other ways top do it might invilve using Time::Local to convert a dd mm
yyyy date into a time value and then using localtime to get the day of the
week (but check the values you pass into Time::Local)
Hope this helps,
Mike
In article <357BDE18.B4781F@mindspring.com>,
KC Lucchese <kcl@mindspring.com> wrote:
>Pardon what may be a question that's been asked a thousand times before!
>I know just enough PERL to be dangerous and to support someone else's
>application, so take it easy on me, OK?
>
>I have a script that passes a user-selected date to another script and I
>want to display the day of week (Sunday, Monday, Tuesday, etc.) for that
>day... I've tried everything I can find via the PERL references both in
>print (very limited) and on the internet (very old)....
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Mon, 08 Jun 1998 16:15:09 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: Day of Week Display for User-Input Date
Message-Id: <357BFFFD.BFE86A86@nortel.co.uk>
KC Lucchese wrote:
> ...to display the day of week (Sunday, Monday, Tuesday, etc.) for that
> day...
>
> Can anyone give me some ideas on how to do this????
use Time::gmtime;$time = gmtime();
printf "weekday is: %day", (qw(Sun Mon Tues Wednes Thurs Fri
Satur))[$time->wday()];
Hope it helps, hope it works.
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: Tue, 09 Jun 1998 00:11:48 +0100
From: womlake@zip.com.au
Subject: Delete all files in a directory
Message-Id: <357C6FB4.373@zip.com.au>
Can anyone assist me with the syntax for deleting all files in a given
directory????
Hope someone can help. Ok I know it sounds simple but I can't do it.
Warren
------------------------------
Date: 8 Jun 1998 15:11:21 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Delete all files in a directory
Message-Id: <6lguup$2p0$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
womlake@zip.com.au writes:
:Can anyone assist me with the syntax for deleting all files in a given
:directory????
>From your shell:
rm -r directory
This is unrelated to Perl, of course.
--tom
--
"The reasonable man conforms himself to his environment. The
unreasonable man conforms his environment to himself. Therefore
all change depends on the unreasonable man."
------------------------------
Date: Mon, 8 Jun 1998 08:01:16 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Delete all files in a directory
Message-Id: <MPG.fe59c968c4189e09896af@nntp.hpl.hp.com>
In article <357C6FB4.373@zip.com.au>, womlake@zip.com.au says...
> Can anyone assist me with the syntax for deleting all files in a given
> directory????
> Hope someone can help. Ok I know it sounds simple but I can't do it.
>
> Warren
>
my $dir_name = '/absolute/pathname/of/directory';
opendir DIR, $dir_name or die "couldn't open $dir_name. $!.";
unlink map "$dir_name/$_", grep !/^\.\.?$/, readdir DIR or
die "couldn't unlink $dir_name. $!.";
closedir DIR;
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 8 Jun 1998 14:34:06 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: File::Find examples
Message-Id: <6lgsou$tm$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, Tom.Grydeland@phys.uit.no (Tom Grydeland) writes:
:Except find2perl doesn't use it. (as of 5.004_04)
Ouch.
:This is in fact a *big* disadvantage, since a find2perl which did would
:provide a multitude of examples for potential File::Find users.
:
:... and the find manpage is not very friendly.
Ok, here are some examples. I'll let you guess whence they derive. :-)
--tom
+--------------------------------------------------------+
| Print all files, directories having an appended slash. |
+--------------------------------------------------------+
@ARGV = qw(.) unless @ARGV;
use File::Find;
find sub { print $File::Find::name, -d && '/', "\n" }, @ARGV;
+------------------------------+
| Find the size of a directory |
+------------------------------+
$dirsize = -s $DIRECTORY;
+---------------------------------------------------+
| Find what people mean by the size of a directory |
+---------------------------------------------------+
use File::Find;
@ARGV = ('.') unless @ARGV;
my $sum = 0;
find sub { $sum += -s }, @ARGV;
print "@ARGV contains $sum bytes\n";
+----------------------------------------------------------------+
| Find the largest single file within a given set of directories |
+----------------------------------------------------------------+
use File::Find;
@ARGV = ('.') unless @ARGV;
my ($saved_size, $saved_name) = (-1, '');
sub biggest {
return unless -f && -s _ > $saved_size;
$saved_size = -s _;
$saved_name = $File::Find::name;
}
find(\&biggest, @ARGV);
print "Biggest file $saved_name in @ARGV is $saved_size bytes long.\n";
+-------------------------------------+
| Find the most recently changed file |
+-------------------------------------+
use File::Find;
@ARGV = ('.') unless @ARGV;
my ($age, $name);
sub youngest {
return if defined $age && $age > -M;
$age = (stat(_))[9];
$name = $File::Find::name;
}
find(\&youngest, @ARGV);
print "$name " . scalar(localtime($age)) . "\n";
+----------------------+
| Find all directories |
+----------------------+
#!/usr/bin/perl -lw
# fdirs - find all directories
@ARGV = qw(.) unless @ARGV;
use File::Find ();
sub find(&@) { &File::Find::find }
*name = *File::Find::name;
find { print $name if -d } @ARGV;
And here's my pmdesc program, which uses File::Find. It prints out the
names, versions, and descriptions of all modules installed on your system.
To run it, simply type:
% pmdesc
It prints a list of modules and their descriptions:
FileHandle (2.00) - supply object methods for filehandles
IO::File (1.06021) - supply object methods for filehandles
IO::Select (1.10) - OO interface to the select system call
IO::Socket (1.1603) - Object interface to socket communications
...
--tom
#!/usr/bin/perl -w
# pmdesc - describe pm files
# tchrist@perl.com
use strict;
use File::Find qw(find);
use Getopt::Std qw(getopts);
use Carp;
use vars (
q!$opt_v!, # give debug info
q!$opt_w!, # warn about missing descs on modules
q!$opt_a!, # include relative paths
q!$opt_s!, # sort output within each directory
);
$| = 1;
getopts('wvas') or die "bad usage";
@ARGV = @INC unless @ARGV;
# Globals. wish I didn't really have to do this.
use vars (
q!$Start_Dir!, # The top directory find was called with
q!%Future!, # topdirs find will handle later
);
my $Module;
# install an output filter to sort my module list, if wanted.
if ($opt_s) {
if (open(ME, "-|")) {
$/ = '';
while (<ME>) {
chomp;
print join("\n", sort split /\n/), "\n";
}
exit;
}
}
MAIN: {
my %visited;
my ($dev,$ino);
@Future{@ARGV} = (1) x @ARGV;
foreach $Start_Dir (@ARGV) {
delete $Future{$Start_Dir};
print "\n<<Modules from $Start_Dir>>\n\n"
if $opt_v;
next unless ($dev,$ino) = stat($Start_Dir);
next if $visited{$dev,$ino}++;
next unless $opt_a || $Start_Dir =~ m!^/!;
find(\&wanted, $Start_Dir);
}
exit;
}
# calculate module name from file and directory
sub modname {
local $_ = $File::Find::name;
if (index($_, $Start_Dir . '/') == 0) {
substr($_, 0, 1+length($Start_Dir)) = '';
}
s { / } {::}gx;
s { \.p(m|od)$ } {}x;
return $_;
}
# decide if this is a module we want
sub wanted {
if ( $Future{$File::Find::name} ) {
warn "\t(Skipping $File::Find::name, qui venit in futuro.)\n"
if 0 and $opt_v;
$File::Find::prune = 1;
return;
}
return unless /\.pm$/ && -f;
$Module = &modname;
# skip obnoxious modules
if ($Module =~ /^CPAN(\Z|::)/) {
warn("$Module -- skipping because it misbehaves\n");
return;
}
my $file = $_;
unless (open(POD, "< $file")) {
warn "\tcannot open $file: $!";
# if $opt_w;
return 0;
}
$: = " -:";
local $/ = '';
local $_;
while (<POD>) {
if (/=head\d\s+NAME/) {
chomp($_ = <POD>);
s/^.*?-\s+//s;
s/\n/ /g;
#write;
my $v;
if (defined ($v = getversion($Module))) {
print "$Module ($v) ";
} else {
print "$Module ";
}
print "- $_\n";
return 1;
}
}
warn "\t(MISSING DESC FOR $File::Find::name)\n"
if $opt_w;
return 0;
}
# run Perl to load the module and print its verson number, redirecting
# errors to /dev/null
sub getversion {
my $mod = shift;
my $vers = `$^X -m$mod -e 'print \$${mod}::VERSION' 2>/dev/null`;
$vers =~ s/^\s*(.*?)\s*$/$1/; # remove stray whitespace
return ($vers || undef);
}
format =
^<<<<<<<<<<<<<<<<<~~^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$Module, $_
.
--
There is a need to keep from being locked into Open Systems. --IBM sales rep
------------------------------
Date: Mon, 08 Jun 1998 14:46:49 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Foreach Efficiency
Message-Id: <357BFAE3.4EAC@min.net>
Peter A Fein wrote:
>... the majority of questions tend to get RTFM's
> or use module X responses. I will readily conceed that many of the
> question deserve such responses (ie, "How do I send mail from a CGI?"
> & the like), but people seem a little too eager to respond in this
> manner, as I think happened here.
I do not understand how suggesting that someone do a little
experimentation with the interpreter can be construed as "RTFM".
I do, unfortunately, understand how someone might construe
"That's a good inclination to have" as something other than
essentially "Yes".
John Porter
------------------------------
Date: 8 Jun 1998 13:57:45 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: I'm having problems:
Message-Id: <slrn6nnreo.ve4.Tom.Grydeland@mitra.phys.uit.no>
On 7 Jun 1998 23:05:42 GMT,
Tom Christiansen <tchrist@mox.perl.com> wrote:
> Misleading? Hello? It's entirely obvious, since it's an emulation of
> the standard find program, as used by find2perl.
Except find2perl doesn't use it. (as of 5.004_04)
This is in fact a *big* disadvantage, since a find2perl which did would
provide a multitude of examples for potential File::Find users.
... and the find manpage is not very friendly.
> --tom
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
- Do radioactive cats have 18 half-lives? -
------------------------------
Date: 8 Jun 98 14:54:45 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: I'm having problems:
Message-Id: <897318434.717058@thrush.omix.com>
Tom Grydeland <Tom.Grydeland@phys.uit.no> wrote:
: Except find2perl doesn't use it. (as of 5.004_04)
Err, huh? find2perl builds a wanted() sub for use with File::Find.
Sure, it will build you a full program to an require find.pl (for
reverse compatibility...) but if you check out find.pl in your
later releases (including 5.00404) you'll see it's just a wraper
for File::Find.
: This is in fact a *big* disadvantage, since a find2perl which did would
: provide a multitude of examples for potential File::Find users.
But it does this now, I don't understand?
: ... and the find manpage is not very friendly.
True. At the very least it should give a one line synopsis and
reason for existence. It need not however state any of it's options
because it's an exact mirror of find(1), so a pointer to that page
is all that should be needed for syntax.
--
-Zenin
zenin@archive.rhps.org
------------------------------
Date: 8 Jun 1998 15:22:13 GMT
From: "mana" <mana@technologist.com>
Subject: Re: I'm having problems:
Message-Id: <01bd92f1$afc5ee80$7f8d16ac@dn9n2153c1>
> No. Please don't. Please stop reinventing File::Find. This code is
> broken, as it will follow symlinks incorrectly, off into gaga land,
> even back to where you've been before,
What you did not understand is that I just gave the basic idea about
how the Perl works?
How one can use stack to recurse into Directories?
It is up to the user to accommodate this logic into whatever he wants to
recurse into
This would help if one really wants to write a truly portable PERL code
without using the "EVER CHANGING PERL MODULES"
However thanks for taking time
- mana
------------------------------
Date: 8 Jun 1998 15:42:13 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: I'm having problems:
Message-Id: <slrn6no1ik.7e2.Tom.Grydeland@mitra.phys.uit.no>
On 8 Jun 98 14:54:45 GMT,
Zenin <zenin@bawdycaste.org> wrote:
> Tom Grydeland <Tom.Grydeland@phys.uit.no> wrote:
> : Except find2perl doesn't use it. (as of 5.004_04)
>
> Err, huh? find2perl builds a wanted() sub for use with File::Find.
> Sure, it will build you a full program to an require find.pl (for
> reverse compatibility...) but if you check out find.pl in your
> later releases (including 5.00404) you'll see it's just a wraper
> for File::Find.
Argh, you're absolutely right. My bad.
Switching to nitpicker mode, this still seems an odd way of
demonstrating the "proper" use of a module; wrapping it in a .pl file.
Just C<use File::Find;>9 seems so much better to me.
(Somehow, I thought the .pl files didn't change. Silly or what?)
> : This is in fact a *big* disadvantage, since a find2perl which did would
> : provide a multitude of examples for potential File::Find users.
>
> But it does this now, I don't understand?
Before cracking open find.pl, I wouldn't rely on the subroutines created
by find2perl to work as intended with File::Find. The output of the
former didn't seem to match the manpage description of the latter.
> : ... and the find manpage is not very friendly.
>
> True. At the very least it should give a one line synopsis and
> reason for existence. It need not however state any of it's options
> because it's an exact mirror of find(1), so a pointer to that page
> is all that should be needed for syntax.
Ah, but I was talking about the find(1) manpage. :-)
As for the File::Find(3) manpage, it claims
"This library is primarily for the find2perl tool"
which doesn't seem too inspiring when trying to use it for your own
purposes. I'd recommend taking this sentence out.
> -Zenin
9 ducking
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
- Do radioactive cats have 18 half-lives? -
------------------------------
Date: Mon, 08 Jun 1998 11:38:58 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: I'm having problems:
Message-Id: <fl_aggie-0806981138580001@aggie.coaps.fsu.edu>
In article <897318434.717058@thrush.omix.com>, Zenin
<zenin@bawdycaste.org> wrote:
+ True. At the very least it should give a one line synopsis and
+ reason for existence. It need not however state any of it's options
+ because it's an exact mirror of find(1), so a pointer to that page
+ is all that should be needed for syntax.
Ah, but not everyone has access to unix...
Oh, yeah, linux...sorry...
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>
------------------------------
Date: Mon, 08 Jun 1998 15:42:45 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Is PERL case sensitive?
Message-Id: <357C0800.5BDA@min.net>
REUBEN LOGSDON wrote:
>
> On 5 Jun 1998, Martien Verbruggen wrote:
>
> > Subject: Is PERL case sensitive?
> >
> > Depends what you mean.
> >
> > It is perl for the program, Perl for the language. Never PERL.
> >
> > That is case sensitive. The program perl, and the language Perl are
> > both case sensitive as well. I don't really know about PERL.
>
> PERL is an acroynm for "Practical Extraction and Report Language". It's
> common practice to capitalize acronyms.
Hmm, you are correcting Martien?
Maybe you should get your facts straight, then.
One good way to do that is to read "History Made Practical",
p. 554 in the Camel book.
John Porter
------------------------------
Date: 8 Jun 1998 14:51:08 GMT
From: murple@erols.com
Subject: Re: Lotus Notes from perl?
Message-Id: <6lgtos$gn$1@winter.news.erols.com>
Andrew Gruskin <agruskin@melbpc.org.au> scribbled:
: Using Win32::OLE you can drive Notes. I have Perl scripts creating Notes
: documents and then sending (emaiing) them.
I'm using perl scripts on a Linux box, however. It's not possible to use
Win32::OLE from Linux, is it?
/-------------------------------------------------------------\
/| Craig Schenk | The statement below is the truth. |\
\| murple@erols.com | The statement above is a lie. |/
\-------------------------------------------------------------/
------------------------------
Date: Mon, 8 Jun 1998 12:32:10 -0400
From: "Steven Alexson" <salexson@null.connix.com>
Subject: Mail Headers being set through Mail library
Message-Id: <6lh088$8a6@beast.connix.com>
I am having some trouble setting mail headers through the Mail libraries in
Perl. When I use "test" as the sending method (as shown below) The headers
appear to be correct. When I use "mail" or "sendmail" as the sending
method, the message is sent properly, but none of the headers are sent. I
have tried not specifying the mail method (omitted the use Mail:Mailer line
completely), and there is no change. It still doesn't send the headers. Any
ideas? Please e-mail any feedback to salexson@connix.com.
TIA
Here is my code:
# BEGIN CODE BLOCK
require Mail::Send;
use Mail::Mailer qw(test);
my $msg = new Mail::Send;
my $From = 'From';
my $cheader1 = 'X-connix-order-type';
my $cheader2 = 'X-connix-order-tag';
# Get headers to be sent when not using test as mailer method
# Set Mail Headers
##################################
$msg->set($cheader1, 'members');
$msg->set($cheader2, '$account');
$msg->to('salexson@connix.com');
$msg->cc("$who1\@connix.com");
$msg->subject('Group Membership Form');
$msg->set($From, "$who1\@connix.com \(Group Members
Form\)");
my($first, $last) = split (" ", $name[$i]);
my $fh = $msg->open;
print $fh <<END;
group:$account:group:-:-
$billtype[$i]:$last:$first:$dphone[$i]:$login[$i]
special:$special
special2:$special2
special3:$special3
END
;
$fh->close;
# END CODE BLOCK
------------------------------
Date: 8 Jun 1998 14:52:27 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: Perl module for doing a unix 'which'?
Message-Id: <6lgtrb$kj6$1@ns1.arlut.utexas.edu>
This is one of those few times where /bin/sh is the better solution
than perl. This is what I use:
====
#! /bin/sh
# like which(1), but uses your current $PATH and lists all occurences
# instead of just the first, and the exit value can be used.
retval=1
[ ! "$1" ] && exit $retval
IFS=:
for i in $PATH ; do
if [ -x ${i}/$1 -a -f ${i}/$1 ]; then
echo ${i}/$1
retval=0
fi
done
exit $retval
====
I wrote something similar in perl, but the /bin/sh version
consistantly ran faster. Probably because /bin/sh is always already
loaded.
--
Stuart McDow Applied Research Laboratories
smcdow@arlut.utexas.edu The University of Texas at Austin
"Look for beauty in roughness, unpolishedness"
------------------------------
Date: 8 Jun 1998 15:28:33 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl module for doing a unix 'which'?
Message-Id: <6lgvv1$3t3$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
smcdow@arlut.utexas.edu (Stuart McDow) writes:
:This is one of those few times where /bin/sh is the better solution
:than perl. This is what I use:
[....]
:I wrote something similar in perl, but the /bin/sh version
:consistantly ran faster. Probably because /bin/sh is always already
:loaded.
Your sh version is slower than my perl version.
% time sh /tmp/wh.sh tee
/home/tchrist/scripts/tee
/usr/ucb/tee
0.020u 0.020s 0:00.03 133.3% 0+0k 0+0io 150pf+0w
% time wh tee
/home/tchrist/scripts/tee
/usr/ucb/tee
0.020u 0.000s 0:00.03 66.6% 0+0k 0+0io 216pf+0w
Here's mine.
#!/usr/bin/perl
# wh - like which, but find all in path.
foreach $file (@ARGV) {
for $dir (split(/:/,$ENV{'PATH'})) {
print $path,"\n" if -f ($path="$dir/$file") && -x _;
}
}
--tom
--
/* This is the one truly awful dwimmer necessary to conflate C and sed. */
--Larry Wall, from toke.c in the v5.0 perl distribution
------------------------------
Date: 8 Jun 1998 15:11:03 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Problem with re-iterating if loops...
Message-Id: <6lguu7$5k7$2@client3.news.psi.net>
Larry Rosler (lr@hpl.hp.com) wrote on MDCCXLI September MCMXCIII in
<URL: news:MPG.fe498ec8e5920cf989696@nntp.hpl.hp.com>:
++ [This followup was posted to comp.lang.perl.misc and a copy was sent to
++ the cited author.]
++
++ In article <6lef2n$8ho$1@csnews.cs.colorado.edu>, tchrist@mox.perl.com
++ says...
++ > [courtesy cc of this posting sent to cited author via email]
++ >
++ > In comp.lang.perl.misc,
++ > Randal Schwartz <merlyn@stonehenge.com> writes:
++ > :Ewww. Didn't anyone ever teach you NOT to use A && B || C as if-then-else
++ > :because it doesn't scale to the times when B returns false? Ewww.
++ >
++ > But they didn't.
++ >
++ > :Moral: *don't* use A && B || C for if-then-else. Use A ? B : C, as
++ > :Ritchie (via Wall) intended.
++ >
++ > Don't think so. I know quite exactly what I'm doing. That's like saying
++ > "don't use while if $x{K} because you should always say if exists $x{$K}".
++ > Which would also be going too far.
++
++ You surely do know quite exactly what you're doing. But don't do it too
++ often where performance matters. The peephole optimizer evidently isn't
++ smart enough to eliminate the superfluous test for TRUE after each of the
++ successful selections.
++
++ #!/usr/local/bin/perl -w
++ use Benchmark;
++
++ timethese (1 << 20, {
++ '&& ||' => q{ $x = $a && 1 || $b && 2 || $c && 3 || $d && 4 || $e &&
++ 5 || 6 },
++ '? :' => q{ $x = $a ? 1 : $b ? 2 : $c ? 3 : $d ? 4 : $e ? 5 : 6 },
++ } );
++ __END__
++
++ Benchmark: timing 1048576 iterations of && ||, ? :...
++ && ||: 15 secs (12.77 usr 0.03 sys = 12.80 cpu)
++ ? :: 10 secs ( 8.25 usr 0.02 sys = 8.27 cpu)
++
Well, now you are mainly timing the time it takes to compile the strings
over and over again; and the || && one is longer.
#!/usr/local/bin/perl -w
use strict;
use Benchmark;
use vars qw /$a $b $c $d $e/;
timethese (100_000, {
'&& ||' => sub {$a && 1 || $b && 2 || $c && 3 || $d && 4 || $e && 5 || 6},
'? :' => sub {$a ? 1 : $b ? 2 : $c ? 3 : $d ? 4 : $e ? 5 : 6}
});
__END__
Benchmark: timing 100000 iterations of && ||, ? :...
&& ||: 4 secs ( 3.61 usr -0.02 sys = 3.59 cpu)
? :: 5 secs ( 3.44 usr 0.01 sys = 3.45 cpu)
Not much difference now.
Abigail
--
perl -we '$_ = q ;4a75737420616e6f74686572205065726c204861636b65720as;;
for (s;s;s;s;s;s;s;s;s;s;s;s)
{s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'
------------------------------
Date: 8 Jun 1998 14:12:58 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Q: apply func to mutate list; oneliner
Message-Id: <6lgrha$p7h$1@pegasus.csx.cam.ac.uk>
In article <yo33edkyyur.fsf@shell13.ba.best.com>,
Xah Lee <xah@shell13.ba.best.com> wrote:
>
>
>Suppose I have a list from split(...), then I want to apply a function to the second element, then return the list. How to do it in one line?
A simple substitute will do it:
$line =~ s!/(\w+)/!'/'.monthNameToNumber($1).'/'!e
Mike Guy
------------------------------
Date: 8 Jun 1998 15:34:45 GMT
From: Lou Poppler <lwp@flenser.ibm.net>
Subject: Re: Question about four-argument select use
Message-Id: <357c0495.0@news1.ibm.net>
On Tue, 26 May 1998 22:01:35 GMT, elvi@dsuper.net wrote:
X-Http-User-Agent: Mozilla/4.02 [en] (WinNT; I)
[ snip ]
: The problem right now is that I never receive a go-ahead to read from select.
: When I was doing this without select, using regular buffered <> function to
: read, I did get data from the socket, so I know it's possible. Just not sure
: what I'm doing wrong. I hope it's obvious to someone else.
Are you sure that NT supports this (or any) form of select() ?
------------------------------
Date: 8 Jun 1998 15:12:50 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: question
Message-Id: <6lgv1i$5k7$3@client3.news.psi.net>
wolfram.oehms (wolfram.oehms@metronet.de) wrote on MDCCXLI September
MCMXCIII in <URL: news:01bd923c$8c1dd3e0$97a5a8c1@default>:
++ Is there a way to send an email out to everyone who comes to our website
++ automatically without them filling out a form,etc... ?
No.
And you don't want to either.
Abigail
--
Is there a way to send an email automatically to wolfram.oehms@metronet.de
each time his postings are being read?
------------------------------
Date: Mon, 8 Jun 1998 14:30:58 GMT
From: pynq@midway.uchicago.edu (Jeremy Mathers)
Subject: Script Auto-restart - using -M file test - Cannonical way?
Message-Id: <Eu8LnM.J4t@midway.uchicago.edu>
The -M file test operator will tell you if a given file has been changed
since the script has started running. An obvious application of this is for
the script to periodically query its source file (the .pl file) and see if
it has been edited. If so, the script ought to restart itself.
Suppose you have a Perl script running as a daemon, possibly on a distant
machine. You make changes to the script, then have to walk over to the
distant machine and restart the script. It seems there ought to be a
standard way for this process to be automated.
Is there?
(I can probably imagine less than elegant ways of doing it, such as putting
the real code into a "foo.pl", which defines a procedure called &real_program,
then have a top_level script do an include of "foo.pl" whenever foo.pl
changes, but it ought to be possible to do it more seamlessly)
************************************************************************
The Official JM Personality Test
Part I. Answer these questions:
1) You are visiting a friend in his office and you notice two
calendars on adjacent walls. On one wall, is a Three Stooges
calendar; on the other, one of the Sports Illustrated Swimsuit
Edition. Which one is more likely to hold your
interest/attention?
2) You are driving on an urban freeway (not at rush hour) and
there is a traffic snarl, that looks like it could go on for
some time. As you crawl forward, you notice an exit to a
surface street that looks like it might get you where you
are going more quickly than the freeway will. Are you
likely to take the exit or would you just stay where you
are and duke it out with everybody else?
3) You go into a restaurant and order a Rueben sandwhich.
When it arrives, you are not pleased with its
price/performance ratio. Are you more likely to say that
it is not big enough or that it is too expensive?
Part II. Now, write an essay for each one telling what you think it
says about you/What the purpose of each question is.
- pynq@quads.uchicago.edu, who is still costing the net
hundreds, if not thousands, of dollars, every time he posts -
************************************************************************
rwvpf wpnrrj ibf ijrfer
------------------------------
Date: Mon, 08 Jun 1998 15:50:08 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Script Auto-restart - using -M file test - Cannonical way?
Message-Id: <QKTe1.910$14.4921360@news2.voicenet.com>
Jeremy Mathers <pynq@midway.uchicago.edu> wrote:
>The -M file test operator will tell you if a given file has been changed
>since the script has started running. An obvious application of this is for
>the script to periodically query its source file (the .pl file) and see if
>it has been edited. If so, the script ought to restart itself.
I don't think that an obvious application of using -M. I think it's a
convoluted way of using -M. :)
>Suppose you have a Perl script running as a daemon, possibly on a distant
>machine. You make changes to the script, then have to walk over to the
>distant machine and restart the script. It seems there ought to be a
>standard way for this process to be automated.
If you can get to the machine to edit the script, why can't you restart
the script after you are done editing and testing it?
>Is there?
Undoubtably!
If you don't feel like killing the daemon and restarting it, you can
just send it a signal to make it restart. Something like:
#!/usr/local/bin/perl
my $progname = $0;
$SIG{'HUP'} = \&catch; # Or use USR1, or any other appropriate signal.
for (;;) {
restart() if $RESTART;
}
sub restart
{
print "Restarting $progname on a $RESTART.\n";
if ($pid = fork) {
#parent
exit;
} elsif (defined $pid) {
exec $progname;
die("This should never happen.\n");
} else {
die("Can't fork.\n");
}
}
sub catch
{
$RESTART = shift;
}
If it is _impossible_ to get to the machine after you've edited the
script, instead of catching a signal, set the script up to catch a
packet. It should be relativly easy to open a port and do a
non-blocking select() on it. When there is activity on the port,
restart the script.
> - pynq@quads.uchicago.edu, who is still costing the net
> hundreds, if not thousands, of dollars, every time he posts -
And being added to hundreds, if not thousands, of killfiles, every time
he posts.
--
Matt Knecht - <hex@voicenet.com>
"496620796F752063616E207265616420746869732C20796F7520686176652066
617220746F6F206D7563682074696D65206F6E20796F75722068616E6473210F"
------------------------------
Date: 8 Jun 1998 15:16:20 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: thumbnails
Message-Id: <6lgv84$5k7$4@client3.news.psi.net>
Kelby Valenti (kelby@mplx.com) wrote on MDCCXXXIX September MCMXCIII in
<URL: news:6l9jij$d3si$1@newssvr04-int.news.prodigy.com>:
++ I'm looking for a program that will create thumbnails from a directory of
++ images. I would like this to be a cgi program. If you can help me in my
++ search I'd appreciate it.
Did you search the attic?
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: 8 Jun 1998 15:29:32 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: what's a cross-platform \n please?
Message-Id: <6lh00s$5k7$5@client3.news.psi.net>
Alan J. Flavell (flavell@mail.cern.ch) wrote on MDCCXLI September
MCMXCIII in <URL: news:Pine.A41.3.95a.980607223728.35170J-100000@rsplus15.cern.ch>:
++
++ Despite hunting through the FAQs etc. I'm still confused about precisely
++ what a \n represents.
++
++ In places it's described as a "newline", which I would understand to be
++ the platform-specific end-of-line representation whatever that might be;
++ while in other places it's described as a "linefeed", which I understand
++ to be one specific control character (\012) irrespective of platform.
MacPerl uses \015 for "\n". This issues was discussed on the p5p
mailinglist last week. "\n" should be right bitsequence for end-of-line
on the current platform. That is \012 on Unix, \015 on Mac, nothing on
VMS textmode, etc.
++ Of course, these two are identical on unix, which is no doubt how the
++ confusion arises. What _is_ \n meant to represent on other platforms?
++ And does it make any difference whether the file is open for binary or
++ text?
For systems that have a difference between binary and text mode, yes.
(I would say that sending a "\n" to file open in binmode should give
a warning...) On UNIX, binmode is seldom used (although according to
K&R, the stdio library does support both).
There are some allusions in the documentation for "open" and
++ "binmode", but to me they seem to assume that the reader already knows
++ the answer, which I don't. They certainly cause me to suspect that when
++ the authors say "newline" they really mean "linefeed", whereas I would
++ understand "newline" to mean "platform-specific end of line
++ representation".
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET", "http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content)) =~ /(.*\))[-\s]+Addition/s) [0]'
------------------------------
Date: 8 Jun 1998 14:37:08 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Why is there no "in" operator in Perl?
Message-Id: <6lgsuk$5k7$1@client3.news.psi.net>
Snowhare (snowhare@xmission.xmission.com) wrote on MDCCXL September
MCMXCIII in <URL: news:6lbv58$t5r$1@xmission.xmission.com>:
++
++
++ Nothing above this line is part of the signed message.
++
++ In article <6l926h$7of$2@client3.news.psi.net>,
++ Abigail <abigail@fnx.com> wrote:
++ >Michael J Gebis (gebis@albrecht.ecn.purdue.edu) wrote on MDCCXXXVIII
++ >September MCMXCIII in <URL: news:6l6v7k$m2q@mozo.cc.purdue.edu>:
++ >++ Andrew Johnson <ajohnson@gpu.srv.ualberta.ca> writes:
++ >++
++ >++ }note, though, that grep is not restricted to regular expressions
++ >++ }for testing, one can use an 'eq' test for improved performance:
++ >++
++ >++ If you care about performance, and your arrays are big, don't use a
++ >++ linear search. Hash, baby, hash! (Please see tcgrep's post on this
++ >++ for more copies of the word "HASH".)
++ >
++ >
++ >Even if you have huge arrays, if you're searching only once, there's
++ >no point in hashing, as building the hash table is linear too.
++
++ But searching it is not. It depends on the relative constants for building
++ the array *AND* linearly searching it vs. building the hash and finding an
++ entry.
++
++ The question is which is larger:
++
++ K O(N) + S O(N) (for building and searching an array)
Building? What's the build when the array is given?
++ vs
++
++ M O(N) + T (for building and finding an entry in a hash).
++
++ if (M < (K + S)) then, for large enough N, it will be faster to build the
++ hash _even for only one search_.
++
++ Benjamin Franz
Yeah, but if it turns out 'eq' is slower than hashing the elements,
something would be very wrong.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
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 2811
**************************************