[6936] in Perl-Users-Digest
Perl-Users Digest, Issue: 561 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 3 00:07:24 1997
Date: Mon, 2 Jun 97 21: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 Mon, 2 Jun 1997 Volume: 8 Number: 561
Today's topics:
Re: 2-way communication with unix command <rra@stanford.edu>
Re: Bored? Want to evaluate my first (usefull) perl sc <zenin@best.com>
Re: Bored? Want to evaluate my first (usefull) perl sc <zenin@best.com>
Collect all Function Names in a C file <senthil@ece.vill.edu>
Re: data structure question (Tad McClellan)
Re: example perl v. caml performance (Seth LaForge)
Re: Going from Perl to C <rootbeer@teleport.com>
Re: Isdigit(), isalpha() in Perl (Kerry Schwab)
Re: Isdigit(), isalpha() in Perl (Greg Bacon)
Re: Isdigit(), isalpha() in Perl <rootbeer@teleport.com>
Re: newbie question about the sort function and hashes (Tad McClellan)
Re: nth root function? <stuartc@ind.tansu.com.au>
Out of memory with big hashes (Phil Glatz)
performance question for sorting text from a large file (Shane 'Fishman' Sherman)
Re: performance question for sorting text from a large (Tad McClellan)
PERL with Windows NT <ssamat@ucsd.edu>
Re: print keys %something how do I sepearte each key? <rra@stanford.edu>
Re: print keys %something how do I sepearte each key? <fnord@panix.com>
Re: print keys %something how do I sepearte each key? <rootbeer@teleport.com>
Re: Printing Arrays to a file <byron@thrush.omix.com>
Re: Process Information <rootbeer@teleport.com>
Re: Read a file to $wholefile <zenin@best.com>
Reading Comma delimited, Quoted String records <mckee@misslink.net>
Re: Tutorial Needed (wrong URL ?) dominic@thiru.vetri.com
Re: Working with multiple files (simultaneously). (Greg Bacon)
Re: Working with multiple files (simultaneously). <rootbeer@teleport.com>
working with Perl and Multiplicity (Doug Young)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 02 Jun 1997 16:51:30 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: 2-way communication with unix command
Message-Id: <m3pvu4pnr1.fsf@windlord.Stanford.EDU>
Michael J Assels <mjassels@cs.concordia.ca> writes:
[referring to my sig]
> Very nice, but you have far too many alphanumerics :-)
Ah, but it runs under -w with either Perl 4 or Perl 5, passes taint and
use strict, and works correctly with Mac, DOS, or Unix line end
convention. That's got to be worth something. :)
(Although I should rework it so that there isn't a line starting with a
space. That's asking for mangling in transit.)
--
#!/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: 2 Jun 1997 20:01:13 GMT
From: Zenin <zenin@best.com>
Subject: Re: Bored? Want to evaluate my first (usefull) perl script?
Message-Id: <5mv8q9$srq$1@nntp2.ba.best.com>
Russ Allbery <rra@stanford.edu> wrote:
>snip<
> BTW, how much of a speed penalty do -w and use strict cause?
use Benchmark;
:-)
--
-Zenin
zenin@best.com
------------------------------
Date: 2 Jun 1997 22:03:26 GMT
From: Zenin <zenin@best.com>
Subject: Re: Bored? Want to evaluate my first (usefull) perl script?
Message-Id: <5mvfve$412$1@nntp2.ba.best.com>
Mark Bainter <mark@michiana.net> wrote:
> I am however interested in any feedback you (as a group)
> might feel like giving me.
>snip<
Hehe, you asked for it. :)
> #!/usr/local/bin/perl5 -T #w removed for release
> #
> # dialup -r <username> Remove User from alias
> # dialup -a <username> Add user to alias
> # dialup -v View Alias Listing
> # dialup -c <username> Check if a username exists
> # Version 1.5
> # Created 5/28/97 by Mark Bainter
> # for Turner Group, IN
> #
> # Requires: Perl5, File, and Getopt modules.
> #
> # Planned Improvements:
> # Enable processing list of names, on cmdline or from file.
> # Remove the capability of using RegExps with the -r option.
I'd suggest a quick read of the perlpod manpage, and a quick
look at some of the modules that come with perl for examples of
it's use. It makes mantaining documentation *much* easyer. It
also removes the need for commented docs such as the above.
> #use strict; # Used for debugging.
I'd leave this in myself.
> use File::Copy; # Used to make a backup.
> use Getopt::Std;
> use vars qw($opt_r $opt_a $opt_h $opt_v $opt_c @alias @time $mod $tmp $rm
> $login $ALIASFILE $NEWFILE);
Hmm, interesting way of naming and opening files. Makes the code
harder to read. I'd suggest setting these (ALIASFILE, NEWFILE) at the
top of your script and remove the hard coded magic strings latter in
your code, and only use the two argument form of open().
> getopts('r:a:hvc:');
> unless ( ($opt_h) || ($opt_r) || ($opt_a) ||
> ($opt_v) || ($opt_c) )
> {
> $opt_h = 1;
> }
Overkill on the parens. It's a little cleaner (IMHO) to do something
such as:
$Help = $opt_h || 0;
$Help = 1 unless ($opt_r || $opt_a || $opt_v || $opt_c);
> if ($opt_r ne "")
> {
> &Fill_Array;
> &Parse_Array($opt_r,1);
> &Write_Array;
> }
I'd recomend using the non-& calling of subs. This would meen they
would also need to be defined first, or listed in a
use subs qw(Fill_Array Etc);
statement, however it would allow perl to spell check them for you
when running under strict. -It won't compile if you spelled a sub
call wrong such that it didn't exist. What this meens is that you
could find such a bug now, instead of when that line of code gets
called. And depending on where that line is, you may not see the
bug for months because the condtion never came up.
> if ($opt_a ne "")
Assigning your opt_* values to more readable vars would help your
code be easier to read. It doesn't matter on something this size
really, but it will on anything much larger:
$AddUser = $opt_a || 0;
> $ALIASFILE = "/usr/lib/mail/dialup.list";
> open(ALIASFILE) or die "Cannot open data";
> while ( $tmp = <ALIASFILE> )
> {
> chop($alias[scalar(@alias)]=$tmp);
> }
> close ALIASFILE;
> }
Not a really recommended way to open files. I'd recommend setting
$ALIASFILE (and $NEWFILE) at the top of your script (you did assign
them globles anyway), and using the two arg form of open(). Also,
the use of $! helps alot too:
open (ALIASFILE, $ALIASFILE) or die "Cannot open data: $!, stopped";
This will turn into a message something like:
"Cannot open data: File not found, stopped at foo.pl line 42"
> while ( $tmp = <ALIASFILE> )
> {
> chop($alias[scalar(@alias)]=$tmp);
> }
> close ALIASFILE;
> }
Funky (and slower) way to push an element into an array. Also, if
you are trying to remove the newline from $tmp, chomp() would be
safer. Maybe like:
while ($tmp = <ALIASFILE>) {
chomp $tmp;
push @alias, $tmp;
}
> sub Display_Array
> {
> foreach (@alias)
> {
> print "$_\n";
> }
> }
The join() function is what you need here:
print join ("\n", @alias), "\n";
Or set $" to "\n", but I don't recommend that.
> sub Parse_Array
> {
> my($rmalias,$rm) = @_;
> my(@newlist) = ();
> if ($rm)
> {
> foreach(@alias)
> {
> if($_ !~ /^$rmalias$/)
Regexps in perl all default to matching $_. -Many functions in perl
default to $_ actually.
unless (/^$rmalias$/) {
> {
> $newlist[scalar(@newlist)] = $_;
See "perldoc -f push" here too.
> #Make a backup copy of the file first!
> $login = getlogin;
> copy("/usr/acct/mark/smw/dialup.list","/usr/acct/mark/smw/dialup.${login}");
Stay away from magic numbers and strings. These really should be
made globles at the top of your script, and maybe even overridable
with option flags.
> select NEWFILE;
>snip<
> print $_,"\n";
How about:
print NEWFILE "$_\n";
or:
print NEWFILE join ("\n", @alias), "\n";
> select STDOUT;
> close STDOUT;
Why do you select STDOUT, then close it? Or did you meen to select
STDOUT and close NEWFILE?
--
-Zenin
zenin@best.com
------------------------------
Date: Mon, 2 Jun 1997 21:16:15 -0400
From: Senthilvel Rangaswamy <senthil@ece.vill.edu>
Subject: Collect all Function Names in a C file
Message-Id: <Pine.SV4.3.95.970602211452.17977B-100000@vu-vlsi.ee.vill.edu>
Hi All:
I am looking for a perl script which will read in a standard C file and
output all the function names used in that C file. Does anybody have
any ideas or pointers...
Thanks,
..Senthil
"Out the 10Base-T, through the router, down the T1, over the leased line,
off the bridge, past the firewall.... nothing but Net."
- Todd Postma
------------------------------
Date: Mon, 2 Jun 1997 07:06:47 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: data structure question
Message-Id: <n0dum5.h81.ln@localhost>
Jon Nathan (jn0729a@cage.cas.american.edu) wrote:
: hello
: i'm trying to write a script that will be a simple quote server. it will read
: in a quote and the source of the quote from a textfile formatted as such:
: 1.Take me out to the ballgame.
: 1.Some song
: 2.Whatever
: 2.Joe Smith
: etc. the format for the file is not written in stone, however it seemed good to
: me at the time. once it reads in all the quotes from the file, it should print
: one out at random, along with the source. because i would eventually like to
: play with the source too, i want to keep it in a seperate variable. that said,
: this is my (ugly) code so far:
: -----start code-------
: open(QUOTES, "//usr//people//nathanj//quotes");
^^ ^^ ^^ ^^
Why the consecutive forward slashes?
Check the return value to ensure that the call to open() actually
opened the filehandle:
open(QUOTES, "//usr//people//nathanj//quotes") || die "could not open file $!";
: while ($quote=<QUOTES>){
: chop($quote); #get a line from the file
chomp($quote);
: $num=/$(\d+\.)/; #digit(s) followed by a period
^
$num is never used again...
$_ (the string you are matching against) has no string in it...
What is that '$' for?
: $quote=~s/\1//; #take the digit(s) and period out
$quote=~s///; #take the digit(s) and period out
: chop($source); #get the next line from the file
chomp($source);
: $source=~s/\$1//; #take the digit(s) and perious out
And what do you expect $1 to contain?
: @\$1=($quote,$source); #set up array named (the number of the quote)
???
: %fullquote={ #set up hash with key of (the number of the quote)
: #and value of (the array containing the quote
: # and source)
: $1 => \@\$1,
: }
:
: }
: #now pick a random key from the @fullquote array
: #and print out the quote associated with that number
: #later i'll deal with the source of the quote
: #put all the keys into another array
: @possibilities = keys (@fullquote);
: #now choose a random one from @possibilities
: #hmm don't quite know how here
hmm. Do a word search for 'random' in the Perl FAQ here
: ---end of code----
: i realise that this is very ugly and wrong in places but would appreciate any
: ideas to simplifly/beautify/make it work. if you can, please cc your reply to my
: email.
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 3 Jun 1997 00:57:27 GMT
From: sethml@ugcs.caltech.edu (Seth LaForge)
Subject: Re: example perl v. caml performance
Message-Id: <slrn5p6qvo.4f4.sethml@claustro.ugcs.caltech.edu>
On 2 Jun 1997 12:59:30 +0100, Tony Bass <aeb@brains.cartoon.bt.co.uk> wrote:
[ ... example of problem whose solution turned out neater, faster, and more
memory-efficient in caml-light than in perl ... ]
I suggest that you try ocaml, also from Inria:
http://pauillac.inria.fr:80/ocaml/
The ocaml lanuage is a superset of caml-light, and the compiler is
based on the caml-light compiler. However, the byte-code compiler and
interpreter are quite a bit more efficient, and it also has a
native-code compiler for a number of platforms. Programs compiled
with the native compiler are often an order of magnitude faster than
the interpreted versions. If you recompile your code with ocaml, I
suspect you'll be pleasantly surprised...
Seth
------------------------------
Date: Mon, 2 Jun 1997 17:23:34 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Prince Mystery <mystery@itis.com>
Subject: Re: Going from Perl to C
Message-Id: <Pine.GSO.3.96.970602172207.20342A-100000@kelly.teleport.com>
On Mon, 2 Jun 1997, Prince Mystery wrote:
> I've got a minor perl routine that does a lot of regexp'ing, and a lot
> of file input/output. I would like to recreate this in C, and then
> compile it, hopefully speeding up the process.
I doubt that this would speed it much. Perl regexps are pretty fast
already, and I/O is slowed by the speed of devices, not the speed of the
language.
> However, due to the fact that I'm much better at perl than I am at C,
> I'm more inclined to try out some sort of converter before recoding it
> from the ground up. Is there such a beast?
There's something about this in the FAQ. :-)
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 2 Jun 1997 18:02:46 -0600
From: kschwab@nyx10.cs.du.edu (Kerry Schwab)
Subject: Re: Isdigit(), isalpha() in Perl
Message-Id: <5mvmv6$ali@nyx10.cs.du.edu>
Bah. old bad habits die hard.... (errant | in earlier regexp)
Here's what I should have said:
I usually do this sort of thing with regexps. If you really want
the functions...
sub isdigit {
my($string)=shift;
$string=~/^\d+$/;
}
sub isalpha {
my($string)=shift;
$string=~/^[a-zA-Z]+$/;
}
In article <5mvhmf$4n2@nyx10.cs.du.edu>,
Kerry Schwab <kschwab@nyx10.cs.du.edu> wrote:
>In article <3392F06A.32B8@aracnet.net>, <ddean@aracnet.net> wrote:
>>Is there a function similar to the C functions isdigit or alpha in Perl
>>
>>Thanks
>>Dean
>
>I usually do this sort of thing with regexps. If you really want
>the functions....
>
>
>sub isdigit {
> my($string)=shift;
> $string=~/^\d+$/;
>}
>sub isalpha {
> my($string)=shift;
> $string=~/^[a-z|A-Z]+$/;
>}
>
>
>--
>Kerry
------------------------------
Date: 3 Jun 1997 01:58:19 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
To: kschwab@nyx10.cs.du.edu (Kerry Schwab)
Subject: Re: Isdigit(), isalpha() in Perl
Message-Id: <5mvtnr$n12$2@info.uah.edu>
[Posted and mailed]
In article <5mvmv6$ali@nyx10.cs.du.edu>,
kschwab@nyx10.cs.du.edu (Kerry Schwab) writes:
: sub isalpha {
: my($string)=shift;
: $string=~/^[a-zA-Z]+$/;
: }
That's not necessarily completely correct, depending on locale. Let your
libc decide what is alphabetic like this:
sub isalpha {
my $str = shift;
$str =~ /^[^\W\d_]+$/;
}
Hope this helps,
Greg
--
Greg Bacon <gbacon@cs.uah.edu>
Unix / Perl Consultant
Perl Institute Partner - http://www.perl.org/
------------------------------
Date: Mon, 2 Jun 1997 19:52:17 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: ddean@aracnet.net
Subject: Re: Isdigit(), isalpha() in Perl
Message-Id: <Pine.GSO.3.96.970602194842.20342N-100000@kelly.teleport.com>
On Mon, 2 Jun 1997 ddean@aracnet.net wrote:
> Is there a function similar to the C functions isdigit or alpha in Perl
Not as a builtin. But you can easily check whether a letter falls within a
certain character set. This is often done with regular expressions,
although it's more efficient to use tr/// if it can do the job. See
perlop(1) for details. (If you want to do these things in a locale
dependant manner, see perllocale(1) in Perl version 5.004.)
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Mon, 2 Jun 1997 06:22:23 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: newbie question about the sort function and hashes
Message-Id: <fdaum5.141.ln@localhost>
Shane 'Fishman' Sherman (fishman@vvm.com) wrote:
: What i am trying to do is sort a hash by the keys but then print the
: whole hash sorted and not just the keys...here is my code:
: print"How many lakes: ";
: $numlakes=<STDIN>;
: for($i=0;$i<$numlakes;$i+=1){
: print "Name of lake: ";
: $name=<STDIN>;
: chomp($name);
: $name=$name." - ";
: print "\ndescription? ";
: $info=<STDIN>;
: $lakeinfo{$name}.=$info . " ";
: }
: @sort = sort %lakeinfo;
: print @sort;
foreach (sort keys %lakeinfo) {
print "lake: $_ info: $lakeinfo{$_}";
}
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 03 Jun 1997 12:04:27 +1000
From: Stuart Cooper <stuartc@ind.tansu.com.au>
Subject: Re: nth root function?
Message-Id: <yeovi3we91w.fsf@parakeet.ind.tansu.com.au>
liamtu@echonyc.com writes:
> is there a secret nth root function in perl? has anyone written one?
>
> Any advice?... C?
>
> -Liam
>
There's a very public nth root function; the ** (general exponentiation)
operator. 2 cubed is 2**3 and cube root of 2 is 2 ** (1/3).
The nth root of a is
a**(1/n)
or; if you like to get logs and e into everything;
exp(log(a)/n)
Hope this helps.
Stuart Cooper.
stuartc@ind.tansu.com.au
------------------------------
Date: Tue, 03 Jun 1997 01:08:17 GMT
From: phil@glatz.com (Phil Glatz)
Subject: Out of memory with big hashes
Message-Id: <33936d78.40456073@news.ricochet.net>
I have an analysis perl (5.003) program that puts stuff into a big
hash array - I eventually get an out of memory fatal exception. I'm
running an HP 9000 with 192 megs, HPUX 10.20.
Looking for hints on memory efficiency, I tries using the
Tie::SubstrHash module to create a tighter table. But wow, things
seem to slow to a crawl! Am I on the right track re memory reduction?
Does this module normally slow things down?
------------------------------------------
Phil Glatz (phil@glatz.com)
Software Engineer Lake Tahoe, Nevada
WWW: http://www.glatz.com
------------------------------
Date: Tue, 03 Jun 1997 00:50:03 GMT
From: fishman@vvm.com (Shane 'Fishman' Sherman)
Subject: performance question for sorting text from a large file
Message-Id: <3393691c.8670514@news.tamu.edu>
I was wondering if performance becomes a serious factor when reading
and sorting a large file of words. like maybe 1000 words or less. Does
speed become a huge factor?
the script would read the words from a txt file and sort them and
output them into an html file. thanks go to anyone who can help me
out.
---Shane 'Fishman' Sherman
---fishman@vvm.com
---Fishman's Bass Fishing World(http://www.vvm.com/~fishman)
------------------------------
Date: Mon, 2 Jun 1997 22:04:42 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: performance question for sorting text from a large file
Message-Id: <ak10n5.3ph.ln@localhost>
Shane 'Fishman' Sherman (fishman@vvm.com) wrote:
: I was wondering if performance becomes a serious factor when reading
: and sorting a large file of words.
It most definitely is a factor with large files.
: like maybe 1000 words or less.
But I wouldn't call that large (but I wouldn't call 10,000 large either.
Probably wouldn't even honor 100,000 with "large" ;-).
: Does
: speed become a huge factor?
So, I'd say don't worry about it.
: the script would read the words from a txt file and sort them and
: output them into an html file.
If they don't change often, why not sort them in "batch", so the
accessing program doesn't need to sort them?
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Mon, 02 Jun 1997 20:19:54 -0700
From: Sameer Samat <ssamat@ucsd.edu>
Subject: PERL with Windows NT
Message-Id: <33938D58.1BEEE998@ucsd.edu>
This may be a naive question... I haven't worked with PERL much at all..
I have perl5 installed on my system (I run a web server under win nt),
and I was curious what steps I needed to take to get perl scripts to be
able to run from web pages hosted on my machine. do I just put the perl
dir in my path and then call programing in the cgi-bin dir as if I was
running on a unix machine?..anything special I need to do?
Thanks for the help
Sameer Samat
ssamat@ucsd.edu
------------------------------
Date: 02 Jun 1997 16:52:34 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: print keys %something how do I sepearte each key?
Message-Id: <m3n2p8pnp9.fsf@windlord.Stanford.EDU>
Dimitiris Vayenas <User_id@webads.gr> writes:
> I wonder if anyone has found a way of getting - out of the print keys
> %something (or print values %something) each key separated by a user
> defined delimiter?
You mean like this?
print join ('|', keys %something);
--
#!/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: 2 Jun 1997 21:07:54 -0400
From: Cliff Heller <fnord@panix.com>
Subject: Re: print keys %something how do I sepearte each key?
Message-Id: <upsoz0pk7q.fsf@panix.com>
"Dimitiris Vayenas" <User_id@webads.gr> writes:
> I wonder if anyone has found a way of getting - out of the print keys
> %something (or print values %something) each key separated by a user
> defined delimiter?
keys %hash and values %hash
return an array context. If you want to delimit them, try join.
print join(":", keys %hash);
--
/ \ Left Reverend Nigh Invulnerable fnord@panix.com
/<0>\ Church of the Subverted Paradigm
/ \ God Plays Dice!
/_______\ --> FIVE TONS OF FLAX <-- Death To All Fanatics!
------------------------------
Date: Mon, 2 Jun 1997 19:48:09 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Dimitiris Vayenas <User_id@webads.gr>
Subject: Re: print keys %something how do I sepearte each key?
Message-Id: <Pine.GSO.3.96.970602194559.20342M-100000@kelly.teleport.com>
On 2 Jun 1997, Dimitiris Vayenas wrote:
> I wonder if anyone has found a way of getting - out of the print keys
> %something (or print values %something) each key separated by a user
> defined delimiter?
Sure, and TMTOWTDI.
print join ", ", keys %hash;
print map "'$_'\n", keys %hash;
{ local($")=':'; print "@{[ keys %hash ]}"; } # :-)
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 2 Jun 1997 22:35:31 GMT
From: Byron Brummer <byron@thrush.omix.com>
Subject: Re: Printing Arrays to a file
Message-Id: <5mvhrj$412$3@nntp2.ba.best.com>
Tad McClellan <tadmc@flash.net> wrote:
>snip<
> OR (better)
> foreach (@altsorted){
> print "$_\n";
> }
OR
print join ("\n", @altsorted), "\n";
IMHO, setting $" (and most of it's friends) is silly and
just causes problems latter.
--
-Byron
byron@omix.com
------------------------------
Date: Mon, 2 Jun 1997 17:32:08 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Brent Johnson <brent@AAC.MsState.Edu>
Subject: Re: Process Information
Message-Id: <Pine.GSO.3.96.970602172935.20342C-100000@kelly.teleport.com>
On 27 May 1997, Brent Johnson wrote:
> Is there a module or some Perl code available which can access
> process information for Unix machines? Piping the 'ps' command
> tends to be a little slow at times and differs from machine to
> machine.
There were some people on the perl-porters list talking about it a while
back, but I don't think anything came of it. The idea was to use Linux's
/proc information or anything else if it was available, and to parse the
output of ps as a fallback.
If nobody else wants to write one, you could start it. Make it open enough
that people can add to it to support different systems, of course. There
are other guidelines in the module list. Good luck!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 2 Jun 1997 22:12:10 GMT
From: Zenin <zenin@best.com>
Subject: Re: Read a file to $wholefile
Message-Id: <5mvgfq$412$2@nntp2.ba.best.com>
Lauri Laakso <lauri@nettipaja.clinet.fi> wrote:
> Ho I can read whole $message.dat file to $wholefile, I am using it
> when I send multiple emails.
open SESAME, $message_dat or die $!;
$wholefile = join '', <SESAME>;
close SESAME;
Don't ever undef $/ unless it can't be avoided. -Hint: There
is never a time that it can't be avoided. Setting it to something
else can be helpful, but don't undef it.
--
-Zenin
zenin@best.com
------------------------------
Date: 3 Jun 1997 02:02:23 GMT
From: "Sean M. McKee" <mckee@misslink.net>
Subject: Reading Comma delimited, Quoted String records
Message-Id: <01bc6fc2$4805a7c0$fc412b9f@seanhome>
Does anyone know of a way to read and parse comma delimited string quoted
records with awk or perl?
I know how to read a comma delimited file (awk -F:) but if a string field
contains a comma (eg. ...,"McKee, Sean",...) then the field is surrounded
in double quotes. Is there a way to deal with this?
Sean McKee
mckee@misslink.net
------------------------------
Date: Mon, 02 Jun 1997 22:51:49 -0600
From: dominic@thiru.vetri.com
Subject: Re: Tutorial Needed (wrong URL ?)
Message-Id: <865309632.31764@dejanews.com>
Andy Birkett wrote:
>
> Are there any good Perl tutorials on the net. If so could someone
> please point me in the right directions.
>
Hello
When I asked the same question to the Perl for Win32 User group I got the
following answers. I am forwarding the same.
===================
Date: Tue, 15 Apr 1997 18:38:35 -0400 (EDT)
From: Dominic Prakash <dominic@thiru.vetri.com>
Subject: Re: Any tutorial available?
> Is there any tutorial sort of a thing is available on the NET other than
> Evangelo's FAQ? i.e. I want a step by step learning of Perl starting
> from "Hello World!" to writing CGI scrips etc.
Hello Perlians,
For the above query I got lot of answers and I am giving all in a
single mail. I think this will be useful for all newbies like me.
Dominic
=============
On Fri, 11 Apr 1997 Bill Cowan <billc@tibinc.com> Wrote:
See http://www.perl.com/perl/index.html for Perl home page.
1. Try: Other Resources -->
Related Sites
Links to other sites related to perl.
==> [[One tutorial listed. Bill]]
2. Try: Perl Software --> Documentation Documentation in various
forms, including various faqs and the Perl FAQ. A book review section
called Camel Critiques has been added.
>From this point, you can spread out to a lot of other Perl resources. Also try Deja News search engine (http://www.dejanews.com/) for comp.lang.perl.* groups (.misc, .modules, .announce) for Perl.
=============
On Date: Fri, 11 Apr 1997 "Colin Durocher" <cdd2@gpu.srv.ualberta.ca>
wrote:
If you are looking for something that is free, a really good and
thorough step by step place to start is the web version of Perl 5 by
Example. It can be found at: http://www.mtolive.com/pbe/index.html
=============
On Date: Fri, 11 Apr 1997 "Eric BERNE" <BERNE@hardy.admin.entpe.fr> wrote:
Try this:
http://www.ncsa.uiuc.edu/General/Training/PerlIntro/
And this one i like the most (it's not a tutorial but USEFULL)
http://www.pcnet.com/~rhswain/perl.html
Does anyone know something better?
=============
On Date: Mon, 14 Apr 1997 Deep Summer <frank@deepsummer.com> wrote:
Try: http://www.mtolive.com/pbe/ instead. The trailing
index.html returns a 404 error, so I'm assuming the
index hook is grabbing .htm or .shtml or .cgi as an
extension (didn't check to see which - but it's not
.html).
-frank
=============
On Date: Mon, 14 Apr 1997 "Colin Durocher" <cdd2@gpu.srv.ualberta.ca>
wrote:
Sorry about the invalid URL... It's been a while since I've been to
this site and it was outdated. the actual URL is indeed:
http://www.mtolive.com/pbe/
and not:
http://www.mtolive.com/pbe/index.html
It used to be that you didn't have to register to access this book but
now I guess you do. Basically this site is the entire contents of Perl 5
by Example, a book that is sold in bookstores. I don't know why it's
there for free but apparently, it is the author that masters the site.
Anyhow, happy reading.
=============
ANYTHING MORE !!! WELCOME.
_____________________________________________
E-mail: dominic@thiru.vetri.com
Vetri Software, 160 Grams Road,
Madras, India
Ph Off: +91 44 824 0665, 827 3452, 827 2066
_____________________________________________
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 3 Jun 1997 01:54:51 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
To: chantane@JSP.UMontreal.CA (CHAN TANG Eric-Aubert)
Subject: Re: Working with multiple files (simultaneously).
Message-Id: <5mvthb$n12$1@info.uah.edu>
[Posted and mailed]
In article <5mv9pp$gp0@epervier.cc.umontreal.ca>,
chantane@JSP.UMontreal.CA (CHAN TANG Eric-Aubert) writes:
: Of course, it's not for copies.
:
: I should have ask: Is it possible to create arrays of
: file handles?
:
: Those <FILE>, and not the contents like
: my %table;
: @file = <FILE>;
: $table{$index} = @file;
Sure..
#! /usr/bin/perl5.004 -w
use 5.004; # what do you mean you haven't upgraded? :-)
use IO::Handle;
$pass = IO::Handle->new;
$motd = IO::Handle->new;
open $pass, '/etc/passwd' or die "Failed open /etc/passwd: $!\n";
open $motd, '/etc/motd' or die "Failed open /etc/motd: $!\n";
## an array?
push @handles, $pass, $motd;
## would you care for hash, sir? :-)
%handles = (
passwd => $pass,
motd => $motd,
);
Hope this helps,
Greg
--
Greg Bacon <gbacon@cs.uah.edu>
Unix / Perl Consultant
Perl Institute Partner - http://www.perl.org/
------------------------------
Date: Mon, 2 Jun 1997 19:45:20 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: CHAN TANG Eric-Aubert <chantane@JSP.UMontreal.CA>
Subject: Re: Working with multiple files (simultaneously).
Message-Id: <Pine.GSO.3.96.970602194255.20342K-100000@kelly.teleport.com>
On 2 Jun 1997, CHAN TANG Eric-Aubert wrote:
> Is it possible to create arrays of file handles?
Yes, and it's in the FAQ. :-) Hope this helps!
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/perlfaq5/
How_can_I_make_a_filehandle_loca.html
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 3 Jun 1997 01:06:36 GMT
From: dyoung@chromium.geoworks.com (Doug Young)
Subject: working with Perl and Multiplicity
Message-Id: <5mvqms$n9a$1@news>
does anyone have any experience running perl with multiplicicy
support...how do I specify which interpreter to use when making calls
such an perl_call_argv or perl_eval_sv?
Do I have to set a global variable? Then what's the point of
MULTIPLICITY?
Please help!
--
Doug Young -- dyoung@geoworks.com
"All ice cubes will be boiled before using"
-- U.S. Army Official, ordering sanitary measures.
Phone: 510-814-5893 Fax: 510-814-4250
------------------------------
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 561
*************************************