[17284] in Perl-Users-Digest
Perl-Users Digest, Issue: 4706 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 24 00:05:35 2000
Date: Mon, 23 Oct 2000 21:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <972360311-v9-i4706@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 23 Oct 2000 Volume: 9 Number: 4706
Today's topics:
ActivePerl: Want to skip open files when unlinking jgrinwal@my-deja.com
Re: ActivePerl: Want to skip open files when unlinking <jeff@vpservices.com>
Re: Alphanumeric sorting of hashes (Tad McClellan)
Re: Beyond useless (Mark Badolato)
C, threads and Perl paulco44213@my-deja.com
Re: Dynamic Regex building? (Gwyn Judd)
Re: File locking (Logan Shaw)
Re: File test -d does not work under Win98 ? (Gwyn Judd)
Re: Formatting of the "make test" output (Garry Williams)
Re: Here-is excute command <elephant@squirrelgroup.com>
Re: Integer overflow (Kevin Reid)
Re: Integer overflow (Martien Verbruggen)
Re: Invalid switch msg on system call <bwalton@rochester.rr.com>
Re: LWP and Netscape jedelcon@sonic.net
new to databases need info/help <pdmos23@geocities.com>
Re: new to databases need info/help <jeff@vpservices.com>
Re: new to databases need info/help <lauren_smith13@hotmail.com>
Re: Out of Memory - ActivePerl 5.6/Win98 SE 192MB RAM (Gwyn Judd)
Re: Out of Memory - ActivePerl 5.6/Win98 SE 192MB RAM (Gwyn Judd)
Re: package & library <elephant@squirrelgroup.com>
parentheses turns into a function mbil_99@my-deja.com
Re: parentheses turns into a function <jeffp@crusoe.net>
Re: parentheses turns into a function <elephant@squirrelgroup.com>
Re: Perl 5.005 or 5.6? (Ilya Zakharevich)
Re: PerlMagick... <ianb@ot.com.au>
Processing an Email (sendmail) attachment with Perl <gartim@ix.netcom.com>
Re: Regular expression help <james@NOSPAM.demon.co.uk>
Re: Submit buttons <elephant@squirrelgroup.com>
Use VS Require <troyr@vicnet.net.au>
Re: Use VS Require <elephant@squirrelgroup.com>
Re: What will the code look like? (Gwyn Judd)
Re: What will the code look like? (Tad McClellan)
Re: why core dump ? <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 24 Oct 2000 01:31:42 GMT
From: jgrinwal@my-deja.com
Subject: ActivePerl: Want to skip open files when unlinking
Message-Id: <8t2opu$2a7$1@nnrp1.deja.com>
I have a directory cleanup program which is giving me a problem. It is
failing to delete a log file which has not been updated for more than
two days. When it does this, it is kicking out an email notification.
I want this notification in case some NT Administrator suddenly changes
the permissions on this folder and I can no longer cleanup the files.
The problem is, the application still has log file open--it just hasn't
updated it because the application has been idle. The "unlink"
returns "Permission denied", the same error I would get if the file /
directory permissions did not allow deleting.
I am trying to find a way to skip the notification for this particular
file, or better still skip the deletion attempt for open files
altogether. I pored the documentation on "stat", all the File:: and
File::Spec modules, even the Win32::File, and Win32API::File modules,
and didn't find much.
Any ideas?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 23 Oct 2000 19:26:09 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: ActivePerl: Want to skip open files when unlinking
Message-Id: <39F4F341.2C26E936@vpservices.com>
jgrinwal@my-deja.com wrote:
>
> I have a directory cleanup program which is giving me a problem. It is
> failing to delete a log file which has not been updated for more than
> two days. When it does this, it is kicking out an email notification.
> I want this notification in case some NT Administrator suddenly changes
> the permissions on this folder and I can no longer cleanup the files.
>
> The problem is, the application still has log file open--it just hasn't
> updated it because the application has been idle. The "unlink"
> returns "Permission denied", the same error I would get if the file /
> directory permissions did not allow deleting.
eval { unlink $file };
--
Jeff
------------------------------
Date: Mon, 23 Oct 2000 22:19:40 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Alphanumeric sorting of hashes
Message-Id: <slrn8v9sds.5oa.tadmc@magna.metronet.com>
On Mon, 23 Oct 2000 16:34:36 -0700, Linc Madison
<lincmad001@telecom-digest.zzn.com> wrote:
>In article <m3u2a38qc8.fsf@dhcp11-177.support.tivoli.com>, Ren Maddox
><ren.maddox@tivoli.com> wrote:
>
>> In either case, if you have very much data to sort, you might want to
>> convert this to a ST or GRT, but I have a hunch that you aren't
>> dealing with that much data...
>
>What are ST
---------------------------
#!/usr/bin/perl -w
use strict;
@ARGV = glob '/usr/lib/perl5/5.6.0/pod/perlfaq[1-9].pod';
while (<>) {
print "$1\n" if /(S\w+\s+T\w+)/;
print "$1\n" if /(G\w+\s+R\w+T\w+)/;
}
---------------------------
output:
Special Topics
State Tool
Standard Time
Schwartzian Transform
SHF TAB
One of those is mentioned in one of the sorting FAQs, so
you surely already knew what ST was. You probably just
didn't connect them...
>and GRT?
That's the Guttman-Rosler Transform.
>I can't look them up if I don't know what the abbreviations are for....
Right.
Google finds 10 hits for Guttman-Rosler
>(I'm interested because I have a program that uses a hash with over
>120,000 pairs, and I have to sort on the keys.)
We can't tell if you would benefit from those techniques though.
If you just need to sort a list of keys, they won't help.
If you need to sort a list of keys, based on a calculation
using the keys (transform), then you ought to look them up.
The OP in _this_ thread needed to transform (strip 2 chars)
the items being sorted.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 24 Oct 2000 01:25:14 GMT
From: mbadolato@corp.quepasa.com (Mark Badolato)
Subject: Re: Beyond useless
Message-Id: <8FD6B7D92mbadolatocorpquepasa@206.165.3.80>
gellyfish@gellyfish.com (Jonathan Stowe) mentioned:
>This would probably only rate ~~ in the CiP[1] rating scheme.
>Although I would have to confess to plenty of similar code where I
>have devised some module with various methods some of which only
>ever get partially implemented (as above :).
Which I thought of too, however I also found at least 8 calls to the
subroutine from the script, so I think it's intentional. The rest of
the script is horrendous too.
>Anyhow I'll forward it
>to the CiP rating panel[2] to see what they think
>
Right on =)
--mark
------------------------------
Date: Tue, 24 Oct 2000 01:13:59 GMT
From: paulco44213@my-deja.com
Subject: C, threads and Perl
Message-Id: <8t2nok$1f1$1@nnrp1.deja.com>
Hi all-
In a multithreaded program that calls some Perl subroutines I had made
sure the that only one thread ever called the Perl subroutine and all
was well. When I remove that restriction I find that I get some strange
reaction when using the Socket module - in short it doesn't work unless
(by chance) the thread that called it the first time is used again. So
it only works intermitantly when the original thread happens to be the
one calling my Perl subroutine.
Is there some general restriction on the use of threads when calling
Perl from a C program? If so where can I find the details - I've been
looking through the documentation without much luck.
I'm using Active Perl build 618 on NT.
Any help would be appreciated.
Thanks!
PC.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 24 Oct 2000 02:05:37 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Dynamic Regex building?
Message-Id: <slrn8v9rja.5rj.tjla@thislove.dyndns.org>
I was shocked! How could Alan J. Flavell <flavell@mail.cern.ch>
say such a terrible thing:
>On Mon, 23 Oct 2000, Bart Lateur wrote:
>
>> I don't think J. Stowe's HTML::Parser examples were useless.
>
>Of course not. Please do not feed the troll.
Trolls have to eat though ;)
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
"Water. Fascinating. I never touch the stuff myself."
-- Londo, "A Voice in the Wilderness I"
------------------------------
Date: 23 Oct 2000 20:28:45 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: File locking
Message-Id: <8t2okd$1k0$1@provolone.cs.utexas.edu>
In article <7138vso83vhc2t7rrn2ddg93u76qifq8em@4ax.com>,
Bart Lateur <bart.lateur@skynet.be> wrote:
>Logan Shaw wrote:
>>When reading, don't lock the file. Instead, check the modification
>>time on the file and make sure it's in the past. Then, read the file.
>>Then, check the modification time again.
>
>Yes, it is a bit weird. But, if the file is updated in very short
>intervals, you can wait forever to read it properly.
But that's easy to deal with -- just give up and do regular locking if
you've tried this method two or three times and haven't been able to
read the file.
>But mail is appended, i.e; added to the end of the mail file, isn't it?
>The old data is never overwritten? Well, make use of that. Read the file
>size when you start reading.
Yes, for some applications that could be even better. I wonder if
there are any mail programs that actually do that...
- Logan
------------------------------
Date: Tue, 24 Oct 2000 02:34:38 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: File test -d does not work under Win98 ?
Message-Id: <slrn8v9t9m.5rj.tjla@thislove.dyndns.org>
[ Chas - Next time you respond to someone, please post your reply
beneath the (suitably trimmed) text you are replying to]
I was shocked! How could Chas Friedman <friedman@math.utexas.edu>
say such a terrible thing:
>>
>> Hi,
>>
>> I'm using'the O'Reilly Perl Resource Kit for Windows, installed under Win98
>> (first edtion).
>> If I am using the following code:
>> opendir(DIR, $dir) or die $!;
>> @dirs = grep(-d, readdir(DIR));
>> closedir(DIR) or die $!;
>> where $dir is a correct full directory path, which contains several subdirs.
>> If I print @dirs only the . and .. directories show up - the others are
>> ignored.
>> Does someone recognize this?
>>
>> Thanx so far
>> Arie van Wingerden
>Hmmm... curious! I tried it with my perl on Windows, with the same result, and
Not really curious. This behaviour is as expected. Did you read the
documentation in 'perldoc -f readdir'?
>and the same thing happens (directories other than . or .. are ignored.)
>However, if I try
>
>if (-d "../somedir") {print "OK\n"}
>
>then "OK" is printed for listings which are directories. (on Windows or Linux).
>(If you figure this out, I'd like to know. I use perl some, but I'm no expert.)
It's good that you are using Perl and trying to help and stuff but
replies like this aren't really very much help unless you have any
correct information to add to the discussion. This is fairly trivial
stuff, if you are going to help out here then you really should become
familiar with the documentation first.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
"You must have an IQ of at least half a million." -- Popeye
------------------------------
Date: Tue, 24 Oct 2000 03:56:35 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Formatting of the "make test" output
Message-Id: <TL7J5.59$Si.4636@eagle.america.net>
On Mon, 23 Oct 2000 10:27:19 +0200, Volker Moell <moell@ID-PRO.de> wrote:
>Hi, all!
>
>I have a little question concerning the output of "make test". Under
>"normal" circumstances you get someting like this:
>
>t/AssociatorNames...ok
>t/Associators.......ok
>t/ExtrinsicMethods..ok
>t/GetClass..........ok
>
>But when the name of the test scripts become longer the output is no
>longer nice formated:
>
>t/GetClass..........ok
>t/GetInstance-PaulA_User.ok
>t/GetInstance.......ok
>t/GetProperty-PaulA_User.ok
>
>Is there a way to make the output look better? Ok, it's by far not a
>important question, but... :-)
I don't think so. I did modify my copy of Test::Harness at line 89 to
use 25 instead of 20 in the "$leader" variable and this did the trick
for a test case that I have which is similar to yours. Since this is
hard-coded, there seems to be no way to affect it though the
interface.
My version of Test::Harness is `1.1604'.
--
Garry Williams
------------------------------
Date: Tue, 24 Oct 2000 12:56:20 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: Here-is excute command
Message-Id: <MPG.145fa564e6eeabc8989840@localhost>
danfan wrote ..
>I want to use shell here-is syntax in a Perl-script,
>to access an application from the CLI where the application
>prompts for userid and password
>
>In a shell script I would write:
>#!/bin/ksh
>mq001 -v <<EOCMD
>myuserid
>mypassword
>get job_status
>get schema_status
>end
>EOCMD
>exit 0;
>
>I have tried several varietis of
>(@response)=print mq001 -v<<`EOCMD`;
>myuserid
>mypassword
>get job_status
>get schema_status
>end
>EOCMD
>
>
>1. Only the first lines works ( no login)
>2. Secondly how do I get hold of the output
>
>This works:
>(@response)=print ksh -x <<`EOCMD`;
>mq001 -v <<EOC
>myuserid
>mypassword
>get job_status
>get schema_status
>end
>EOC
>EOCMD
>but I still canīt grab the output of the command
this is really just for sending stuff to a command .. to communicate
bidirectionally have a look at IPC::Open2 or IPC::Open3 if you're
interested in STDERR as well
furthermore have a look at the perlipc section of the documentation
perldoc IPC::Open2
perldoc IPC::Open3
perldoc perlipc
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Mon, 23 Oct 2000 21:16:44 -0400
From: kpreid@attglobal.net (Kevin Reid)
Subject: Re: Integer overflow
Message-Id: <1eip66d.tp5r5b9h5kn2N%kpreid@attglobal.net>
Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
> On Wed, 18 Oct 2000 10:17:05 -0400,
> Kevin Reid <kpreid@attglobal.net> wrote:
> > Is there a standard definition of what will happen when $NextID
> > overflows? Or if not, is it likely that this code will be a problem?
>
> # perldoc perlnumber
> is a good starting point.
"perlnumber": No items found.
I'm using 5.004 (due to lack of recent port) here.
> But Perl can autoincrement more than just integers.
<snip>
>
> So, this will not easily overflow. It might eat up all your memory, but
> by then you'll long be dead :)
I know. My current plan is to switch to incremented strings for IDs *IF*
real-world usage shows problems.
--
Kevin Reid: | Macintosh:
"I'm me." | Think different.
------------------------------
Date: Tue, 24 Oct 2000 01:38:30 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Integer overflow
Message-Id: <slrn8v9q0j.a0g.mgjv@verbruggen.comdyn.com.au>
On Mon, 23 Oct 2000 21:16:44 -0400,
Kevin Reid <kpreid@attglobal.net> wrote:
> Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
>
> > On Wed, 18 Oct 2000 10:17:05 -0400,
> > Kevin Reid <kpreid@attglobal.net> wrote:
> > > Is there a standard definition of what will happen when $NextID
> > > overflows? Or if not, is it likely that this code will be a problem?
> >
> > # perldoc perlnumber
> > is a good starting point.
>
> "perlnumber": No items found.
>
> I'm using 5.004 (due to lack of recent port) here.
Ah, yes, perlnumber is more recent than that. 5.6.0 IIRC. Even if you
aren't willing or able to upgrade to 5.6.0 yet, you can still download
the sources and look at the documentation in there :) There may be
_some_ minor differences between 5.6.0 and 5.004 in the way numbers
are handled, but I doubt it's much (Ilya will correct me if I'm wrong,
I hope).
Martien
--
Martien Verbruggen |
Interactive Media Division | This matter is best disposed of from
Commercial Dynamics Pty. Ltd. | a great height, over water.
NSW, Australia |
------------------------------
Date: Tue, 24 Oct 2000 02:13:58 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Invalid switch msg on system call
Message-Id: <39F4F055.9588DAD2@rochester.rr.com>
Kent Scheidegger wrote:
>
> I'm running perl on a Win98 machine. Every time I make a system
> call, I get a message"Invalid switch". This happens even with
> a simple call like this:
>
> system ("dir");
>
> The command works, but I get this annoying message.
>
> Apparently something in my perl setup is passing an invalid switch
> when it invokes the shell. How can I find out what it's doing wrong
> and fix it?
...
Hmmmm...does your COMSPEC environment variable read as follows:
C:\WINDOWS\COMMAND.COM
with no switches? If you don't know how to find out, run the one-liner:
perl -e "for (sort keys %ENV){print "ENV{$_}=$ENV{$_}\n"}
--
Bob Walton
------------------------------
Date: Tue, 24 Oct 2000 02:25:19 GMT
From: jedelcon@sonic.net
Subject: Re: LWP and Netscape
Message-Id: <04237B36C6BB7286.89C1DEB853EC5AFC.8A7892C5A60A3EC4@lp.airnews.net>
On Mon, 23 Oct 2000 08:41:08 -0700, Jeff Zucker <jeff@vpservices.com>
wrote:
>Jonathan Stowe wrote:
>>
>> On Mon, 23 Oct 2000 14:00:18 GMT, jedelcon@sonic.net Wrote:
>> > I have an intranet set up at home on which to practice my skills. I am
>> > running Redhat6.1 on both client and server. The client is in
>> > x-windows configuration. I
>> > I successfully installed the LWP module and its dependencies and can
>> > access an web page from my server using 'getprint'. Unfortunaltely all
>> > I get is the html code. I want to see the page in Netscape. Is there a
>> > way to do this.
>>
>> Use getstore() and then open the resulting file in your browser.
>
>Or continue to use getprint() but put it in a CGI and print a
>content-header first. That is assuming you have a web server running.
>
>> You qwill have to explain what you mean better if that is not what you
>> expected to have to do.
>
>Also true for my part of the possible answer.
>
>--
>Jeff
What I am attemping to do is write a perl script which would run on
the client machine and randomly display web pages in netscape. These
pages would be stored and served from my server. This needs to be done
in a looping fashion with different pages being displayed one after
the other. In other words it needs to happen with no intervention from
me. Eventually a cgi script on the server would download pages built
on the fly. My goal is to be able to loadtest my server by having
several client machines making page requests at the same time. Is this
any clearer?
Thanks for the feedback,
jerbear
------------------------------
Date: Tue, 24 Oct 2000 01:18:36 GMT
From: Pasquale <pdmos23@geocities.com>
Subject: new to databases need info/help
Message-Id: <39F4E44C.FA2D6F8D@geocities.com>
My new challenge is perl & databases, particularly Access for now. I
have no clue as to how these work together. Originally, I thought it
was as simple as using the open and close functions to the database
file. NOT! Are there any suggestions as to where I can get some
information or examples to learn from and to get me started. Excuse me
if I sound a little lost, but this is all new to me. I've looked
through "Programming Perl" and it doesn't mention too much.
Thanks
Pasquale
------------------------------
Date: Mon, 23 Oct 2000 18:26:21 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: new to databases need info/help
Message-Id: <39F4E53D.8E1F6285@vpservices.com>
Pasquale wrote:
>
> My new challenge is perl & databases, particularly Access for now. I
> have no clue as to how these work together. Originally, I thought it
> was as simple as using the open and close functions to the database
> file. NOT! Are there any suggestions as to where I can get some
> information or examples to learn from and to get me started. Excuse me
> if I sound a little lost, but this is all new to me. I've looked
> through "Programming Perl" and it doesn't mention too much.
Start here:
http://www.symbolstone.org/technology/perl/DBI/
--
Jeff
------------------------------
Date: Tue, 24 Oct 2000 01:54:30 GMT
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: new to databases need info/help
Message-Id: <qZ5J5.2655$JL5.265925@paloalto-snr1.gtei.net>
"Pasquale" <pdmos23@geocities.com> wrote in message
news:39F4E44C.FA2D6F8D@geocities.com...
> My new challenge is perl & databases, particularly Access for now. I
> have no clue as to how these work together. Originally, I thought it
> was as simple as using the open and close functions to the database
> file. NOT! Are there any suggestions as to where I can get some
> information or examples to learn from and to get me started. Excuse
me
> if I sound a little lost, but this is all new to me. I've looked
> through "Programming Perl" and it doesn't mention too much.
Try typing 'perldoc -q database' into your command prompt. That should
get you started.
Lauren
------------------------------
Date: Tue, 24 Oct 2000 01:59:30 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Out of Memory - ActivePerl 5.6/Win98 SE 192MB RAM
Message-Id: <slrn8v9r7r.5rj.tjla@thislove.dyndns.org>
I was shocked! How could Larry Rosler <lr@hpl.hp.com>
say such a terrible thing:
>In article <slrn8v7da3.spp.tjla@thislove.dyndns.org> on Mon, 23 Oct 2000
>03:49:29 GMT, Gwyn Judd <tjla@guvfybir.qlaqaf.bet> says...
>
>...
>
>> while (<INFILE>) {
>>
>> chomp;
>>
>> my @lines = split /\n/m;
>
>That 'm' is just noise.
>
>> # remove newlines
>> chomp @lines;
>
>What newlines did you have in mind? The split() removed every one
>already.
Yeah yeah I know I know. The program tested okay so I didn't find the
bits that did nothing. Funny noone picked on my using @input{@fields}
rather than @input{keys %input} and saving the extra variable as well as
less typing and less chance of mistakes :)
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
The rule on staying alive as a forecaster is to give 'em a number or
give 'em a date, but never give 'em both at once.
-- Jane Bryant Quinn
------------------------------
Date: Tue, 24 Oct 2000 02:16:59 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Out of Memory - ActivePerl 5.6/Win98 SE 192MB RAM
Message-Id: <slrn8v9s8k.5rj.tjla@thislove.dyndns.org>
I was shocked! How could Gwyn Judd <tjla@guvfybir.qlaqaf.bet>
say such a terrible thing:
>Yeah yeah I know I know. The program tested okay so I didn't find the
>bits that did nothing. Funny noone picked on my using @input{@fields}
>rather than @input{keys %input} and saving the extra variable as well as
>less typing and less chance of mistakes :)
Interestingly, when I typed that, I thought I didn't have a reason for
it, but then when I tried it I found out I did, only when I typed it
that way, I didn't know I did. If you know what I mean :) Oh well two
unnecessary lines and one necessary line that I thought wasn't isn't too
bad considering everything.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
The perfect lover is one who turns into a pizza at 4:00 A.M.
-- Charles Pierce
------------------------------
Date: Tue, 24 Oct 2000 12:22:06 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: package & library
Message-Id: <MPG.145f9d5ab65b3ae498983e@localhost>
tuple wrote ..
>Hello,
>
>I' am stuck with the following:
>
>My program uses packages (in separated files) now and it is ok.
>But how can i use a library (eg. Date-Calc) in my package ??
>The library is declared in my program.
>
>Thanks.
>
>Pierre Bachelart.
>
>
> Here my program (menu.pl) and his package (askpba3.pl) (part of it)
>
>#!/usr/bin/perl -w
>use lib '~/lib/perl';
>use Tk;
>use Date::Calc qw(Add_Delta_DHMS
> Today_and_Now
> );
>use Tk::BrowseEntry;
>use strict;
>use diagnostics;
>require "/home/someone/askpba3.pl"; #
>require "/home/someone/search_log"; #
>.....................
>.....................
>etc...
>
>and the package in another file
>
>package askpba3;
>BEGIN {
>}
>
>sub sendmail {
> open(MAIL,">$menu::mail") or die "can't open mail:$!";
> print MAIL "\n";
> print MAIL "From:",$menu::name," Date:",$menu::date,"\n";
> print MAIL "----\n";
> print MAIL "exch:", $record{"Exch:"},"\n";
> print MAIL"rit :", $record{"rit"},"\n";
> print MAIL "type:", $record{"type"},"\n";
> print MAIL "code:", $record{"code"},"\n";
> print MAIL "na :", $record{"na"},"\n";
> print MAIL "deliv:", $record{"deliv"},"\n";
> print MAIL "fault:", $record{"fault"},"\n";
> close (MAIL);
>.....................................
>.....................................
>etc....
just use it again in the package file .. ie.
package askpba3;
use Date::Calc;
# etc.
see the documentation on 'use' for why this will only include the file
once
perldoc -f use
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Tue, 24 Oct 2000 01:14:41 GMT
From: mbil_99@my-deja.com
Subject: parentheses turns into a function
Message-Id: <8t2npu$1fq$1@nnrp1.deja.com>
its a monday so my brain is skipping like scratched records of yore:
could someone please explain to my why the space matters here?
case 1
-------
use diagnostics;
print('foo'); # prints foo
case 2
------
use diagnostics;
print ('foo') # a space after the print, triggers the "parenthese turns
into a function" diagnostic message.
thanks!
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 23 Oct 2000 21:47:28 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: parentheses turns into a function
Message-Id: <Pine.GSO.4.21.0010232145550.1894-100000@crusoe.crusoe.net>
[posted & mailed]
On Oct 24, mbil_99@my-deja.com said:
>use diagnostics;
>print('foo'); # prints foo
>print ('foo') # a space after the print, triggers the "parenthese turns
>into a function" diagnostic message.
Because it doesn't want you trying to do
print (3 + 2) * 4; # really print(5) * 4, which is 1 * 4, void context
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
------------------------------
Date: Tue, 24 Oct 2000 12:59:41 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: parentheses turns into a function
Message-Id: <MPG.145fa62a4e22698a989841@localhost>
mbil_99@my-deja.com wrote ..
>its a monday so my brain is skipping like scratched records of yore:
>could someone please explain to my why the space matters here?
>
>case 1
>-------
>use diagnostics;
>print('foo'); # prints foo
>
>case 2
>------
>use diagnostics;
>print ('foo') # a space after the print, triggers the "parenthese turns
>into a function" diagnostic message.
which perl are you using ? .. 5.6.0 doesn't treat either any differently
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: 24 Oct 2000 01:27:53 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl 5.005 or 5.6?
Message-Id: <8t2oip$b3j$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Logan Shaw
<logan@cs.utexas.edu>],
who wrote in article <8t2mbc$1fk$1@provolone.cs.utexas.edu>:
> O.K., I now see that we weren't talking about exactly the same things.
> You're talking about the names of symbols in the libraries; I was
> talking about the names of the libraries.
I do not think it is random that most of implementation of dynaloading
break into two categories (instead of 4) due to be the following
dichotomies:
a) symbol-to-entry-point resolution is done at link-/run-time;
b) executable modules are cached by names/full-paths;
I remember I invented for myself some simple explanation why answers
to these two questions should better match, but do not remember it
right now...
Ilya
------------------------------
Date: Tue, 24 Oct 2000 13:35:58 +1100
From: Ian Boreham <ianb@ot.com.au>
Subject: Re: PerlMagick...
Message-Id: <39F4F58E.3F396ECD@ot.com.au>
Speed Demon wrote:
> Basically I have a bunch of images that all need to be 72x14 pixels. Some
> are a few pixels out.
> I need to readin all the images and the crop them accordingly, if you can
> send me some sample code I'd appreciate it greatly.
Did you look at the man pages (if such things exist on your system)?
man convert:
-crop <width>x<height>{+-}<x offset>{+-}<y offset>{%}
preferred size and location of the cropped image. See X(1)
for details about the geometry specification.
To specify a percentage width or height instead, append %.
For example to crop the image by ten percent on all sides of
the image, use -crop 10%.
Omit the x and y offset to generate one or more subimages of
a uniform size.
Use cropping to crop a particular area of an image. Use
-crop 0x0 to trim edges that are the background color. Add
an x and y offset to leave a portion of the trimmed edges
with the image.
Regards,
Ian
------------------------------
Date: Mon, 23 Oct 2000 20:06:07 -0700
From: "Gary J. Artim" <gartim@ix.netcom.com>
Subject: Processing an Email (sendmail) attachment with Perl
Message-Id: <39F4FC9F.3640@ix.netcom.com>
Question: Can you act as an email client using Perl and
read emails and process attached files as data? We have
a Website where some of the clients refuse to use our
upload page, but will email us attached, tab-delimited
files. I'd like to get them thru Perl and auto upload them
to my mysql database. Has anyone done this.
Any help is GREATLY appreciated!
emailto: gary@dkstat.com
------------------------------
Date: Tue, 24 Oct 2000 02:33:25 +0100
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Regular expression help
Message-Id: <ant2401250b0fNdQ@oakseed.demon.co.uk>
In article <39F4D970.FAEA67B6@stomp.stomp.tokyo>, Godzilla!
<URL:mailto:godzilla@stomp.stomp.tokyo> wrote:
> This next one has me boogered on the trinary
> conditional operator.
>
> > Locale-wise version:
>
> > /(?:\w.*){6}/s && /\d/ && /[^\W_\d]/
>
> trinary conditional operator (I'm am lost here)
I think what you need to know is that within a regular
expression (?:something) means group the something as
a single item but do not remember it in $1, $2, etc.
There are several other (?<char>...) things you can do
and in general they are called extended regex sequences.
If you have Camel 3 see page 160, or Camel 2 page 68.
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Tue, 24 Oct 2000 12:24:37 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: Submit buttons
Message-Id: <MPG.145f9df4dcbd039698983f@localhost>
Jerry Linch wrote ..
>Is it possible to have multiple Submit buttons on a form? What I want to do
>is set up a form to add, edit, or delete a database record. My thought is to
>have a Submit button for each of these actions. Obviously, I would want to
>be able to tell, from the Perl script, which button was pressed so that I
>could handle it appropriately. Any help on this would be appreciated.
yes it's possible .. but nothing to do with Perl .. ask in a more
appropriate newsgroup like
comp.infosystems.www.authoring.cgi
or have a look at one of the many CGI resources on the web
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Tue, 24 Oct 2000 13:31:11 +1100
From: "Troy Rasiah" <troyr@vicnet.net.au>
Subject: Use VS Require
Message-Id: <ww6J5.5508$SF5.112203@ozemail.com.au>
Hi all,
can anyone tell me whats the advantages and disadvantages of using
"Use" instead of "Require"
Thanks in advance
----------------------------
TR
------------------------------
Date: Tue, 24 Oct 2000 14:04:06 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: Use VS Require
Message-Id: <MPG.145fb542e69fd08f989842@localhost>
Troy Rasiah wrote ..
> can anyone tell me whats the advantages and disadvantages of using
>"Use" instead of "Require"
they do different things - each have advantages and disadvantages in
different situations
perldoc -f use
perldoc -f require
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Tue, 24 Oct 2000 02:21:31 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: What will the code look like?
Message-Id: <slrn8v9sh4.5rj.tjla@thislove.dyndns.org>
I was shocked! How could Tad McClellan <tadmc@metronet.com>
say such a terrible thing:
>Who is Spike Milligan, and what has he done with poor Ogden Nash?
Spike Milligan was one of the Goon Show members. Who the heck was Ogden
Nash?
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Extremism in the defense of liberty is no vice... moderation in the pursuit
of justice is no virtue.
-- Barry Goldwater
------------------------------
Date: Mon, 23 Oct 2000 22:21:03 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: What will the code look like?
Message-Id: <slrn8v9sgf.5oa.tadmc@magna.metronet.com>
On Tue, 24 Oct 2000 02:21:31 GMT, Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
>I was shocked! How could Tad McClellan <tadmc@metronet.com>
>say such a terrible thing:
>
>>Who is Spike Milligan, and what has he done with poor Ogden Nash?
>
>Spike Milligan was one of the Goon Show members. Who the heck was Ogden
>Nash?
I don't know who Spike Milligan is, nor what the Goon Show is :-(
But Ogden Nash wrote the quoted poem.
The attribution was incorrect.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 24 Oct 2000 02:37:08 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: why core dump ?
Message-Id: <39F4F5C3.8EA51262@rochester.rr.com>
"Ronald J.H. Rood" wrote:
>
> Hi,
> I am relatively new to perl. This is a little excercise script:
> perl 5.6.0 aix
> dbi 1.14
> dbd oracle 1.06
> ------------------------------------
> #!/usr/bin/perl -w
> use DBI;
>
> my $dbuser = $ENV{ORACLE_USERID} || 'scott/tiger';
> my $getRows = 'select count(*) from TABLE_NAME';
> my $dbh = DBI->connect('dbi:Oracle:', $dbuser, '', {
> AutoCommit => 1,
> PrintError => 0,
> }) or die "Couldn't connect to database: " . DBI->errstr;
> my $sth = $dbh->prepare('SELECT table_name, owner FROM all_tables WHERE
> table_name like upper (?) ')
> or die "Couldn't prepare statement: " . $dbh->errstr;
>
> print "Enter table name> ";
> while ( defined ($table_pattern = <>) && ( length ($table_pattern) > 0 )
You would be better off with <STDIN> rather than <> above. If you
accidentally give a parameter to your program when you start it, <> will
attempt to read from a file by that name. Also, the defined function
will succeed when scalar $table_pattern has *any* value, including the
null string, except for undef (which is not the null string). Also, the
length function will report the length of the string value returned by
$table_pattern, which will include the line terminator character(s).
Since neither of your while tests will ever fail, you could just as
easily say:
while(<STDIN>){
...
Then place your termination tests inside the while loop, executing the
last function to terminate the loop. Then you could do something like:
while(<STDIN>){
chomp; #remove line terminators if any
$table_pattern=$_;
#next line works because line terminator(s) were removed
last unless length($table_pattern)>0;
> ) { # Read input from the user
> my @data;
> my $count_rows;
>
> chomp $table_pattern;
> $sth->execute($table_pattern) # Execute the query
> or die "Couldn't execute statement: " . $sth->errstr;
>
> # Read the matching records and print them out
> while (@data = $sth->fetchrow_array()) {
> my $table_name = $data[0];
> my $owner = $data[1];
>
> ($count_rows = $getRows) =~ s/TABLE_NAME/$owner.$table_name/ ;
> # $count_rows now contains something like select count(*) from
> owner.table
> my $sth = $dbh->prepare( $count_rows)
> or die "Couldn't prepare statement: " . $dbh->errstr .
> $count_rows;
>
> $sth->execute() # Execute the query
> or die "Couldn't execute statement: " . $sth->errstr;
> @data = $sth->fetchrow_array();
> my $rows = $data[0];
> print "\t$count_rows has $rows rows\n";
> }
>
> if ($sth->rows == 0) {
> print "No tables matched `$table_name'.\n\n";
> }
>
> print "\n";
> print "Enter table_name> ";
> }
>
> $sth->finish;
> $dbh->disconnect;
> ---------------------------------------
> It just counts the number of rows in a table whose name[s] matches the
> specified pattern and prints the results. When I quit I get a coredump.
Question: if your while loop never terminates, how does your program
terminate? When you type ctrl-C? Normally, I wouldn't expect that
killing a Perl program would dump core, but who knows?
> Is this because of my imperfect perl code ?
> Do you see a better way to code this ? comments are very welcome.
>
> I also want to stop the loop when $table_pattern = empty. Now it does
> not stop; that's because the newline or something similar is in
> $table_pattern. How should I change that ?
Hope the above helps.
...
> Ronald
> http://unix-dba.myweb.nl
...
--
Bob Walton
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 4706
**************************************