[6701] in Perl-Users-Digest
Perl-Users Digest, Issue: 325 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 17 16:17:14 1997
Date: Thu, 17 Apr 97 13:00:46 -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 Thu, 17 Apr 1997 Volume: 8 Number: 325
Today's topics:
"-lna0F<" VS #! -lna0F< (ash)
Re: "Dummies" book any good? (Abigail)
Re: $= <gnat@elara.frii.com>
Re: A simple substitution <gnat@elara.frii.com>
Re: Can we create an executable of perl program <gnat@elara.frii.com>
Re: client timing out (Andreas Karrer)
Re: convert a char into ASCII <gnat@elara.frii.com>
Employment OP <mservice@e-d-s.com>
Re: Get a week number from a file <gnat@elara.frii.com>
Re: Good editor for W95? (Christopher Masto)
Re: Good editor for W95? <Chris.King@swindon-fc.demon.co.uk.mars>
Re: Good editor for W95? <wmeahan@ford.com>
has someone written a word counter (not a wc clone) <usenet-tag@qz.little-neck.ny.us>
Help with Math::BigFloat si vous plait <sysop@gbfcu.reno.nv.us>
Help..Perl Script For Byte Counter <deepak@pcsltd.com>
Re: HELP: Redirection with Perl... <Chris.King@swindon-fc.demon.co.uk.mars>
Re: How do I randomly re-order the lines of a file? <gnat@elara.frii.com>
How to direct screen output to a file ? <dsonak@us.oracle.com>
Re: how to get perl handle elm's receive automatically <gnat@elara.frii.com>
How to track memory usage (Ed Mahr)
Re: how to use a system-installed Perl w/locally downlo <gnat@elara.frii.com>
Re: HTML Parser anywhere ? <eryq@enteract.com>
Re: HTML Parser anywhere ? (Mike Stok)
Last Update! <zaheed.haque@ein.ericsson.se>
Leap-year date routine needed (R. D. Davis)
Re: New Microsoft Perl Product (fwd) <cole@io-design.com>
newbie install problem <rizulof@newschool.edu>
Re: Palindromic words search??? <Chris.King@swindon-fc.demon.co.uk.mars>
Re: PERL 4.036 for Solaris 2.5 <eryq@enteract.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Apr 1997 04:27:46 GMT
From: searlea@aston.ac.uk (ash)
Subject: "-lna0F<" VS #! -lna0F<
Message-Id: <5iv042$ra7$1@whatsit.aston.ac.uk>
(nice subject line eh? :)
Just a wee little question...
This does what I want (csh):
perl "-lna0F<" -e 'map { />/ && print "number ".++$i.": $`" } @F' < x.html
but this doesn't:
#!/usr/local/bin/perl -lna0F<
map { />/ && print "number ".++$i.": $`" } @F
The only difference is that the #! version doesn't seem to process the -l
switch before setting $/ to null!
Is this a bug, or am I missing something?
(if it's a bug, has it been fixed?)
Summary of my perl5 (5.0 patchlevel 3 subversion 2) configuration:
Platform:
osname=solaris, osvers=2.5, archname=sun4-solaris
--
/*-------------------------------*
| Ash Searle - ash@innocent.com | " confused "
*-------------------------------*/
------------------------------
Date: Thu, 17 Apr 1997 18:45:27 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: "Dummies" book any good?
Message-Id: <E8spFr.GII@nonexistent.com>
On 17 Apr 1997 09:41:33 +0100, Olivier Dehon wrote in comp.lang.perl.misc
<URL: news:njzbu7ehwhu.fsf@jpmorgan.com>:
++ abigail@fnx.com (Abigail) writes:
++
++ >
++ > On Wed, 16 Apr 1997 10:51:40 GMT, Jonathan Peterson wrote in
++ > comp.lang.perl.misc <URL: news:3354ab99.3478663@news.sonnet.co.uk>:
++ > ++
++ > ++ Explaining to a real beginner that:
++ > ++
++ > ++ if ($a == 1) {
++ > ++ print ("Whee!");
++ > ++ }
++ > ++
++ > ++ is the same as
++ > ++
++ > ++ $a || print ("Whee!");
++ > ++
++ > ++ is not something that you can do in a few sentences. More like a few
++ > ++ chapters.
++ >
++ >
++ > Ok, then what do you do if the beginner set $a to 2 and complains it
++ > prints "Whee" in the second case and not in the first?
++ >
++
++ Oops !
++ If the beginner sets $a to 2, it won't print "Whee!" in any case !
++ So if he complains it does, he is probably trying to test your
++ own knowledge of Perl ;-)
Oops. I was assuming Jonathan meant to write: $a && print ("Whee!");
++ I hope that not too many beginners are reading this thread, because
++ they will get really confused !
++
++ P.S.:
++ From the perlop manpage:
++ Binary "||" performs a short-circuit logical OR operation. That is, if
++ the left operand is true, the right operand is not even evaluated. Scalar
++ or list context propagates down to the right operand if it is evaluated.
Indeed, hence:
if ($a) {
print ("Whee!");
}
and
$a && print ("Whee!");
should have the same effects.
Abigail
------------------------------
Date: 16 Apr 1997 11:46:05 -0600
From: Nathan Torkington <gnat@elara.frii.com>
Subject: Re: $=
Message-Id: <5q67xm509u.fsf@elara.frii.com>
Brian Lorraine <lorraine@ait.nrl.navy.mil> writes:
> DO I have to associate the predefined "$=" to the file i'm refering
> to somehow or will it automatically assume it's counting the lines
> in the LAST FILE that I opened?
(from perlvar):
format_lines_per_page HANDLE EXPR
$FORMAT_LINES_PER_PAGE
$= The current page length (printable lines) of the
currently selected output channel. Default is 60.
(Mnemonic: = has horizontal lines.)
(from IO::Handle):
See the perlvar manpage for complete descriptions of each
of the following supported IO::Handle methods:
[...]
format_lines_per_page
STDOUT is default selected output channel. You can set $= for a
particular filehandle with:
use IO::Handle;
format_lines_per_page MYHANDLE 24;
Nat
------------------------------
Date: 16 Apr 1997 11:50:41 -0600
From: Nathan Torkington <gnat@elara.frii.com>
Subject: Re: A simple substitution
Message-Id: <5q4td65026.fsf@elara.frii.com>
abigail@fnx.com (Abigail) writes:
> What's wrong with "tr/a-z\xe0-\xf6\xf8-\xfe/A-Z\xc0-\xd6\xd8-\xde/;"?
You assume a particular character set. Those may not be the write
values for people with Swedish, German, Japanese, etc, character sets.
For single-byte encodings, getting your locale (man perllocale)
working is the easiest way to make "word characters" and "non-word
characters" work (as well as uc, etc).
Hope this helps!
Nat
------------------------------
Date: 16 Apr 1997 11:52:46 -0600
From: Nathan Torkington <gnat@elara.frii.com>
Subject: Re: Can we create an executable of perl program
Message-Id: <5q3esq4zyp.fsf@elara.frii.com>
pan.dhanwada@teldta.com writes:
> I am calling a perl program using a system command of c
> main()
> {
> system('x.pl');
> }
>
> Here the problem is as the perl program is called thousands of times the
> system is getting slowed down. The main reason for the slow down is as
> perl program is an interpreter not an executable.
Another way of looking at it is that you're calling system() thousands
of times. Try making your perl script do the thousands-of-times part.
That way you only load it once.
Nat
------------------------------
Date: 17 Apr 1997 19:34:21 GMT
From: karrer@ife.ee.ethz.ch (Andreas Karrer)
Subject: Re: client timing out
Message-Id: <slrn5lcupv.4cl.karrer@kuru.ee.ethz.ch>
In article <5j3veo$66t$1@neocad.com>, Jeff Stampes wrote:
>functionality working, it's based on the first examples on Camel 2
>P. 349-350.
Make sure you get Larry's fixes
(http://www.perl.com/perl/critiques/camelrata/fixes.clean), especially
for that IPC section of the (1st printing) of Camel 2. Doesn't matter
much for this particular code, though.
>I'm including both scripts below...I'm looking for how I can control
>the timeout of the client, and also interested in determining what
>the SO_MAXCONN of the server is, and can I control this to allow
>larger number of connections, or is this a system constant that I
>cannot control?
Depends on the system. The Socket module gets SOMAXCONN from
/usr/include/sys/socket.h or thereabouts, but you can just say:
perl -e 'use Socket;print SOMAXCONN, "\n"'
to find out. The numerical value will almost universally be 5.
On some systems, most notably the original 4.2BSD code, this is the
maximum value for the listen queue length. Some implementations even
_ignore_ the second parameter in listen() and use 5 no matter what
you specify. On the other hand, the man page on Solaris 2 says in
the section formerly known as BUGS:
There is currently no backlog limit.
- Andi
------------------------------
Date: 16 Apr 1997 11:57:39 -0600
From: Nathan Torkington <gnat@elara.frii.com>
Subject: Re: convert a char into ASCII
Message-Id: <5q208a4zqk.fsf@elara.frii.com>
Rachel Mackenzie <rachel@cbogate.peel.edu.on.ca> writes:
> How do you change a character to ascii???
> how do you change ascii to character????
You're looking for the ord() and chr() functions, documented in the
perlfunc manpage (type "man perlfunc" and see if the person who
installed perl was nice to you :-).
$number = ord($char);
$char = chr($number);
For example,
$space = ord(" "); # $space is now 32
print "A space has ASCII value $space\n";
$sep = chr($space); # $sep is now a string containing one space
print "Read", $sep, "The", $sep, "Manual,", $sep", "Rachel\n";
:-)
Nat
------------------------------
Date: Thu, 17 Apr 1997 14:03:04 -0400
From: "Matthew A. Service" <mservice@e-d-s.com>
Subject: Employment OP
Message-Id: <335665D8.2A56@e-d-s.com>
Looking for perl programmer for online catalog/order entry project.
Interested parties please mailto:perl@e-d-s.com
------------------- Electronic Data Strategies ---------------------
Bringing Your Business to the World!
Matthew A. Service * Web Design
mservice@e-d-s.com * Shopping Cart Solutions
Ph:860-749-2219 * Site Promotion
Fax:860-749-1490 * Consulting
AT&T BusinessReach Partner http://www.att.com/worldnet
AT&T Creative Alliance Partner http://www.att.com/cap/gallery
GTE-SuperPages Authorized Sales Agent http://superpages.gte.net
--------------------- http://www.e-d-s.com -------------------------
------------------------------
Date: 16 Apr 1997 12:07:06 -0600
From: Nathan Torkington <gnat@elara.frii.com>
Subject: Re: Get a week number from a file
Message-Id: <5qzpuy3kqd.fsf@elara.frii.com>
"Charles F. Ritter" <critter@quack.kfu.com> writes:
> But if modules scare you and your on a unix machine you could
> iterate over the array returned by the system "cal" command. "cal"
> returns this:
Modules scare you? That's a shame. Without modules, you're almost
definitely being cursed to reinvent the square wheel, instead of using
a sleek, smooth, and well-balanced, wheel that has been written,
tested, and prooved by thousands of programmers.
Which part of installing Date::DateCalc don't you like? Depressed and
glum because you don't have access to write to /usr/local/lib/perl5?
You can install modules in your own directories, and then do
use lib "/path/to/my/perl/directory";
use Date::DateCalc;
at the top of your scripts. Or just put Date/DateCalc.pm into the
same directory as your script and perl will automagically find it for
you.
If the actual process of making and installing modules is what causes
you to wake in a sweat at 3am, consider going through the pain and
torment for the CPAN module (which will come with 5.004) once, and
then have *it* do the build and install for you. Why suffer, when we
can write programs to suffer for us?
If there's a fear worth getting over with perl5, it's definitely
modules. Come, hold my hand little one. Let us walk together through
the valley of camels ...
Nat
------------------------------
Date: 17 Apr 1997 15:20:57 GMT
From: exidor@superior.net (Christopher Masto)
Subject: Re: Good editor for W95?
Message-Id: <5j5f4p$bco@lacy.zippo.com>
In article <33554994.60A2@inlink.com>,
Benjamin Burack <rascal@inlink.com> wrote:
>I'm writing CGI scripts in perl on my W95 machine, and then uploading
>them to the Unix server. I'm looking for recommendations on good
>editors that can easily save in a Unix format.
There is a Win32 port of Emacs available, called NTemacs. You can get more
information at http://www.cs.washington.edu/homes/voelker/ntemacs.html.
I haven't used this in a while, so it's probably even better than I
remember. :-) If the ange-ftp mode works, you have the added bonus of
being able to edit remote files without the bother of manually FTPing
back and forth or dealing with the lag of a telnet-over-PPP session.
--
Christopher Masto . . . .
chris@masto.com . . . . . Masto Consulting: info@masto.com
perl -e 'map{vec($x,$_>$}?$_+$y:$_+($y+=8),1)=1;$}=$_}split//,"12360123".
------------------------------
Date: Thu, 17 Apr 1997 12:05:48 +0100
From: Chris King <Chris.King@swindon-fc.demon.co.uk.mars>
Subject: Re: Good editor for W95?
Message-Id: <d9apXTAMQgVzEwcp@swindon-fc.demon.co.uk>
In article <33554994.60A2@inlink.com>, Benjamin Burack
<rascal@inlink.com> writes
>I'm writing CGI scripts in perl on my W95 machine, and then uploading
>them to the Unix server. I'm looking for recommendations on good
>editors that can easily save in a Unix format.
Here's a batchfile that can convert them for you if you like - not too
efficient but it works. Make sure perl's in your path though:
@REM='
@echo off
perl -S %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
goto endofperl
';
#dos2unix for dos via perl
#usage: dos2unix infile [outfile]
if (($#ARGV > 1) || ($ARGV[0] eq "")) {
print "dos2unix: Invalid args
Usage: dos2unix infile [outfile]\n\n";
exit(1);
}
$infile=$ARGV[0];
$outfile=$ARGV[1] || $infile; #write to same file
open (IN,$infile);
@slurp=<IN>;
close (IN);
open (OUT,">$outfile");
binmode OUT;
print OUT @slurp;
close (OUT);
__END__
:endofperl
--
Chris King
The similarity of any fact mentioned within this post and
any in reality, living or dead, is purely coincidental.
Remove 'mars' from address when replying. I hate spam.
I like corned beef though.
------------------------------
Date: Thu, 17 Apr 1997 13:18:59 -0400
From: Bill Meahan <wmeahan@ford.com>
Subject: Re: Good editor for W95?
Message-Id: <33565B82.5DAA@ford.com>
netkid@netcom.com wrote:
>
> In <33554994.60A2@inlink.com>, Benjamin Burack <rascal@inlink.com> writes:
> >I'm writing CGI scripts in perl on my W95 machine, and then uploading
> >them to the Unix server. I'm looking for recommendations on good
> >editors that can easily save in a Unix format.
> >
> >Thanks,
> >Ben Burack
> >rascal@inlink.com
>
> An Ascii FTP transfer should handle the CRLF to LF translation correctly.
[That settles the "Unix compatibility" issue, but ....]
Oh, boy!!! Another "what is the best editor for Perl holy war!"
This seemed to stop the last one (perhaps coincidentally):
-------------------Begin included text-----------------------------
After 30+ years of programming (starting with IBM 1620 machine language
entered through the front-panel switches), I've adopted the following,
highly cynical, biased-as-hell curmudgeonly views on "the best" of
anything, particularly editors:
1) **There is no "best" editor** (or programming language or PDA, or
Operating system, or GUI, or whatever) in any abolute or abstract sense.
There is only the editor that is "best" for YOU IN YOUR SITUATION.
2) Number of features, size, speed, number of existing users etc. are
all interesting, possibly even useful data points but ultimately
unpersuasive in themselves.
3) The editor that <name of net.god> thinks is best may well be the
very, very best editor for **them** but that doesn't mean it's the best
for **you** regardless of how forcefully the net.god and his/her
disciples argue for it.
4) Different people have different "mental models" of how the act of
editing takes place. This is a product of their previous experience,
neural organization, personality and a host of other considerations
having nothing whatsoever to do with code size, response time, extension
language or the other accidentals these editior wars tend to focus on.
Thus if your mental model of the editing process tends to separate
editing into different classes of actions only one of which should take
place at a time, then a "modal" editor (e.g. vi and its kin) is probably
a very good choice.
On the other hand, if you see editing as an continuous flow of "typing"
interspersed with occasional commands, then a "modeless" editor (e.g.
emacs and its kin) may be the better choice.
This choice of "moded" versus "modeless" is probably the hardest and
most basic choice since all the other features in the world will NOT
overcome the pain and suffering forced upon you by an editor that
operates in a modal manner if your brain operates modeless (or vice
versa).
BTW, some of us shift mental models depending on the situation at hand:
for large-scale editing I work better with a modeless editor so I tend
to use emacs or one of its kin. OTOH if I need to quickly correct a
simple typo or just replace a simple string, I'm already operating in a
defacto "fix-it mode" so I'm more likely to grab plain-vanilla vi. Go
figure.
5) Feature sets, like color syntax highlighting, syntax direction, tags,
class hierarchies dog walking, baby changing and ego stroking are all
really *nice* features and can prove quite useful IF (and I do mean IF)
they are implemented in a way that makes sense to YOU and don't get in
the way of doing the basic function of editing text.
However, the usefulness of any given feature set (or individual feature)
greatly depends on how often you're going to do anything that uses it.
If you sit in front of a tube and grind code 6-20 hours per day every
working day, they may be a whole lot more helpful than if you whack out
a 20-line script once every fortnight or two.
If you **do** spend 6-20 hours per day in front of ANY editor, that
editor will become either the "best" editor in existance OR the worst
piece of dreck in computerdom (from **your** perspective). Doing the
same thing over and over and over tends to develop "muscle memory" so
that your body does things automatically without requiring
conscious thought. At that point, any argument about how intuitive or
not some particular operation is moot since the muscles in the wrists
and fingers have long since overridden the brain. (Case in point: MS
Word is pretty clearly a lot more "intuitive" than Word Perfect 4.2 for
DOS but a lot of the secretaries and clerks around here took an
inordinately long time to migrate since they had to retrain their
fingers to not be hitting various "F-key" combinations to peform
relatively simple tasks).
6) If your boss dictates use of a given tool in the name of
"commonality" or if neither you nor your company is willing to spend
whatever it takes to get/install/maintain your editor-of-choice (and,
yes, even "free" editors have a cost in terms of time spent installing,
customizing or upgrading, disk space etc.) then all other considerations
do not apply. You use what you are permitted to use - sooner or later
you'll no longer care since you will either have become used to it or
will have quit and found another job.
Specifically addressing Perl: perl source is just plain old 7-bit
USASCII text. Thus **ANY** editor that can enter and edit plain old
7-bit USASCII text can be used for Perl development. No special editor
is required, period. You could, in principle, even develop Perl programs
using punched cards (probably have to use an 029 punch since an 026
doesn't support the full character set) or paper tape on an ASR33 or -35
though you'd have to have one hell of a strange mental model to prefer
these methods :-)
So as the editor religious wars rage, just take whatever editor you like
to use (even a wordprocessor if you save in "DOS Text" mode) and go out
and develop something useful. In the end, that's the object of the
whole exercise.
For the record, I mostly use Emacs (GNU on Unix, JED and NotGNU on PCs),
plain-vanilla vi on Unix systems, Notepad on Windows and whatever is
built into the "integrated development environment" I'm using at the
moment. I have used 026 and 029 keypunches, ASR33 teletypes, ed, edlin,
ex, Wordstar, brief, WordPerfect, MS Word and even a purely home-grown
"full screen editor" at various times in my career. Got my work done
with all of them - you can too!
--
Bill Meahan wmeahan@ford.com
Ford Motor Company -- End User Support - North America
Not an official statement of Ford Motor Company or anyone else
except the author and he's crazy as a loon.
------------------------------
Date: 17 Apr 1997 16:39:34 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: has someone written a word counter (not a wc clone)
Message-Id: <5j5jo6$gdl$1@news.netusa.net>
I figure I could put to good use a program/procedure that would tell me
the X most frequently used words in a file and the number of appearances
of each. Has someone written such a thing? (Preferably with lots of
nice features like exclusion lists and sanity checks on words so the
odd uuencoded file will produce an error message not garbage counts.)
Or do I have to get my hands dirty and code myself? :^)
Elijah
------
dislikes actually starting projects
------------------------------
Date: Thu, 17 Apr 1997 10:39:50 -0700
From: Sysop <sysop@gbfcu.reno.nv.us>
Subject: Help with Math::BigFloat si vous plait
Message-Id: <33566066.47B6@gbfcu.reno.nv.us>
Hi folks,
First time using Perl modules here and (surprise) I'm running into some
problems. Essentially I'm trying to get numeric output with two
decimal places (money format). Here's the snippet of code in question:
use Math::BigFloat;
$bignumber=Math::BigFloat->new($item_price*$item_qty);
$subtotal_main = $subtotal_tmp->ffround(2);
When I check it with perl -cw I get this ugly message:
"use" may clash with future reserved word at order.cgi line 48.
syntax error in file order.cgi at line 48, next 2 tokens "use Math"
syntax error in file order.cgi at line 51, next 2 tokens "Math:"
syntax error in file order.cgi at line 52, next 2 tokens "->"
If anyone could send a hint/solution/??? to help me out I'd really
appreciate it! Thanks for your time!
.ben.
ben@seepeeyew.reno.nv.us
ben@scs.unr.edu
ben@gbfcu.reno.nv.us
------------------------------
Date: Thu, 17 Apr 1997 12:56:58 -0400
From: Deepak Thadani <deepak@pcsltd.com>
Subject: Help..Perl Script For Byte Counter
Message-Id: <3356565A.77F@pcsltd.com>
Hello,
I was wondering if anyone knew of a cool way to display a
number in the same location of the screen using a perl script?
For example, I want to take the sizes of all files I parse
and add them to a grand total byte count. I then want to take
the byte count and have it display in the same location on the screen,
updating the value as it changes.
Eventually, we want to attach a serial device to our UNIX
machine, which will have like a counter which we can place high in
the office..which will display this count at all times...
Anyone know what I should do or should try not to do?
Thanks for any help. Please send email or simply post to the group.
PS: we're using Perl 4.035 right now.
Deepak <deepak@pcsltd.com>
------------------------------
Date: Thu, 17 Apr 1997 12:19:15 +0100
From: Chris King <Chris.King@swindon-fc.demon.co.uk.mars>
Subject: Re: HELP: Redirection with Perl...
Message-Id: <QNFqrUAzcgVzEwe8@swindon-fc.demon.co.uk>
In article <5j4e88$9v3@usenet85.supernews.com>, No Mass Spam E-Mail!
<zippidy@do.dah.com> writes
>Not quite newbie..
>
>I did it once before, and since have lost my drive, and all my
>development CGI's!
>
>I want to call a url and have the browser load it from Perl.
?
Sounds suspiciously more like a CGI question not a Perl one. Try
comp.infosystems.www.authoring.cgi
>Also, Iam haveing some trouble with printing " chars.
>
>I tried:
>
>print "<META HTTP-EQUIV="REFRESH
>CONTENT="URL=http://www.digispec.com/loadthis.htm">";
How about:
print "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"URL=http://www.digispec.co
m/loadthis.htm\">";
>This does not work. It will work on an HTML page with
>the " replaced with the actual ' " '.
A. because you told it to. Incicentally and totally off-topic to this
group, it should be " or " - the semicolon is vitally
important. Doesn't work in a tag though.
The " is replaced by a " by the browser, not perl, and that's why it
looks like that.
--
Chris King
The similarity of any fact mentioned within this post and
any in reality, living or dead, is purely coincidental.
Remove 'mars' from address when replying. I hate spam.
I like corned beef though.
------------------------------
Date: 16 Apr 1997 12:11:40 -0600
From: Nathan Torkington <gnat@elara.frii.com>
Subject: Re: How do I randomly re-order the lines of a file?
Message-Id: <5qybai3kir.fsf@elara.frii.com>
adam@orion.math.uiuc.edu (Adam H. Lewenberg) writes:
> I need to RANDOMLY re-order the lines of a small text file (between 20
> and 50 lines). Preferably, I would like to say something like 'reorder
> file' and get the re-ordered file sent to standard output. A perl
> solution would be good, but I could also use awk, sed, or any of the
> other standard UNIX tools.
Process:
read it into an array, one element per line.
shuffle that array
write the sucker back out.
@lines = <FILE> will do the first step.
http://www.perl.org/CPAN/doc/manual/html/pod/perlfaq4/How_do_I_shufle_an_aray_random.html has the second step.
You should be able to take care of the third step.
Nat
------------------------------
Date: Thu, 17 Apr 1997 12:20:03 -0700
From: "Dipti V. Sonak" <dsonak@us.oracle.com>
Subject: How to direct screen output to a file ?
Message-Id: <335677E3.22BC@us.oracle.com>
Hi,
I want to re-direct the output[ all of it ] produced by a command to a
file. This is what I did :
system("make demo >& $outputFile );
The $outputFile [ /tmp/outputFile ] is an empty file [ length 0 ].
This is giving me an error :
sh : /tmp/outputFile : bad number
This syntax works from the command line.
What am I doing wrong ?
If I use : system( "make demo >> $outputFile ); all the make messages go
to this file - but the error messages produced by make are still
displayed on the screen. I am more intersted in the error messages.
Thanks,
Dipti Sonak
------------------------------
Date: 16 Apr 1997 12:12:47 -0600
From: Nathan Torkington <gnat@elara.frii.com>
Subject: Re: how to get perl handle elm's receive automatically
Message-Id: <5qwwq23kgw.fsf@elara.frii.com>
Maverick <lufan@hotmail.com> writes:
> I want to write a perl script to auto-detect
> elm's new arrival and parse it into several files
Consider just using procmail.
Nat
------------------------------
Date: 17 Apr 1997 13:43:28 -0500
From: mahr@ibmoto.com (Ed Mahr)
Subject: How to track memory usage
Message-Id: <5j5r0g$rb7@hortense.ibmoto.com>
Does anyone know of a way to track the amount of memory a Perl script is
using at various points during the scripts execution?
On a related note, is there a good method or utility for tracking memory
leaks in Perl?
Thanks.
- Ed Mahr
------------------------------
Date: 16 Apr 1997 12:15:39 -0600
From: Nathan Torkington <gnat@elara.frii.com>
Subject: Re: how to use a system-installed Perl w/locally downloaded modules
Message-Id: <5qvi5m3kc4.fsf@elara.frii.com>
friedman@medusa.acs.uci.edu (Eric D. Friedman) writes:
> >I am not superuser, yet I wish to use the system-installed Perl with
> >modules I get from CPAN and store in my lcal directory? Is there some
> >way to set this up?
> >This would be a good FAQ.
> Agreed, I propose the following:
You mean, like:
http://www.perl.org/CPAN/doc/manual/html/pod/perlfaq8/How_do_I_instal_a_CPAN_module_.html
and
http://www.perl.org/CPAN/doc/manual/html/pod/perlfaq8/How_do_I_kep_my_own_module_libr.html
?
Nat
------------------------------
Date: Thu, 17 Apr 1997 13:24:19 -0500
From: Eryq <eryq@enteract.com>
To: Henrik Soderstrom <emehenk@rioja.ericsson.se_nojunk_>
Subject: Re: HTML Parser anywhere ?
Message-Id: <33566AD3.56C59EA0@enteract.com>
Yes. HTML::Parser, as mentioned in:
ftp://ftp.cis.ufl.edu/pub/perl/CPAN/modules/00modlist.long.html
HTH,
--
___ _ _ _ _ ___ _ Eryq (eryq@enteract.com)
/ _ \| '_| | | |/ _ ' / Hughes STX, NASA/Goddard Space Flight Cntr.
| __/| | | |_| | |_| | http://www.enteract.com/~eryq
\___||_| \__, |\__, |___/\ Visit STREETWISE, Chicago's newspaper by/
|___/ |______/ of the homeless: http://www.streetwise.org
------------------------------
Date: 17 Apr 1997 18:32:20 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: HTML Parser anywhere ?
Message-Id: <5j5qbk$a6e@news-central.tiac.net>
In article <5j5gvk$d4h@newstoo.ericsson.se>,
Henrik Soderstrom <emehenk@rioja.ericsson.se_nojunk_> wrote:
>
>Hi, I want to write something to parse an html-tree, fix
>relative references after moving subtrees around, change
>absolute references to relative and little things like that.
>
>Just thought I'd check if there's any HTML-parsing code available
>out there, that I could base it on before I start reinventing
>the wheel here.
I have an HTML::Parser module installed on my system:
NAME
HTML::Parser - SGML parser class
SYNOPSIS
require HTML::Parser;
$p = HTML::Parser->new; # should really a be subclass
$p->parse($chunk1);
$p->parse($chunk2);
#...
$p->eof; # signal end of document
# Parse directly from file
$p->parse_file("foo.html");
[...etc...]
it's a part of the libwww package, the current version is libwww-perl-5.08
and it can be found on CPAN in the modules tree. CPAN is the
comprehensive perl archive network and a couple of ways of getting to it
are:
http://www.perl.com/CPAN/
ftp to ftp.funet.fi and look in /pub/languages/perl/CPAN/
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Thu, 17 Apr 1997 19:13:35 +0200
From: Zaheed Haque <zaheed.haque@ein.ericsson.se>
Subject: Last Update!
Message-Id: <33565A3F.53FF@ein.ericsson.se>
Hey,
I apologize for this stupid questions.. But please help!
Does anyone aware of any script that can go to an
external website and check for the last update date on
specific HTML pages and prints out the output.. for example
1. Check the following URL http://a.com/b/c.html
2. If the todays date is same as the document update date then print
something to a file ...
Hopefully you all will share your experince and or tell us
what way we can solve this problem ..
Best Regds
Zaheed
------------------------------
Date: 17 Apr 1997 14:54:36 -0400
From: rdd@access2.digex.net (R. D. Davis)
Subject: Leap-year date routine needed
Message-Id: <5j5rlc$gv9@access2.digex.net>
Does anyone know where I can find a Perl script which can be used to
determine which years are leap-years? I need to write a script which
determines if the present day is the last day of the month; hence, the
script would be much more accurate with leap-years taken into
consideration.
--
R. D. Davis http://www.access.digex.net/~rdd
rdd@digex.net, rdd@mystica.uucp Computer preservationist. Many types of
unwanted older computer systems disassembled,
Office telephone: 1-410-744-4900 removed for free (locally) and preserved.
------------------------------
Date: Thu, 17 Apr 1997 12:58:56 -0500
From: Jason Cole <cole@io-design.com>
Subject: Re: New Microsoft Perl Product (fwd)
Message-Id: <335664E0.BD486D0F@io-design.com>
My code reads
$arg = '-n'; #unless (&is_already( $arg, '-n' ) || !$FLAG_power_on);
...although it's clearly incomplete; it really should confirm that
it's actually executing at the moment. I was in a hurry, I got sloppy.
The tests are commented out right now because there's an intermittent
bug I can't quite nail down. Probably in &is_already.
So far, the truncated version works fine, and I just try to ignore my
creeping dread about skating without a safety net.
Russ Allbery wrote:
> Since we're discussing issues of style....
>
> Matthew Cravit <mcravit@best.com> writes:
> > I would probably write it as:
> > $arg = "-n" unless ($arg eq "-n");
>
> Generally, though, the assignment isn't the common case. The ideal in my
> mind is to put what the statement *normally* does first. So I'd write it
> as:
>
> unless ($arg eq '-n') { $arg = '-n' }
>
> (unless, of course, the assignment is the common case, in which case I'd
> use your phrasing.)
> --
> Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
Jason Cole (cole@cephalopod.com)
------------------------------
Date: Thu, 17 Apr 1997 14:22:20 -0700
From: Frank Rizulo <rizulof@newschool.edu>
Subject: newbie install problem
Message-Id: <3356948C.7608@newschool.edu>
I'm trying to install Perl 5 on a Solaris 2.5.1. Configure runs with no
problem, but when I run "make", it finishes with the error:
"Fatal error: command failed for target libperl.a"
In the config.sh file there are references to a "perl5" directory -- I
assume that should get created -- but it's not there. Thanks for any
help.
Frank Rizulo
rizulof@newschool.edu
------------------------------
Date: Thu, 17 Apr 1997 12:29:12 +0100
From: Chris King <Chris.King@swindon-fc.demon.co.uk.mars>
Subject: Re: Palindromic words search???
Message-Id: <p9bkHbAImgVzEwam@swindon-fc.demon.co.uk>
In article <3355E6BC.41C6@mrc-lmb.cam.ac.uk>, Jong <jong@mrc-
lmb.cam.ac.uk> writes
>Hi,
>
>I am trying to make a program which detects all the palindromic(perfect
>or imperfect palindromes) sequences in any long string.
This seems to work - you'll probably have to modify it for your needs
though:
--8<--8<--8<--
#!/bin/perl
# Check a palindrome to see if it's a palindrome. Palindrome isn't a
palindrome.
print "Enter your suspected palindrome:\n>";
$word=<STDIN>;
chop $word;
$reversedword=join("",reverse(split("",$word)));
print "Reversed word is $reversedword\n";
if ($word eq $reversedword) {
print "Yup, it's a hit.\n";
}
else {
print "Nope. Miss. Battleship sunk.";
}
--8<--8<--8<--
--
Chris King
The similarity of any fact mentioned within this post and
any in reality, living or dead, is purely coincidental.
Remove 'mars' from address when replying. I hate spam.
I like corned beef though.
------------------------------
Date: Thu, 17 Apr 1997 13:37:55 -0500
From: Eryq <eryq@enteract.com>
To: "feedme.org/anti-spam.html" <nozaki@feedME>
Subject: Re: PERL 4.036 for Solaris 2.5
Message-Id: <33566E03.19358DE8@enteract.com>
feedme.org/anti-spam.html wrote:
>
> Hi! Where can I find a binary version of PERL 4 .036 for SUN Solaris 2 .5?
> Thanks!
4.036? Geez, that's ancient history. Why not just install Perl5?
It should be able to run any 4.036 script with minimal (if any)
tweaking of the script.
HTH,
--
___ _ _ _ _ ___ _ Eryq (eryq@enteract.com)
/ _ \| '_| | | |/ _ ' / Hughes STX, NASA/Goddard Space Flight Cntr.
| __/| | | |_| | |_| | http://www.enteract.com/~eryq
\___||_| \__, |\__, |___/\ Visit STREETWISE, Chicago's newspaper by/
|___/ |______/ of the homeless: http://www.streetwise.org
------------------------------
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 325
*************************************