[7346] in Perl-Users-Digest
Perl-Users Digest, Issue: 971 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 3 19:07:26 1997
Date: Wed, 3 Sep 97 16:00:23 -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, 3 Sep 1997 Volume: 8 Number: 971
Today's topics:
ANNOUNCE: Locale::Iconv <mxp@linguistik.uni-erlangen.de>
ANNOUNCE: Tk-GBARR-1.01 <gbarr@ti.com>
Chart-0.94 (David Bonner)
Clearing screen in CGI kchadha@hotmail.com
Communication between objects and global subroutines in (Dan Sumption)
Re: defunct process after using open2() (Charles DeRykus)
Finding files - idiom? (Craig Berry)
Re: Finding files - idiom? <rootbeer@teleport.com>
Re: HELP My flock does not work?!? <rootbeer@teleport.com>
Re: Help! cron&perl ! (Ronald L. Parker)
How to kill a child? (Jun Zhuang)
How to open a file for both read and write <songtao@nortel.ca>
Image::Size 2.4 available on CPAN (Randy J. Ray)
Re: Is Perl for Win32 really as brain damaged as it see (Ronald L. Parker)
Re: library for dbase file processing. <ster@stargazer.net>
Re: My vs local declarations (Jason Gloudon)
NT Mail Question (Ranson)
Re: NT Mail Question <rmcguigan@ramresearch.com>
Re: pattern matching HELP! (Craig Berry)
Positioning cursor on screen <robwm@worldnet.att.net>
Re: Printing two variables on alternate lines? (Tad McClellan)
Re: Printing two variables on alternate lines? (Craig Berry)
Re: Simple Perl for Win 32 Question (not in FAQ) (Kevin)
Statistics::Descriptive v2.0 (Colin Kuskie)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 3 Sep 1997 21:14:54 GMT
From: Michael Piotrowski <mxp@linguistik.uni-erlangen.de>
Subject: ANNOUNCE: Locale::Iconv
Message-Id: <5ukk0e$9dd$1@nadine.teleport.com>
I've just uploaded Locale::Iconv to PAUSE; it should be available on
CPAN soon, under authors/id/MPIOTR. Alternatively, you can get it from
ftp://ftp.linguistik.uni-erlangen.de/pub/perl.
Its Module List entry is:
Name DSLI Description Info
------------- ---- -------------------------------------------- -----
Text::Iconv bdcO Convert charsets with XPG4 iconv() function MPIOTR
As you can see, this is a beta release, that is, it has not yet been
extensively tested. Consequently, I'll be grateful for bug reports and
comments.
The following is an extract from the README file:
Description
-----------
This module provides a Perl interface to the XPG4 iconv() function. It
is largely untested, especially for state-dependent encodings. For
more details see the pod documentation embedded in the file iconv.pm.
Prerequisites
-------------
Your system should be compliant with XPG4 or at least provide
iconv_open(), iconv() and iconv_close() functions compliant with XPG4.
Note that the possible conversions and the quality of the conversions
depend on the available iconv conversion tables and algorithms, which
are in most cases supplied by the operating system vendor. Some
systems also allow you to build your own tables (e.g. HP-UX, Digital
UNIX, and AIX provide the genxlt(1) command).
--
If a problem is not completely understood, it is probably best to
provide no solution at all. (Scheiffler/Gettys)
.................................................................
Michael Piotrowski mxp@linguistik.uni-erlangen.de
------------------------------
Date: 3 Sep 1997 21:13:40 GMT
From: Graham Barr <gbarr@ti.com>
Subject: ANNOUNCE: Tk-GBARR-1.01
Message-Id: <5ukju4$9al$1@nadine.teleport.com>
I have just uploaded to CPAN a new release of the libnet distribution.
This release contains updates and some new widgets that were mentioned
in release 1.00
The README from the distribution ....
This distribution is my contribution to the ever growing collection
of Tk Widgets, currently it includes
Tk::Cloth - An OO interface to Tk::Canvas
Tk::Pane - A widget panner (view only part of a widget)
Tk::TFrame - A frame with a title
Tk::ProgressBar - a widget to show completion status etc
Tk::NumEntry - An entry widget that accepts numbers and has up/down
buttons for in/decrement.
The documentation is minimal (or even non-existant) but I was
requested to release them before my life enters a stage of
turmoil (I am moving to the US real soon). I will release
better documentation after I have settled. In the mean time
the I hope the examples directory is sufficient.
Also in the works are :-
Tk::ListMgr - A widget that manages lists in various ways
eg, multi column, array
Tk::IFrame - An index frame (ie has tabs to select which sub-frame
is viewable)
Tk::MenuEntry - a text entry with a menu
These will hopefully be in the next release, but my time is very
limited at the moment. Feel free to mail me if you are interesed
in seeing what I have, but I don't feel they are ready
for release yet.
Please mail all bugs/comments directly to me <gbarr@ti.com> as I do not
read the Tk lists on a regular basis.
Copyright (c) 1997 Graham Barr <gbarr@ti.com>. All rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
Share and Enjoy !
--
The road to success is lined with many tempting parking spaces.
------------------------------
Date: 3 Sep 1997 21:16:10 GMT
From: davidb@kenan.com (David Bonner)
Subject: Chart-0.94
Message-Id: <5ukk2q$9fr$1@nadine.teleport.com>
Just posted Chart-0.94 to CPAN. Changes since 0.93:
Moved the legend down to be flush with the chart
Fixed the long decimal y-tick label problem
Fixed (for the last time, hopefully) the pre-5.004 compilation problem
Fixed handling of undefined data points
Added more colors for the default data colors
Added the transparent gif option
Added the option for user-specified colors
Added the grid_lines option
Enjoy, and mail me with any complaints/suggestions...
--
#=====================================================================#
#"it's the word's suppression that gives it the | david bonner #
# power, the violence, the viciousness" -lenny bruce | dbonner@bu.edu #
#=====================================================================#
------------------------------
Date: Wed, 03 Sep 1997 16:34:19 -0600
From: kchadha@hotmail.com
Subject: Clearing screen in CGI
Message-Id: <873321728.711@dejanews.com>
Hi,
I need to do the following in a CGI
(very simplified version given below : )
print " This is test 1 "
print "This is test 2"
sleep(5)
Clear the screen and
print "test 3"
print "test 4"
How would I clear the screen from the GCI script
after printing a couple of lines ?
Please e-mail your replies to kchadha@hotmail.com
Thank You !
K. Chadha
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Wed, 03 Sep 1997 21:45:28 GMT
From: dan@gulch.demon.co.uk (Dan Sumption)
Subject: Communication between objects and global subroutines in Perl
Message-Id: <340dd551.3439796@news.demon.co.uk>
After a year or two of tinkering with ever more ambitious and unwieldy
perl scripts, I have taken the plunge and tried to learn
object-oriented programming the Perl way (I have a little experience
from C/C++ and Java, and VB/JavaScript-type object models). I
anticipate a few problems along the way, as I am starting off with a
fairly major project which will need to be very flexibile in terms of
inheritance and slotting in new capabilities.
The first (of undoubtedly many) problems I have run up against is how
to communicate between my packages and the global parts of the
program. I have a library subroutine which I call
interpolate_variables. This takes as its input a single template
string, and any variable names within the template will be substituted
with the value of that variable at run-time.
For example, if the template string is
'$description is worth $value'
and
$description='this program'
and
$value='nothing'
Then the subroutine will return:
this program is worth nothing
However, because of the interpolation method used, I need to keep the
variable names simple, e.g. $description rather than
$self->{description}. This means (I think) that I need to store the
values (if only temporarily) in variables which are accesible outside
the object's package.
What is the best way of doing this? Is there a best way of doing this?
Am I stupidly overlooking something and, in so doing, putting my
objects in danger of contamination or other problems?
Any advice gratefully received, as well as pointers to good resources
on OO-perl (I have read Randal Schwarz's Unix Review columns and Tom
Christiansen's perltoot.
Ta.
Ta Ta.
Ta Ta Ta.
Dan Sumption, Technical Director dan@gulch.demon.co.uk
Hard Reality, Canary Wharf, London E14 dan@hardnet.co.uk
http://www.hardnet.co.uk/dan/
------------------------------
Date: Wed, 3 Sep 1997 19:13:02 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: defunct process after using open2()
Message-Id: <EFy5Dr.J4D@bcstec.ca.boeing.com>
In article <3401DAC0.A41B1A38@ml.com>, Alan Page <apage@ml.com> wrote:
>Does anyone know the proper way to close the process started when using
>open2()?
>I tried killing the process, closing each handle and I still end up with
>a defunct process.
>
open2 should reap the process for you but perhaps you could
try a backup reaper :
use IPC::Open2;
use POSIX 'WNOHANG';
$pid = open2(...);
waitpid($pid,WNOHANG);
HTH,
--
Charles DeRykus
------------------------------
Date: 3 Sep 1997 21:01:57 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Finding files - idiom?
Message-Id: <5ukj85$scd$1@marina.cinenet.net>
I am writing a Perl app which will take a filename argument, possibly
containing wildcards, and search the current filesystem (from root on
down) for files matching that argument.
My current approach is to turn the filename arg into a Perl regex (for
example, turning * into .*, ? into .), then traverse the filesystem using
File::Find, recording the files whose names match the regex. This works
just fine, but leaves me with the feeling that I'm overlooking some far
more direct way to do this. If it matters, I'm writing this for DOS, but
I'd certainly prefer a 'generic' solution.
So, any suggestions? TIA...
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Wed, 3 Sep 1997 15:28:13 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Craig Berry <cberry@cinenet.net>
Subject: Re: Finding files - idiom?
Message-Id: <Pine.GSO.3.96.970903152711.16111D-100000@julie.teleport.com>
On 3 Sep 1997, Craig Berry wrote:
> I am writing a Perl app which will take a filename argument, possibly
> containing wildcards, and search the current filesystem (from root on
> down) for files matching that argument.
Sounds like you want to start with find2perl, or something like it, since
that's just about what it does. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 3 Sep 1997 15:26:04 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Bosch Patrick <bosch@goweb.lu>
Subject: Re: HELP My flock does not work?!?
Message-Id: <Pine.GSO.3.96.970903151929.16111C-100000@julie.teleport.com>
On Wed, 3 Sep 1997, Bosch Patrick wrote:
> #!/usr/bin/perl
Use -w and 'use strict' to build better programs twelve ways. :-)
> open(FILE, "+<file.txt");
Always check the return value from open, to be sure that it worked.
> if (flock(FILE, LOCK_EX)) {
Unless you've done something you haven't shown here, Perl doesn't know
what you mean by LOCK_EX. Try putting 'use Fcntl qw(:flock);' in early in
your script.
> while (<FILE>) {
> print $_;
> }
> sleep(5);
> seek(FILE,0,2);
> print FILE "34\n";
> flock(FILE, LOCK_UN);
> close(FILE);
You should never unlock a file before it's closed. In fact, you should
never unlock it after it's closed, either. Just close it, and everything
should do what you want.
> } else {
> print "coucou\n";
> }
A more descriptive error message would be nice. Maybe "Can't flock: $!"
would work for you.
> exit(1);
Why exit with a constant non-zero exit status?
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 03 Sep 1997 21:16:29 GMT
From: ron@farmworks.com (Ronald L. Parker)
Subject: Re: Help! cron&perl !
Message-Id: <340ed31f.16642335@news.supernews.com>
On 3 Sep 1997 05:31:14 GMT, Tero Tuononen <tuononen@cc.helsinki.fi>
wrote:
>Hi there !
>
>I am having problems with the following structure:
>
>I have few perl scripts that work fine when executed from commandline
>and in proper directory. When I call these very same scripts from
>cron it does not work anymore. There is one script that is called from
>cron and then the script itself calls for more scripts when it generates
>proper commandlines to do some daily routines with daily changing files. All
>the stuff is located in the same directory but is there still a problem
>with paths or what ? The script cannot access some file that surely are
>in the same directory...it also has major difficulties copying result
>files to some subdirectories and so on.
>
Perhaps it has the wrong working directory when run from cron. If the
suggestions from other posters haven't helped, try adding this to the
beginning of the script:
chdir(($0=~m#(.*)/#)[0]);
--
Ron Parker
Software Engineer
Farm Works Software Come see us at http://www.farmworks.com
For PGP public key see http://www.farmworks.com/Ron_Parker_PGP_key.txt
------------------------------
Date: 3 Sep 1997 21:38:57 GMT
From: jzhuang@ringer.cs.utsa.edu (Jun Zhuang)
Subject: How to kill a child?
Message-Id: <5ukldh$gtv@ringer.cs.utsa.edu>
I tried to kill a child process after a fork(), but I find out
it ALWAYS ovewrwrite my printf in the parent process.
The code is:
$pid_A = fork;
if ($pid_A != 0) { # this is parent process
for( ; ;) {
if (waitpid($pid_A,0) == -1) #wait for child to finish
{last; }
}
}
else { # this is child process
alarm 30; # set timeout to 30 seconds
#do something here
alarm 0;
die or exit(1);
}
printf(some_file, "Hello world!"); #this should be parent only,
#but I found child is still alive here.
How do I kill a child completely?
--
Jun Zhuang |Jun Zhuang
Department of Computer Science |Department of Pharmacology
University of Texas |UT Health Science Center
San Antonio, Texas |San Antonio, Texas
Email: jzhuang@ringer.utsa.edu |Email: zhuang@uthscsa.edu
| jun@gcrdb.uthscsa.edu
------------------------------
Date: Wed, 03 Sep 1997 18:18:55 -0400
From: Songtao Chen <songtao@nortel.ca>
Subject: How to open a file for both read and write
Message-Id: <340DE24F.41C67EA6@nortel.ca>
Hi there,
Could anyone tell me how to open a file for both
read and write ?
I am new to Perl.
Thanks,
songtao@nortel.ca
------------------------------
Date: 3 Sep 1997 21:17:22 GMT
From: rjray@tremere.ecte.uswc.uswest.com (Randy J. Ray)
Subject: Image::Size 2.4 available on CPAN
Message-Id: <5ukk52$9gf$1@nadine.teleport.com>
Version 2.4 of Image::Size has been uploaded to PAUSE, and will propagate
to all CPAN sites over the next few days.
To build and install, you will need perl 5.002 or later, and sufficient
access to install an extension.
Summary of Changes in 2.4:
* Small bug in jpegsize, not returning the string 'JPG' as the third element
of the returned list. Figures I have a half-documented feature, and someone
actually uses it. :-)
>From the README file for 2.4:
Image::Size is a library based on the image-sizing code in the wwwimagesize
script, a tool that analyzes HTML files and adds HEIGHT and WIDTH tags to
IMG directives. Image::Size has generalized that code to return a raw (X, Y)
pair, and included wrappers to pre-format that output into either HTML or a
set of attribute pairs suitable for the CGI.pm library by Lincoln Stein.
Currently, Image::Size can size images in XPM, XBM, GIF, JPEG, PNG and the
PPM family of formats (PPM/PGM/PBM).
I did this because my WWW server generates a lot of documents on demand
rather than keeping them in static files. These documents not only use
directional icons and buttons, but other graphics to annotate and highlight
sections of the text. Without size attributes, browsers cannot render the
text of a page until the image data is loaded and the size known for layout.
This library enables scripts to size their images at run-time and include
that as part of the generated HTML. Or for any other utility that uses and
manipulates graphics. The idea of the basic interface + wrappers is to not
limit the programmer to a certain data format.
Please send any reports of problems or bugs to rjray@uswest.com. I wouldn't
mind a short note to know that you're using this, just so I can justify its
continued development to my manager :-). (In seriousness, a rough idea of
how many others are using this will help promote its upkeep.)
This package is copyright ) 1996 by Randy Ray (rjray@uswest.com) and is
placed in the public domain under terms of the Artistic License used to
cover Perl itself. See the file Artistic in the distribution of Perl 5.002 or
later for details of copy and distribution terms.
Perl module interface by Randy J. Ray (rjray@uswest.com), original
image-sizing code by Alex Knowles (alex@ed.ac.uk) and Andrew Tong
(werdna@ugcs.caltech.edu), used with their joint permission.
Some bug fixes submitted by Bernd Leibing <bernd.leibing@rz.uni-ulm.de>.
PPM/PGM/PBM sizing code contributed by Carsten Dominik
<dominik@strw.LeidenUniv.nl>. Tom Metro <tmetro@vl.com> re-wrote the JPG and
PNG code, and also provided a PNG image for the test suite. Dan Klein
<dvk@lonewolf.com> contributed a re-write of the GIF code.
A fix for reading binary data on PC-ish operating systems was contributed by
Silas Dunsmore <silasd@psyber.com>.
--
===============================================================================
Randy J. Ray -- U S WEST Technologies IAD/CSS/DPDS Phone: (303)595-2869
Denver, CO rjray@uswest.com
"It's not denial. I'm just very selective about the reality I accept." --Calvin
------------------------------
Date: Wed, 03 Sep 1997 21:06:44 GMT
From: ron@farmworks.com (Ronald L. Parker)
Subject: Re: Is Perl for Win32 really as brain damaged as it seems?
Message-Id: <340dcdc3.15268738@news.supernews.com>
On Wed, 3 Sep 1997 12:59:21 -0700, Tom Phoenix <rootbeer@teleport.com>
wrote:
>(Speculation alert.) I _think_ that a command in backticks is (sometimes?)
>handed off to the command-line processor, COMMAND.COM, which may be the
>culprit here. (But I don't know why _anything_ should be running the
>floppy drive here.) Does this happen with Sarathy's most recent binary?
>
> http://www.perl.com/CPAN/authors/id/GSAR/
Yes, it does (Perl 5.004_02 bindist 04).
Things in backticks access the floppy drive even when command.com
wouldn't think of looking there (cd and dir are builtins, and both hit
the floppy when I tested it.) system() doesn't hit the floppy drive,
so I think perhaps Perl is trying to put the results of the backticked
command in a temporary file, and whatever code is doing that tries to
use A: first. Fileglobs do the same thing. This doesn't matter much
to me, because backticks and fileglobs are nearly useless anyway when
the command shell is so brain-damaged, but it does appear to be a bug.
Words to live by: If you're thinking of asking MS-DOS to do something
for you, chances are you just haven't seen how Perl can do it better.
>
>> Also, chdir and Win32::SetCwd do not work when attempting to change
>> the current directory to a different drive and using opendir on the
>> root of a drive fails.
>
>Sounds like you're ready to file a bug report. :-)
Before we jump to conclusions, let's see some code. I've never had
problems with chdir, and I've used it in both ActiveWare Perl and in
Sarathy's builds. My quick test of opendir on the root of a drive
seemed to work just fine, too. Note to the original poster: check
those backslashes. Better yet, change them to forward slashes.
--
Ron Parker
Software Engineer
Farm Works Software Come see us at http://www.farmworks.com
For PGP public key see http://www.farmworks.com/Ron_Parker_PGP_key.txt
------------------------------
Date: 3 Sep 1997 22:12:37 GMT
From: "Ster" <ster@stargazer.net>
Subject: Re: library for dbase file processing.
Message-Id: <01bcb8b6$a3483bb0$01808080@cornholio>
Okay, nobody wants to direct me to a PERL 4 library cause it's obsolete.
How about PERL 5 library then?
______________________
Ster@stargazer.net
http://stargazer.net/ster
------------------------------
Date: 3 Sep 1997 22:15:28 GMT
From: jgloudon@bbn.com (Jason Gloudon)
Subject: Re: My vs local declarations
Message-Id: <5ukni0$ktg$1@daily.bbnplanet.com>
In article <340DB07E.D63@wv.MENTORG.COM>,
WX Guest account <wxguest1@wv.MENTORG.COM> wrote:
> Lots of Code - too much Perl magic :
Your examples depend on some magic that fuzzify your question.
Man Page extract -
open FILEHANDLE
Opens the file whose filename is given by EXPR,
and associates it with FILEHANDLE. If FILEHANDLE
is an expression, its value is used as the name of
the real filehandle wanted. If EXPR is omitted,
the scalar variable of the same name as the
FILEHANDLE contains the filename. ____(Note that
lexical variables--those declared with my--will
not work for this purpose; so if you're using my,
specify EXPR in your call to open.)____
The second example fails when you attempt to open a file for reading, the default if you leave out the ">" prefix. If you add the prefix you'll see that my does not work with open in this manner. Try the following example instead:
#!/usr/bin/perl
$somevalue='outside';
sub ourvalue {
local $somevalue = 'inside'; # Replace local with my and compare
print "ourvalue:$somevalue\n";# the output
¬inlexical;
}
sub notinlexical {
print "notinlexical:$somevalue\n";
}
print "Main:$somevalue\n";
&ourvalue;
print "Main:$somevalue\n";
>3. One last question. There are at least three ways to declare a
>variable:
> 1. $file_name = blah #A global declaration
> 2. local $file_name = blah #A global, locally scoped value
> 3. my $file_name = blah #A local var, meaningless outside innermost
>block.
>
>What happens if $file_name isn't declared globally already, but I
>declare it with a "local" declaration instead of "my"? Does it create a
>global variable, but hide the locally assigned value? And are these
>declarations static or dynamic?
I think you should try modifying the program I presented above to test these.
As for static or dynamic ? If you are referring to scoping - yes, local and my create dynamically scoped names.
------------------------------
Date: 3 Sep 1997 21:11:45 GMT
From: ranson@infoave.net (Ranson)
Subject: NT Mail Question
Message-Id: <5ukjqh$18e@news1.infoave.net>
Forgive me, but I know little about NT servers. I need to write a program that
is going to send mail from a perl script. Having always worked in UNIX
the code below almost always works.
Thanks in advance.
Q. Does NT use sendmail? Or does NT use another mail prog. ?
$mailprog = '/usr/sbin/sendmail';
open (MAIL, "|$mailprog $mymail") || die "Can't open $mailprog!\n";
print MAIL "Reply-to: $UserMail $UserName\n";
------------------------------
Date: 3 Sep 1997 21:58:08 GMT
From: "Ryan" <rmcguigan@ramresearch.com>
Subject: Re: NT Mail Question
Message-Id: <01bcb8b5$3330d180$6e6fa1cd@www>
This has been the biggest pain in the ass for so many people. You'd think
Microsoft would do something for little things like this ( I've heard of a
lot of programmers switching back to UNIX machines for this very reason)
That's not entirely necessary though. First of all, you'll need to
download or purchase a sendmail program for NT. You should throw away
Activeware's port of perl for win32's ( really annoying when trying to use
pipes ) and get Garusam...some funny name's port of perl from CPAN. Change
your scripts,
$mailprog = 'c:\whatever\whatever.exe';
Hope this helps...
Ranson <ranson@infoave.net> wrote in article
<5ukjqh$18e@news1.infoave.net>...
>
> Forgive me, but I know little about NT servers. I need to write a
program that
> is going to send mail from a perl script. Having always worked in UNIX
> the code below almost always works.
>
> Thanks in advance.
>
> Q. Does NT use sendmail? Or does NT use another mail prog. ?
>
> $mailprog = '/usr/sbin/sendmail';
>
> open (MAIL, "|$mailprog $mymail") || die "Can't open $mailprog!\n";
>
> print MAIL "Reply-to: $UserMail $UserName\n";
------------------------------
Date: 3 Sep 1997 21:13:26 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: pattern matching HELP!
Message-Id: <5ukjtm$scd$2@marina.cinenet.net>
Gary Colman (SPAMFREEcolmang@ms.com) wrote:
: > I am trying to check for illegal characters in a string.
: > the allowable set is [a-z0-9_&.-] and I am trying to write code
: > But no matter what I do I can't seem to find the right syntax.
:
: print "Allowable chars: A-Z a-z 0-9 & . - _\n";
: chop($bob=<STDIN>);
: die "foo'ed\n" unless ($bob =~ /^[a-z0-9_&\.-]*$/);
Probably more efficient to do the complement of that test; replace the
last line with:
die "Foo'ed\n" if $bob =~ /[^a-z0-9_&\.-]/;
In other words, look for any single character *not* in your acceptable
list.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Wed, 03 Sep 1997 15:27:24 -0700
From: Robert Moorhead <robwm@worldnet.att.net>
Subject: Positioning cursor on screen
Message-Id: <340DE44C.3ACC@worldnet.att.net>
Hi everyone!
I am writing a perl 5.003 script which I would like to reposition the
cursor to overwrite the previous line printed on the screen. Is there a
way to supply X-Y coordinates to command perl to place the cursor where
I would like it on the screen or will I always have to put up with my
data scrolling off the screen? Would it be necessary to embed C code
within my script?
Also, does perl offer a function equivalent to the C function
getche()? I would like to input one character such as a menu selection
without requiring the user to press the 'enter' key. Is this a
possibility?
Thank you for your help!
Rob
------------------------------
Date: Wed, 3 Sep 1997 15:42:51 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Printing two variables on alternate lines?
Message-Id: <b4iku5.0o5.ln@localhost>
Phil Davey (pd@mole.bio.cam.ac.uk) wrote:
: Hi,
: I have two variables containing multiple line text and I would like to
: print them on alternate lines.
: For example if $foo is:
: xxxxxxxxxxxxxxxxxx
: xxxxxxxxxxxxxxxxxx
: and $bar is:
: aaaaaaaaaaaaaaaaaa
: aaaaaaaaaaaaaaaaaa
: I would like to end up with:
: xxxxxxxxxxxxxxxxxx
: aaaaaaaaaaaaaaaaaa
: xxxxxxxxxxxxxxxxxx
: aaaaaaaaaaaaaaaaaa
: Any ideas?
: I've searched through DejaNews and looked through the man pages and FAQ
: but I can't find anything which helps.
---------------------------------------
#!/usr/bin/perl -w
$foo = "xxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxx\n";
$bar = "aaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaa\n";
@f = split /\n/, $foo;
@b = split /\n/, $bar;
die "different number of lines\n" unless @f == @b;
for ($i=0; $i<@f; $i++) {
print "$f[$i]\n$b[$i]\n";
}
---------------------------------------
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: 3 Sep 1997 21:36:18 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Printing two variables on alternate lines?
Message-Id: <5ukl8i$scd$3@marina.cinenet.net>
Phil Davey (pd@mole.bio.cam.ac.uk) wrote:
: I have two variables containing multiple line text and I would like to
: print them on alternate lines.
:
: For example if $foo is:
: xxxxxxxxxxxxxxxxxx
: xxxxxxxxxxxxxxxxxx
:
: and $bar is:
: aaaaaaaaaaaaaaaaaa
: aaaaaaaaaaaaaaaaaa
:
: I would like to end up with:
: xxxxxxxxxxxxxxxxxx
: aaaaaaaaaaaaaaaaaa
: xxxxxxxxxxxxxxxxxx
: aaaaaaaaaaaaaaaaaa
:
: Any ideas?
: I've searched through DejaNews and looked through the man pages and FAQ
: but I can't find anything which helps.
Here's one way...note it prints any 'extra' lines from either string all
at the end.
#!/usr/bin/perl -w
use strict;
my $foo = "foo 1\nfoo 2\nfoo 3\n";
my $bar = "bar 1\nbar 2\nbar 3\nbar 4\nbar 5\n";
my @foo_lines = split(/\n/, $foo);
my @bar_lines = split(/\n/, $bar);
my $foo_line;
my $bar_line;
foreach $foo_line (@foo_lines) {
$bar_line = shift @bar_lines;
print "$foo_line\n";
print "$bar_line\n" if defined $bar_line;
}
foreach $bar_line (@bar_lines) {
print "$bar_line\n";
}
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 3 Sep 1997 14:34:00 -0700
From: klander@primenet (Kevin)
Subject: Re: Simple Perl for Win 32 Question (not in FAQ)
Message-Id: <340dd678.19052806@news.primenet.com>
On Wed, 03 Sep 1997 20:42:42 GMT, ron@farmworks.com (Ronald L. Parker)
wrote:
>On 2 Sep 1997 15:23:01 -0700, klander@primenet (Kevin) wrote:
>
>>$filename =~ /^(.+\\)(.*)$/; # <-- extracts path and filename into $1
>> # and $2
>>
>>$fpath = $1;
>>$fname = $2;
>
>Doesn't work for $filename eq '\\autoexec.bat'
>
Oops. You're right. Take out the ^ anchor.
>It also assumes (IMHO mistakenly) that it was given a filename
>separated by backslashes, while Perl itself is content with slashes
>(which I prefer to type when I can, since they're in the same place on
>all keyboards.)
>
Yes, I made assumptions there. The point was to show that regular
expressions can be used for this type of thing. I give up. Use
File::Basename...
-Kevin
------------------------------
Date: 3 Sep 1997 21:14:05 GMT
From: colink@latticesemi.com (Colin Kuskie)
Subject: Statistics::Descriptive v2.0
Message-Id: <5ukjut$9at$1@nadine.teleport.com>
I have uploaded version 2.0 of Statistics::Descriptive to CPAN (with
much help from Herr Koenig :) Here are the details from the README
file:
-------------------------------------------------------------------------
This is a complete rewrite of the OO interface to
Statistics::Descriptive. A full description of the new interface can
be found in the POD documentation inside the module, here are the
highlights:
* None of the underlying methods of calculation have been changed.
* There are two separate, distinct classes in the module, Sparse and
Full. Full inherits from Sparse and extends it with storage of the
data and additional methods that depend on analyzing the data based
on user input (in general). It should be easy to inherit from
either of the classes.
* Minimum and maximum methods are now calculated as part of the
Sparse class, resulting in a faster access to that data.
* The indices to the maxima and minima are also available.
* Methods were added to manually sort the data and prevent
subsequent sorting of the data, sort_data and presorted,
respectively. This should speed up some of the analysis by not
repeatedly sorting the data.
Please send any bugs, comments, complaints or suggestions to me,
colink@latticesemi.com
Enjoy!
------------------------------
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 971
*************************************