[9634] in Perl-Users-Digest
Perl-Users Digest, Issue: 3228 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 22 21:07:18 1998
Date: Wed, 22 Jul 98 18:00:27 -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 Wed, 22 Jul 1998 Volume: 8 Number: 3228
Today's topics:
Re: @INC not working from within prog? (Martien Verbruggen)
Re: @INC not working from within prog? (Ronald J Kimball)
Re: A little enervous trouble (Ronald J Kimball)
Re: Better way of saying this. <jdw@alder.dev.tivoli.com>
Re: Can a Crontab run perl script (nobody)
Re: Dynamically creating graph images <Savage.Ron.RS@bhp.com.au>
Re: Dynamically creating graph images (Jack Ostroff)
Re: Dynamically creating graph images <cyberjeff@sprintmail.com>
Re: Error message details: <GEN0> chunk 549 and <IN> ch (Tad McClellan)
Re: getting ESC (hex 027) through STDIN, how to? <mthomas=posting@edrc.cmu.edu>
Re: Hash tree problems. <rick.delaney@shaw.wave.ca>
Re: Hash tree problems. (Ronald J Kimball)
HELP locking files <michael@nette.com>
How to know the number of hash items without running lo <yroh@samsung.co.kr>
Re: How to know the number of hash items without runnin (Michele Beltrame)
Re: How to know the number of hash items without runnin <rick.delaney@shaw.wave.ca>
Re: im having trouble with a bit of perl script, if som <rick.delaney@shaw.wave.ca>
Re: Is Perl y2k compliant? (Tad McClellan)
Re: Perl -pi <rick.delaney@shaw.wave.ca>
Perl 5.005 Beta 2 on NT mshore@arborsoft.com
Re: Perl array name (Ronald J Kimball)
Re: Perl Beautifier Home Page (Brandon S. Allbery KF8NH)
Re: Perl Beautifier Home Page <rra@stanford.edu>
perl losing required subroutines sxidh@ts.sois.alaska.edu
Re: print FIC : An easy question ! (Ronald J Kimball)
Re: Regular expressions for Perl 5 (Ronald J Kimball)
Re: result pending code..? (Tad McClellan)
Re: specific character/position in string (Josh Kortbein)
Re: SPLIT help please (Ronald J Kimball)
symbolic links for windows <anandan_balaji@emicx.mentorg.com>
Re: The act of glueing one cat's nose to another's tail (Martien Verbruggen)
Re: The act of glueing one cat's nose to another's tail (Michael J Gebis)
Re: Variable Interpolation (monty hindman)
Re: Variable Interpolation (Tad McClellan)
Web mail script <TerryLCora@worldnet.att.net>
Re: what is offline mode? (Ronald J Kimball)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Jul 1998 23:22:04 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: @INC not working from within prog?
Message-Id: <6p5s6s$p4i$1@nswpull.telstra.net>
In article <35B64E80.7F41298@wpine.com>,
Tom Robert <trobert@wpine.com> writes:
> This doesn't:
> unshift (@INC, '/Perl/lib');
> [according to the doc, this is how I should add to the path]
You also need to put it in a BEGIN block if you want to do it that
way. Which documentation did you get this from?
My documentation states:
# perldoc perlvar
[snip]
If you need to modify this at runtime, you should use the use lib
pragma to get the machine-dependent library properly loaded also:
use lib '/mypath/libdir/';
use SomeMod;
[snip]
> Also, how do I modify the @INC variable at a global level?
Change the configuration file of perl. Config,pm, should be in in
${PERLPATH}/${ARCHITECTURE}/${VERSION}/Config.pm
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In the fight between you and the
Commercial Dynamics Pty. Ltd. | world, back the world - Franz Kafka
NSW, Australia |
------------------------------
Date: Wed, 22 Jul 1998 20:31:08 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: @INC not working from within prog?
Message-Id: <1dcl1by.19vbu981cenr4cN@bay1-156.quincy.ziplink.net>
Craig Berry <cberry@cinenet.net> wrote:
> See 'perldoc perlrun'.
see perlrun.
run perl run!
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Wed, 22 Jul 1998 20:31:11 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: A little enervous trouble
Message-Id: <1dcl1ez.vbtfxoreog74N@bay1-156.quincy.ziplink.net>
[posted and mailed]
delta <delta@netpage.tm.fr> wrote:
> WHERE IS THE ERROR, because "\"#ffffff\"\" doesn't seem to be the trouble
^^
Actually, that is the trouble. You backslashed what would otherwise be
the closing quote, so the string doesn't end until the *next* double
quote.
It should be "\"#ffffff\"" instead.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 22 Jul 1998 17:57:25 -0500
From: Jim Woodgate <jdw@alder.dev.tivoli.com>
Subject: Re: Better way of saying this.
Message-Id: <obn2a1cx4a.fsf@alder.dev.tivoli.com>
aml@world.std.com (Andrew M. Langmead) writes:
> Jim Woodgate <jdw@alder.dev.tivoli.com> writes:
> >I don't know if it's easier or more elegant, but you can do the
> >foreach/unless in a one liner:
>
> >grep { $teststring =~ /$_/i } @allowed or die "Sorry not found, stopped";
>
> The foreach has one advantage in that you can stop the loop as soon
> the first match is found, cutting the average number of iterations of
> the loop in half.
I thought about the shortcut, but his algorithm didn't shortcut
anyway, and he was asking for a different solution. I was shooting
for a possibly easier to read version...
> And in an expensive process like a runtime contstructed regular
> expression, you want to cut out as many iterations as possible. Which
> is why the FAQ entry that I mentioned early in the thread uses eval to
> create "compile time" regular expressions at "run time".
I guess my news server is missing some posts, it looked like I was the
only person that responded to his post, so I never saw your earlier
solution. If he would have asked for the fastest version possible, I
wouldn't have responded. He asked for a different substitution for
the foreach, so I posted a simple one...
--
Jim Woodgate
Tivoli Systems
E-Mail: jdw@tivoli.com
------------------------------
Date: 22 Jul 1998 22:42:24 GMT
From: ac1@fspc.netsys.itg.telecom.com.au (nobody)
Subject: Re: Can a Crontab run perl script
Message-Id: <6p5psg$r80@newsserver.trl.OZ.AU>
Avi Rosenberg (avir@compugen.co.il) wrote:
: >
: > Wali Haidri <whaidri@ford.com> Said this:
: >
: > >I wrote a perl (actually an oraperl) program. It runs as expected when
: > >submitted from the command line. But when I run it from a crontab, it
: > >does not work.
: > >
: > >Thanks.
: >
: > Anywhere in the script where you use "relative" paths, you will need
: > to make them full paths.....
: >
: Also remember that when you run a script from cron, it might be
: executing
: with a different uid than your interactive checks...
Tenuous link to Perl, but you could use the same trick the 'at' uses.
>From your command line, execute env or set to get your environment and
insert these as sets at the top of your cron script.
: --
: ***********************************************************************
: Avi Yeshah Rosenberg "GCCGTAATCCGG"
: Compugen Ltd. Tel: +972-3-9348482
: 17 Hamacabim St. Fax: +972-3-9348489
: Petach-Tikva, 49220 E-mail: avir@compugen.co.il
: Israel WWW: http://www.cgen.com
: **********************************************************************
GCCGTAATCCGG? That's a little short for a useful DNA sequence, isn't it?
Or am I missing something?
AC
------------------------------
Date: 22 Jul 1998 23:56:08 GMT
From: "Ron Savage" <Savage.Ron.RS@bhp.com.au>
Subject: Re: Dynamically creating graph images
Message-Id: <01bdb5cc$9b716e20$b3eb1286@steelres-pcm657.resmel.bhp.com.au>
The ref below will give you GD.pm by Lincoln Stein. I use it under Unix. On
top of GD, install Plot.pm from
http://www.speakeasy.org/~cgires/plot/
for an excellent GD wrapper & simple demo. Output is in GIF format.
--
Ron Savage
Home (preferred): rpsavage@ozemail.com.au
Office: Savage.Ron.RS@bhp.com.au
http://www.ozemail.com.au/~rpsavage
[snip]
> Take a look at :
> http://reference.perl.com/query.cgi?graphics
>
>
> Eric.pl
>
------------------------------
Date: 22 Jul 1998 20:11:02 GMT
From: jack_h_ostroff@groton.pfizer.com (Jack Ostroff)
Subject: Re: Dynamically creating graph images
Message-Id: <6p5h0m$jc82@mascagni.pfizer.com>
In article <6p5a1d$1in$2@unlnews.unl.edu>, Greg Berigan <gberigan@cse.unl.edu> writes:
> In comp.lang.javascript, carltjm@mail.auburn.edu (Joseph M Carlton) wrote:
>
> > I am using perl to fetch data from a database for a web project that I am
> > working on. Now, I need to dynamically build a bar graph with this data.
> > Someone told me that I could use javascript and somebody told me that I
> > could do the whole thing in perl. I have not been able to find any
> > information on this topic for either javascript or perl. Could someone
> > PLEASE direct me to a book or web page with information on this? I am
> > not limited to perl and javascript, so if anyone knows of a better way to
> > do this. I would be VERY appreciative. Thanks in advance for your help.
>
> You can do bar graphs (scale images to the size of the needed bar) but
> line graphs and pie graphs are not possible since you can't create
> images on the fly (except B&W BMP images?). If you need this
> functionality, you'll need either communication with a server which will
> create images on demand or use Java.
>
[follow-ups set to clpm only, if I did it correctly...]
Perhaps you can't create images on the fly in javascript, but in Perl,
there are several approaches. Search CPAN for any of the several modules
which do graphics (GIF or CGM primarily, I believe). In addition, I have
several applications which output a file with the relevant data, and then
run an external program (SAS in my case) to generate a GIF file, which is
then either included or referenced by the HTML output by the rest of the
Perl script. For Perl references, search the docs for GIF or graphics (as
has been suggested in another post). For using an external program, check
the Perl docs for "system" or "qx" and the docs for whatever graphic
generating program you like.
Good luck
------------------------------
Date: Wed, 22 Jul 1998 20:14:06 -0400
From: Jeff Thies <cyberjeff@sprintmail.com>
Subject: Re: Dynamically creating graph images
Message-Id: <35B6804D.8D5EB626@sprintmail.com>
Now, I need to dynamically build a bar graph with this data.
> Could someone
> PLEASE direct me to a book or web page with information on this?
Danny Goodman (he's in the FAQ) has a bar graph in his javascript bible,
he's at http://www.dannyg.com (I believe)The book is so good, it's one of
the few I would recommend.
I believe the graph is NS3 and IE4 (not sure)
You might consider just setting an image heigth and width (for the bar
graph) server side. Plug in your perl values for the image height.
Jeff
------------------------------
Date: Wed, 22 Jul 1998 18:25:38 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Error message details: <GEN0> chunk 549 and <IN> chunk 24.
Message-Id: <ids5p6.03c.ln@localhost>
Colin Kilburn (hck@formalsys.ca) wrote:
: Here are two error messages:
: Use of uninitialized value at /lib/Customer/Customer.pm line 973, <GEN0>
: chunk 549.
: Use of uninitialized value at /lib/Customer/Customer.pm line 975, <IN>
: chunk 24.
: What does the '<GEN0> chunk 549' and '<IN> chunk 24' parts refer to?
If you have not changed $/ from its default value then:
s/chunk/line/;
Does that help?
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 22 Jul 98 19:30:44 EDT
From: Mark Thomas <mthomas=posting@edrc.cmu.edu>
Subject: Re: getting ESC (hex 027) through STDIN, how to?
Message-Id: <wf11zrdh3a3.fsf@disorder.ices.cmu.edu>
In <6p58is$cfi@crl.crl.com>, Matthew Rapaport writes:
> If the input stream contains ESC characters (dec. 027 octal 033)
> they do not appear in the output. I do not want them
> filtered. How can I do this?
Perl is not filtering the ESC characters, your terminal is. If you
pipe the output of your perl script into ``cat -v'' or redirect the
output to another file and open that file with XEmacs, less, or vi,
you'll see the ESC character there.
If you want to use perl to make the ESC characters visible, try the
script:
while( defined($line = <STDIN>) ) {
$line =~ s/\033/^[/g;
print $line;
}
exit;
-Mark
--
Mark Thomas
http://www.ndim.edrc.cmu.edu/~mthomas/
------------------------------
Date: Thu, 23 Jul 1998 00:24:01 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Hash tree problems.
Message-Id: <35B68405.FEC25A3E@shaw.wave.ca>
Michael Bowler wrote:
>
> I am having problems with checking for existence of keys down
> non-existent branches in a hash tree, causing those branches to be
> created. Is this how perl is supposed to handle this?
> I have the following piece of code:
> -----------------
> #!/opt/corp/local/bin/perl
> use strict;
>
> my %hash;
> $hash{'one'}{'1'} = 1;
> delete $hash{'one'};
> if (exists($hash{'one'}{'1'})) {
> print "Error, all of hash one should have been deleted.\n";
> }
> if (exists($hash{'one'})) {
> print "Error, hash one has been recreated.\n";
> }
> -----------------
>
> When this is executed, the second error message is written.
>From perlref:
6. References of the appropriate type can spring into existence if
you dereference them in a context that assumes they exist.
$hash{'one'} is automatically defined with a hash reference so that
{'1'} can be looked up.
Kind of ironic that 'exists($hash{'one'}{'1'})' is one of the contexts
that assumes existence. :-)
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Wed, 22 Jul 1998 20:31:15 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Hash tree problems.
Message-Id: <1dcl1vd.1gas7my2i4r2oN@bay1-156.quincy.ziplink.net>
Michael Bowler <mkbowler@nortel.com> wrote:
> I am having problems with checking for existence of keys down non-existent
> branches in a hash tree, causing those branches to be created. Is this how
> perl is supposed to handle this?
Well, the documentation seems to think so...
perlref:
References of the appropriate type can spring into existence if you
dereference them in a context that assumes they exist. Because we
haven't talked about dereferencing yet, we can't show you any
examples yet.
[...]
$array[$x]->{"foo"}->[0] = "January";
This is one of the cases we mentioned earlier in which references
could spring into existence when in an lvalue context. Before this
statement, $array[$x] may have been undefined. If so, it's
automatically defined with a hash reference so that we can look up
{"foo"} in it. Likewise $array[$x]->{"foo"} will automatically get
defined with an array reference so that we can look up [0] in it.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Wed, 22 Jul 1998 19:06:33 -0400
From: Michael <michael@nette.com>
Subject: HELP locking files
Message-Id: <35B67078.9F540CDD@nette.com>
I am trying to write to a file in Win32 as a response to submission via
a form. It should modify an HTML page, but I am getting inconsistent
results (the file is empty or missing parts). Is this because I am not
locking it? and if so, then how do I lock it. I tried using flock but
that didn't work.
Thanx!!
------------------------------
Date: 22 Jul 1998 23:14:22 GMT
From: yroh <yroh@samsung.co.kr>
Subject: How to know the number of hash items without running loop.
Message-Id: <6p5roe$o9s$1@news-read.att.co.kr>
Without running loop, is there way to count how many items the hash has?
------------------------------
Date: 22 Jul 1998 23:39:30 GMT
From: mick@io.com (Michele Beltrame)
Subject: Re: How to know the number of hash items without running loop.
Message-Id: <slrn6rcu9d.7h2.mick@caladan.italpro.ddns.org>
Hi yroh <yroh@samsung.co.kr>!
>Without running loop, is there way to count how many items the hash has?
You can use something like:
@hkeys = keys(%myhash);
$numitems = $#hkeys;
Best regards, Mickey.
--
Michele Beltrame
mick@io.com
http://www.italpro.com/mb/
------------------------------
Date: Thu, 23 Jul 1998 00:04:49 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: How to know the number of hash items without running loop.
Message-Id: <35B67F84.8825D3CB@shaw.wave.ca>
Michele Beltrame wrote:
>
> Hi yroh <yroh@samsung.co.kr>!
>
> >Without running loop, is there way to count how many items the hash
> >has?
>
> You can use something like:
>
> @hkeys = keys(%myhash);
> $numitems = $#hkeys;
>
You could also use $numitems = 5 and it would be correct more often.
$numitems = keys %myhash;
perldoc -f keys
perldoc perldata!
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Thu, 23 Jul 1998 00:38:19 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: im having trouble with a bit of perl script, if someone could give me a hand
Message-Id: <35B68753.E168FB05@shaw.wave.ca>
jhestyr@my-dejanews.com wrote:
>
>
> heres what i have:
>
> $prog=1;
> $dir=1;
> mkdir('temp', 0777);
> chdir('temp');
> while($prog <= 3){
> until($dir == 4) {
> print "dir = $dir\n";
> print "prog = $prog\n";
> mkdir("$dir", 0777);
> $dir++;
> }
> srand();
> $randnum = int( rand(3) ) + 1;
> chdir("$randnum");
chdir $randnum or die "Can't cd $randnum: $!\n";
If you always check the return value of functions, especially
file/directory functions, you will find your bugs a lot faster. Now fix
all your chdir and mkdir statements and you'll find the problem. If
not, read on.
> $prog++;
> print "prog = $prog\n";
> }
>
> but after fulfilling the nested until command, it moves onto the
> random funtion, and then exits the loop.
> mebbe putting a line: $count = 1 after the $prog++ ?
>
Maybe. Try that first. Then try $dir = 1 after $prog++.
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Wed, 22 Jul 1998 18:27:57 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Is Perl y2k compliant?
Message-Id: <ths5p6.03c.ln@localhost>
Victor O. (vonyemelukwe@att.com) wrote:
: Is Perl y2k?
No it is not.
(disregard what you saw when you did a word search
for '2000' in the documentation that came with
the perl distribution)
Perl is not worth learning.
Try Visual Basic instead.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 23 Jul 1998 00:12:13 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Perl -pi
Message-Id: <35B68140.934E389D@shaw.wave.ca>
BJ Kim wrote:
>
> I'm trying to edit in place a certain file using this command
>
> perl -p -i.bak -e "s/pear/plum/" fruit.txt
>
> I get this error:
> Can't do inplace edit: fruit.txt is not a regular file.
All perl error messages are documented in the perldiag man page.
Can't do inplace edit: %s is not a regular file
(S) You tried to use the -i switch on a special file,
such as a file in /dev, or a FIFO. The file was ignored.
Fruit In, Fruit Out? ;-)
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Thu, 23 Jul 1998 00:41:02 GMT
From: mshore@arborsoft.com
Subject: Perl 5.005 Beta 2 on NT
Message-Id: <6p60qv$2ou$1@nnrp1.dejanews.com>
Hi,
I'm having some trouble installing Perl 5.005 Beta 2 on NT.
I use MSVC++ 4.2 (including nmake) on NT4.0. When the "USE_THREADS" line is
uncommented in ...\win32\Makefile, the build craps out when it tries to make
the SOCKET extension. Here's the tail of the output:
...
Writing Makefile for Socket
nmake -nologo
cl.exe -c -Od -MD -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -Od -MD
-DNDE
BUG -DVERSION=\"1.7\" -DXS_VERSION=\"1.7\" -I..\..\lib\CORE Socket.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 10.20.6166 for 80x86
Copyright (C) Microsoft Corp 1984-1996. All rights reserved.
Socket.c
"Running Mkbootstrap for Socket ()"
The name specified is not recognized as an
internal or external command, operable program or batch file.
NMAKE : fatal error U1077: '0' : return code '0x1'
Stop.
NMAKE : fatal error U1077: 'd:\tools\msdev\BIN\NMAKE.EXE' : return code '0x2'
Stop.
---
The build breaks much earlier if USE_THREADS remains commented out.
Any insight would be greatly appreciated.
With thanks and regards,
Matt
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 22 Jul 1998 20:31:17 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Perl array name
Message-Id: <1dcl3kj.kxu6231r4kwzjN@bay1-156.quincy.ziplink.net>
Larry Rosler <lr@hpl.hp.com> wrote:
> That is certainly a simple and usable approach, but might get you into
> trouble in various ways. For example, suppose the name is not a valid
> Perl identifier?
Symbolic references may get you into trouble, but not in the way you
gave as an example. Any string is a valid identifier in a symbolic
reference.
DB<1> $x = "is this\tan\ninvalid identifier???"
DB<2> $$x = "no, it works!"
DB<3> x $$x
0 'or will it work?'
DB<5> X ~is
$is this^Ian^Minvalid identifier??? = 'no, it works!'
DB<6>
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 22 Jul 1998 19:47:51 -0400
From: allbery@rushlight.kf8nh.apk.net (Brandon S. Allbery KF8NH)
Subject: Re: Perl Beautifier Home Page
Message-Id: <ktaf61zbvc.fsf@rushlight.kf8nh.apk.net>
+-----
| There. And now for a more personal touch: if I read code in a fixed
| pitch font, like Courier, I notice that it tires me after a while. After
| only 10 minutes, I notice that I'm starting to stare at the letters. I
| must really concentrate to simply see what is written there. Besides,
| Courier is just a damn ugly. :-)
+--->8
XEmacs (former Lucid Emacs) supports variable-width fonts, and I've seen it
use them in C and Perl modes. I'm not very fond of the idea, actually, but
evidently *someone* is (Sun ships it with their SPARCWorks stuff).
Courier just plain sucks as a font. I use Lucida Sans Typewriter as my
monospaced font, and find it much easier to read (I find serif fonts give
me eye fatigue).
--
brandon s. allbery [os/2][linux][solaris][japh] allbery@kf8nh.apk.net
system administrator [WAY too many hats] allbery@ece.cmu.edu
electrical and computer engineering
carnegie mellon university (bsa@kf8nh is still valid.)
------------------------------
Date: 22 Jul 1998 17:16:37 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Perl Beautifier Home Page
Message-Id: <m33ebt5sm2.fsf@windlord.Stanford.EDU>
Brandon S Allbery KF8NH <allbery@rushlight.kf8nh.apk.net> writes:
> Courier just plain sucks as a font. I use Lucida Sans Typewriter as my
> monospaced font, and find it much easier to read (I find serif fonts
> give me eye fatigue).
A lot about Courier is explained by the fact that Courier is a font
designed for *printed* output. Using print fonts for screen display is
just a bad idea; the requirements are different. For one thing, screen
fonts are much easier to read if they're considerably bolder than would be
considered acceptable in printed output.
I'm happily using 9x15, the X font, have been for years, and find it quite
readable, particularly in white on black (which reduces eyestrain
considerably on an emitting display over black on white).
--
#!/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: Wed, 22 Jul 1998 23:37:26 GMT
From: sxidh@ts.sois.alaska.edu
Subject: perl losing required subroutines
Message-Id: <6p5t3m$uuc$1@nnrp1.dejanews.com>
I'm getting an undefined subroutine message that I don't understand. I've
looked through the manuals (Perl Programming, Advanced Perl Programming,
etc.), PerlFAQs, Dejanews,the man pages, etc. and can't find anything that
helps. I'm running perl 5.00404 under Digital Unix 3.2g. I'm hoping someone
here can give me a hand with this one or point me to the right place to look
the answer up myself. I've looked and I can't seem to find anything that
helps.
The situation is this: I've got a program that has a bunch of require's in
it. One of the require'd modules is BIND.pl which is essentialy a subroutine
called BIND. About 90% of the other required modules are also simply
subroutines which are common to one or two programs. Some of these
subroutines call the &BIND routine. On some occasions, I've never
satisfactorily figured out why, the calls to &BIND have resulted in the error
message "Undefined subroutine &main::BIND called at /some/other/module line
68." This is well after the require of BIND.pl (it's one of the first
requires that we do because it is so heavily used) and after &BIND has been
called numerous times. Why am I losing &BIND? Packaging is not causing this
to occur in our programs, as far as we can tell. (That would be too easy.)
We have over 100 modules that are being required and used, yet this one is
the only problem child. Does anyone have any explanations or ideas on the
cause of this anomaly? The only workaround/fix we have found to this is to
do another "require 'BIND.pl';" inside the offending module, which goes
against my knowledge of require.
Any suggestion or directions (RTFM with page numbers) would be appreciated. A
bit of pseudocode follows.
Ivan Heffner
sxidh@ts.sois.alaska.edu
University of Alaska Fairbanks
Statewide Office of Information Services
Technical Services
my_program:
#! /usr/local/bin/perl
use diagnostics -verbose
require 'BIND.pl';
require 'SOME_SUB.pl';
require 'SOME_OTHER_SUB.pl';
require 'ANOTHER_SUB.pl';
$var = &BIND("string");
.
.
.
&SOME_SUB(arg1,arg2,arg3);
SOME_SUB.pl:
sub SOME_SUB {
.
.
.
$var2 = &BIND($arg2);
&SOME_OTHER_SUB($var2);
.
.
.
}
SOME_OTHER_SUB.pl:
sub SOME_OTHER_SUB {
.
.
.
$var3 = &BIND("some string again");
&ANOTHER_SUB($var3);
.
.
.
}
ANOTHER_SUB.pl:
sub ANOTHER_SUB {
.
.
.
$last_bind = &BIND("This is the last straw");
.
.
.
}
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 22 Jul 1998 20:31:18 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: print FIC : An easy question !
Message-Id: <1dcl3v4.kcb1atcqqci0N@bay1-156.quincy.ziplink.net>
Uri Guttman <uri@sysarch.com> wrote:
> RJK> If you want to include quotes, you need to specify them within the
> RJK> string. Here is one way of doing that:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> RJK> print FIC "\"$in{'fond1'}\"" if $in{'fond1'} =~ m/\S/;
>
> hey ronald, you should know about qq! a much cleaner way to do this and
> it avoids the backwhacks and it handles nested pairs of
> parens/braces/brackets
And here is another:
> print FIC qq{"$in{'fond1'}"} if $in{'fond1'} =~ m/\S/;
>
> TIMTOWTDI
:-)
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Wed, 22 Jul 1998 20:31:24 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Regular expressions for Perl 5
Message-Id: <1dcl42b.q05yy3zz9nklN@bay1-156.quincy.ziplink.net>
BJKim <shado@uclink4.berkeley.edu> wrote:
> Does Perl 4 not support certain aspects of regular expressions that Perl
> 5 does.
Let's see... The version number of Perl 5 is higher than the version
number of Perl 4. What does that suggest?
> /(<TD>(.*?)</TD><TD>(.*?)</TD>){1}?/: nested *?+ in regexp at change.cgi
> line 70.
The only thing sillier than using the quantifier {1} is using the
quantifier {1} with non-greedy matching.
'Match exactly 1 instance of the subexpression, but match as few
instances as possible.'
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Wed, 22 Jul 1998 18:35:32 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: result pending code..?
Message-Id: <40t5p6.j5c.ln@localhost>
J. Pratt (jpratt@command-central.nmsd.k12.nm.us) wrote:
: I was wondering how one would code something that is "outcome
: dependent". What I mean by this term is. . let's say, you wanted a file
: to be emptied (rm'ing it, I suppose)
An empty file and a non-existant file are very different things
in my book...
: if and only if something is
: successful. More specifically, I am going to have a cron job setup that
: mails the contents of a file to myself, and if and only if the crontab
: job is successful will the files contents be emptied.
: The only real idea I had thought of so far is this.. The crontab entry
: would look something like:
: 0 1 * * * whoever cat file_with_info | mail myself@feh.com
: Now.. If I was to simply add "| rm file_with_info", it seems that would
: do the trick. . Hmm? But, then again, there's no guarantee that the
: file was mailed properly (but if not, it would go into the mail queue
: and should eventually get sent).
And getting "sent" gives no guarantee that it will be received either ;-)
: *shrug* Just a thought.. Any
: feedback on this? I figure there's other methods of accomplishing my
: goal.
I'd write a mail filter.
When you _receive_ the message, just 'reply' to it.
Have a mail filter that will go delete the file when it gets the reply.
: Additionally, although this sounds somewhat complex (but a good feature,
: nonetheless), I am wanting to make sure that if someone commits
: information to the file (you will be able to add info. to the file via
: the web) while the cron job is running and e-mailing the contents of the
: file, that their line of info. is not deleted nor sent again in the next
: e-mail job run.
perldoc -f flock
perlfaq5 How can I lock a file?
perlfaq5 What can't I just open(FH, ">file.lock")?
perlfaq5 I still don't get locking. I just want to increment
the number in the file. How can I do this?
Use the docs that are already on your hard disk...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 22 Jul 1998 22:53:03 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: specific character/position in string
Message-Id: <6p5qgf$9kr$1@news.iastate.edu>
Michael Shavel (mshavel@erols.com) wrote:
: Hello,
: I need to find out if the next to last character in a 3001 length
: character string is a period (.)
: There are other periods in the string that I do not care about. I don't
: know what their postion is though.
: I do not want to dump the whole string into an array or hash though.
: Anyone know of another way? I was thinking of substr but that function
: says it will extract the substring. I need the string in tact. Just need
: to know if the period is at position 3000.
A comparison of some different ways to do it follows. I'm slightly
confused as to why RINDEX2 took longer than RINDEX. Comments, anyone?
I've not used Benchmark much.
Unsuprisingly, regexes are the fastest (and were the only unrecommended
solution, oddly).
/home/kortbein% perl find.pl
Benchmark: timing 1000000 iterations of REGEX, RINDEX, RINDEX2, SUBSTR...
REGEX: 1 secs ( 0.97 usr 0.02 sys = 0.98 cpu)
RINDEX: 4 secs ( 3.87 usr 0.02 sys = 3.88 cpu)
RINDEX2: 5 secs ( 4.22 usr 0.02 sys = 4.23 cpu)
SUBSTR: 2 secs ( 1.47 usr 0.00 sys = 1.47 cpu)
/home/kortbein% cat find.pl
#!/usr/local/bin/perl5
use Benchmark;
my $string = 'a' x 2999 . '.' . 'b';
my $flag = 0;
timethese(1000000, {
'REGEX' =>
'$flag = 1 if $string =~ /\..$/',
'SUBSTR' =>
'$flag = 1 if ("." eq substr($string, -2))',
'RINDEX' =>
'$flag = 1 if (rindex($string, ".") eq length($string) - 2)',
'RINDEX2' =>
'$flag = 1 if (rindex($string, ".") eq 2999)'
});
Question to more experienced readers: why does my code warn about
use of an uninitialized variable in one of the timethese() evals
if I run with -w? I can't see where the usage mentioned is.
I thought it might have been substr(), since one can assign to
it, but a separate test I ran had no problems with substr() being
on the LHS or RHS of assignment.
Josh
--
__________________________________________
She had heard all about excluded middles;
they were bad shit, to be avoided.
- Thomas Pynchon
------------------------------
Date: Wed, 22 Jul 1998 20:31:25 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: SPLIT help please
Message-Id: <1dcl4cf.maft7i1py9x4hN@bay1-156.quincy.ziplink.net>
Tim Rosine <trosine@math.uwsuper.edu> wrote:
> On Wed, 22 Jul 1998 12:41:53 GMT, horseyride@hotmail.com wrote:
>
> >Can someone tell me how to do split commands for weird characters? I have two
> >splits, one where I want to split on a '.' (decimal) and one on a '|' (pipe
> >character). Thanks
> >
> >Adam
>
> @array = split('.',$string);
> @array = split('|',$string);
I don't think so.
DB<1> @array = split('|',$string);
DB<2> x @array
0 'f'
1 'o'
2 'o'
3 '|'
4 'b'
5 'a'
6 'r'
DB<3>
The first argument to split is a pattern match. If you give it a
string, it's *still* a pattern match. And '.' and '|' are
metacharacters within a regex, unless they are escaped with a backslash.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Wed, 22 Jul 1998 16:16:33 -0700
From: Anandan Balaji <anandan_balaji@emicx.mentorg.com>
Subject: symbolic links for windows
Message-Id: <35B672D0.53255D20@emicx.mentorg.com>
Hi,
I am writing some scripts, which has to run on both unix and windows
platforms.
Any idea about how to take care symbolic links? Any work arounds?
Thanks in advance,
-Balaji
--
-------------------------------------------------------
Anandan Balaji anandan_balaji@mentorg.com
-------------------------------------------------------
------------------------------
Date: 22 Jul 1998 23:28:45 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: The act of glueing one cat's nose to another's tail...
Message-Id: <6p5sjd$p4i$2@nswpull.telstra.net>
In article <35B64F87.EFC9705D@onlinetech.net>,
Shaun Gilroy <shaung@onlinetech.net> writes:
> ...and a similar operation performed on strings.
>
> Does anyone have a suggestion on how to copy and concatenate entire
> files in PERL without resorting to:
To copy, you might try to use File::Copy.
# perldoc File::Copy
To concatenate:
open file to write || die
foreach (files to read)
{
open file to read || die
while(<file to read>)
{
print to file to write
}
close file to read
}
close file to write
Of course, there are other ways.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Little girls, like butterflies, need no
Commercial Dynamics Pty. Ltd. | excuse - Lazarus Long
NSW, Australia |
------------------------------
Date: 23 Jul 1998 00:07:17 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: The act of glueing one cat's nose to another's tail...
Message-Id: <6p5url$h68@mozo.cc.purdue.edu>
cberry@cinenet.net (Craig Berry) writes:
}Shaun Gilroy (shaung@onlinetech.net) wrote:
}: Does anyone have a suggestion on how to copy and concatenate entire
}: files in PERL without resorting to:
}: exec "cat ...";
}That's trivial to write in Perl.
Just to bolster the Craig's claim, here's the complete source to cat
written in perl:
#!/usr/bin/perl -p
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Wed, 22 Jul 1998 23:31:35 GMT
From: montyh@umich.edu (monty hindman)
Subject: Re: Variable Interpolation
Message-Id: <rDut1.4812$24.28317833@news.itd.umich.edu>
I guess I should ask differently: Why is Perl more than happy to
interpolate a previously unmentioned scalar variable, while it won't do
the same for a previously unmentioned array variable? I'm not trying to
solve a problem here so much as understand what's going on.
Zenin (zenin@bawdycaste.org) wrote:
: monty hindman <montyh@umich.edu> wrote:
: : Why does this program compile just fine:
: : $a = "$b" ;
: : While this one produces a compiling error:
: : $a = "@b" ;
: : In string, @b now must be written as \@b at 2 line 1, near "@b"
: : Execution of 2 aborted due to compilation errors.
: Because @b hasn't been used anywere as a real array. All you need
: to do is use it somewhere first, even if it doesn't actually do
: anything.
: $ perl -e '$a = "@b"'
: In string, @b now must be written as \@b at -e line 1, near "@b"
: Execution of -e aborted due to compilation errors.
: $ perl -wce '@b = @b; $a = "@b"'
: -e syntax OK
: --
: -Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
: BSD: A psychoactive drug, popular in the 80s, probably developed at UC
: Berkeley or thereabouts. Similar in many ways to the prescription-only
: medication called "System V", but infinitely more useful. (Or, at least,
: more fun.) The full chemical name is "Berkeley Standard Distribution".
--
=======================
Monty Hindman
8500 S.W. Canyon Dr. #8
Portland, OR 97225
(503) 291-1752
montyh@umich.edu
=======================
------------------------------
Date: Wed, 22 Jul 1998 18:23:05 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Variable Interpolation
Message-Id: <p8s5p6.03c.ln@localhost>
monty hindman (montyh@umich.edu) wrote:
: Why does this program compile just fine:
: $a = "$b" ;
: While this one produces a compiling error:
: $a = "@b" ;
: In string, @b now must be written as \@b at 2 line 1, near "@b"
: Execution of 2 aborted due to compilation errors.
This is a popular quote from the 'perldiag' man page (second time today):
-----------------------
=item In string, @%s now must be written as \@%s
(F) It used to be that Perl would try to guess whether you wanted an
array interpolated or a literal @. It did this when the string was first
used at runtime. Now strings are parsed at compile time, and ambiguous
instances of @ must be disambiguated, either by prepending a backslash to
indicate a literal, or by declaring (or using) the array within the
program before the string (lexically). (Someday it will simply assume
that an unbackslashed @ interpolates an array.)
-----------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 22 Jul 1998 20:28:53 -0400
From: "Terry Cora" <TerryLCora@worldnet.att.net>
Subject: Web mail script
Message-Id: <6p603t$nak@bgtnsc02.worldnet.att.net>
Hi all,
I am looking for a web based e-mail script (ala hotmail) for a non profit
geographic spacific church directory site. Running a virtual server with a
"catch all" e-mail system. NetRoamer looks good, but they ignore my e-mails
and do not provide demo to see if it will work on my server. I installed
MailMan, but it will only check the "catch all" box.
Has anyone modified MailMan to to filter incoming messages and sort them
into spacific user boxes with a web interface to allow new users to sign up?
Or does anyone know of a similar program available for low (or no)cost
license to non-commercial sites? No support is needed.
Cheers!
Terry
------------------------------
Date: Wed, 22 Jul 1998 20:31:28 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: what is offline mode?
Message-Id: <1dcl4qs.ce9clytxzq7xN@bay1-156.quincy.ziplink.net>
Gaetano Vocca <gvoc@etb.bel.alcatel.be> wrote:
> This is a multi-part message in MIME format.
> --------------4F285C0C92C60D46290CFD27
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
Don't send multi-part messages in MIME format, please.
> Hi all,
> I'm a new Perl user enjoying the vast and "magic" Perl community. The
> question I have is the typical newbie one. I would like to use the
> routines of the CGI module to generate some HTML pages but not in a CGI
> program. Each time I try to run my small script the Perl program prints
> on STDOUT the message:
> (offline mode: enter name=value pairs on standard input)
> waits for a string of arguments and then it runs regularly.
> Is there any way to avoid this message and the request of the arguments?
This is covered in the documentation for the CGI module. Look at the
section on creating a new instance of a CGI object.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3228
**************************************