[15869] in Perl-Users-Digest
Perl-Users Digest, Issue: 3282 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 7 18:20:49 2000
Date: Wed, 7 Jun 2000 15:20:33 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <960416433-v9-i3282@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 7 Jun 2000 Volume: 9 Number: 3282
Today's topics:
reading contents of an ASCII file <raphaelp@nr1webresource.com>
Re: reading contents of an ASCII file <care227@attglobal.net>
Re: reading contents of an ASCII file <makarand_kulkarni@My-Deja.com>
Re: reading contents of an ASCII file <raphaelp@nr1webresource.com>
Re: reading contents of an ASCII file <madmardy@madmardy.com>
Re: reading contents of an ASCII file <care227@attglobal.net>
Re: reading contents of an ASCII file <raphaelp@nr1webresource.com>
Re: reading contents of an ASCII file <lauren_smith13@hotmail.com>
Re: reading contents of an ASCII file (Bart Lateur)
Re: reading contents of an ASCII file <lr@hpl.hp.com>
Re: reading contents of an ASCII file (Abigail)
Re: reading contents of an ASCII file (Abigail)
Re: rich text & mail attachments <you.will.always.find.him.in.the.kitchen@parties>
Re: Simple regexp question <no_email@no_email.com>
Simple socket question <gbw@theo1.physik.uni-stuttgart.de>
Re: Simple socket question (Clinton A. Pierce)
Re: split line like "a","b","c" <lr@hpl.hp.com>
System() & PID (J. Lundell)
Re: Test <nospam@nospam.com>
Text Sorting Question <jim.ray@west.boeing.com>
Re: Text Sorting Question <sariq@texas.net>
Re: Text Sorting Question <jeff@vpservices.com>
Re: Text Sorting Question <makarand_kulkarni@My-Deja.com>
Re: Text Sorting Question <lr@hpl.hp.com>
Re: Text Sorting Question <abe@ztreet.demon.nl>
Re: the end of perl? (Bart Lateur)
Re: Using Unix SOURCE in PERL SYSTEM?? NEED HELP <Michael.Bukowski@usa.xerox.com>
Re: Win32 Perl read weirdness <lr@hpl.hp.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 7 Jun 2000 22:16:13 +0200
From: "Raphael Pirker" <raphaelp@nr1webresource.com>
Subject: reading contents of an ASCII file
Message-Id: <8hmah9$k7c$1@news.online.de>
Hi,
I would like to read the contents of an ASCII text file into a variable. The
file has many lines, so a singe OPEN won't do. Any hints?
Regards,
Raphael Pirker
------------------------------
Date: Wed, 07 Jun 2000 16:18:17 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: reading contents of an ASCII file
Message-Id: <393EAE09.6F06E449@attglobal.net>
Raphael Pirker wrote:
> I would like to read the contents of an ASCII text file into a variable. The
> file has many lines, so a singe OPEN won't do. Any hints?
I wasn't aware of any line restrictions for an open() call.
Strange. I think if you check perlfaq5 you'll learn how to
accomplish this task, and I just bet it involves an open().
------------------------------
Date: Wed, 07 Jun 2000 13:21:03 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: reading contents of an ASCII file
Message-Id: <393EAEAF.F6DC5AFC@My-Deja.com>
> I would like to read the contents of an ASCII text file into a variable. The
> file has many lines, so a singe OPEN won't do. Any hints?
open the file.
set $/ to undef
then read the file. The entire file will get read into your scalar variable.
Reset the value of $/
-
------------------------------
Date: Wed, 7 Jun 2000 22:22:50 +0200
From: "Raphael Pirker" <raphaelp@nr1webresource.com>
Subject: Re: reading contents of an ASCII file
Message-Id: <8hmatm$kd5$1@news.online.de>
did I forget to mention I'm totally new to Perl? :-)
Makarand Kulkarni <makarand_kulkarni@My-Deja.com> wrote in message
news:393EAEAF.F6DC5AFC@My-Deja.com...
> > I would like to read the contents of an ASCII text file into a variable.
The
> > file has many lines, so a singe OPEN won't do. Any hints?
>
> open the file.
> set $/ to undef
> then read the file. The entire file will get read into your scalar
variable.
> Reset the value of $/
> -
>
>
------------------------------
Date: Wed, 07 Jun 2000 14:34:15 -0600
From: Mark Holt <madmardy@madmardy.com>
Subject: Re: reading contents of an ASCII file
Message-Id: <393EB1C7.6A45D361@madmardy.com>
$/ = undef;
open FILE, "file.txt";
$contents = <FILE>;
close FILE;
$/ = "\n";
Raphael Pirker wrote:
> Hi,
>
> I would like to read the contents of an ASCII text file into a variable. The
> file has many lines, so a singe OPEN won't do. Any hints?
>
> Regards,
>
> Raphael Pirker
------------------------------
Date: Wed, 07 Jun 2000 16:35:04 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: reading contents of an ASCII file
Message-Id: <393EB1F8.5DBC0A8F@attglobal.net>
Mark Holt wrote:
>
> $/ = undef;
> open FILE, "file.txt";
> $contents = <FILE>;
> close FILE;
> $/ = "\n";
Wouldn't it be safer to enclose that block in a subroutine and
use: "local $/ = undef;" ??
------------------------------
Date: Wed, 7 Jun 2000 22:43:33 +0200
From: "Raphael Pirker" <raphaelp@nr1webresource.com>
Subject: Re: reading contents of an ASCII file
Message-Id: <8hmc5r$l29$1@news.online.de>
Hi Mark,
Thanks a lot! It worked just fine!!!
Mark Holt <madmardy@madmardy.com> wrote in message
news:393EB1C7.6A45D361@madmardy.com...
> $/ = undef;
> open FILE, "file.txt";
> $contents = <FILE>;
> close FILE;
> $/ = "\n";
>
> Raphael Pirker wrote:
>
> > Hi,
> >
> > I would like to read the contents of an ASCII text file into a variable.
The
> > file has many lines, so a singe OPEN won't do. Any hints?
> >
> > Regards,
> >
> > Raphael Pirker
>
------------------------------
Date: Wed, 7 Jun 2000 13:47:23 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: reading contents of an ASCII file
Message-Id: <8hmcbh$9rd$1@brokaw.wa.com>
Drew Simonis <care227@attglobal.net> wrote in message
news:393EB1F8.5DBC0A8F@attglobal.net...
> Mark Holt wrote:
> >
> > $/ = undef;
> > open FILE, "file.txt";
> > $contents = <FILE>;
> > close FILE;
> > $/ = "\n";
>
> Wouldn't it be safer to enclose that block in a subroutine and
> use: "local $/ = undef;" ??
If the data just needs to be slurped, wouldn't the idiom
read FILE, $data, -s FILE;
be easier to understand?
Look Ma! No special variables!
:-)
Lauren
------------------------------
Date: Wed, 07 Jun 2000 20:56:41 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: reading contents of an ASCII file
Message-Id: <3940b1aa.1004248@news.skynet.be>
Raphael Pirker wrote:
>I would like to read the contents of an ASCII text file into a variable. The
>file has many lines, so a singe OPEN won't do. Any hints?
Oh yes it will. "open", that is; Perl is case sensitive.
If you undef $/ (preferably temporarily, using "local"), and read from
the file, it will read the entire file in on scalar.
{
local $/; # undef
$contents = <FILE>;
}
--
Bart.
------------------------------
Date: Wed, 7 Jun 2000 13:53:35 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: reading contents of an ASCII file
Message-Id: <MPG.13a8562ce9ec9ca798ab3f@nntp.hpl.hp.com>
In article <393EB1F8.5DBC0A8F@attglobal.net> on Wed, 07 Jun 2000
16:35:04 -0400, Drew Simonis <care227@attglobal.net> says...
> Mark Holt wrote:
> >
> > $/ = undef;
> > open FILE, "file.txt";
open FILE, 'file.txt' or die "Couldn't open 'file.txt'. $!\n";
> > $contents = <FILE>;
> > close FILE;
> > $/ = "\n";
>
> Wouldn't it be safer to enclose that block in a subroutine and
> use: "local $/ = undef;" ??
No need for a subroutine -- a bare block will do, and the undef can be
implicit.
{
local $/;
$contents = <FILE>;
}
The 'more elegant' way of saying that turns out to require an extra copy
of the data, so is less efficient.
$contents = do { local $/; <FILE> };
Some recent threads show that this may well be the fastest:
$contents = read FILE, $contents, -s FILE;
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 7 Jun 2000 21:37:24 GMT
From: abigail@arena-i.com (Abigail)
Subject: Re: reading contents of an ASCII file
Message-Id: <8hmfak$r5c$1@news.panix.com>
On Wed, 7 Jun 2000 22:16:13 +0200,
Raphael Pirker <raphaelp@nr1webresource.com> wrote:
++
++ I would like to read the contents of an ASCII text file into a variable. The
++ file has many lines, so a singe OPEN won't do. Any hints?
Well, I guess that if a single open won't do, you would have to use
more than one.
But I see you know more about Perl than I do. I would never have thought
of opening a file more than once just to read it!
Abigail
------------------------------
Date: 7 Jun 2000 21:41:40 GMT
From: abigail@arena-i.com (Abigail)
Subject: Re: reading contents of an ASCII file
Message-Id: <8hmfik$r5c$2@news.panix.com>
On Wed, 7 Jun 2000 13:53:35 -0700, Larry Rosler <lr@hpl.hp.com> wrote:
++ In article <393EB1F8.5DBC0A8F@attglobal.net> on Wed, 07 Jun 2000
++ 16:35:04 -0400, Drew Simonis <care227@attglobal.net> says...
++ > Mark Holt wrote:
++ > >
++ > > $/ = undef;
++ > > open FILE, "file.txt";
++
++ open FILE, 'file.txt' or die "Couldn't open 'file.txt'. $!\n";
++
++ > > $contents = <FILE>;
++ > > close FILE;
++ > > $/ = "\n";
++ >
++ > Wouldn't it be safer to enclose that block in a subroutine and
++ > use: "local $/ = undef;" ??
++
++ No need for a subroutine -- a bare block will do, and the undef can be
++ implicit.
++
++ {
++ local $/;
++ $contents = <FILE>;
++ }
++
++ The 'more elegant' way of saying that turns out to require an extra copy
++ of the data, so is less efficient.
++
++ $contents = do { local $/; <FILE> };
And there's also:
$contents = do {local (@ARGV, $/) = "file"; <ARGV>};
Abigail
------------------------------
Date: Thu, 8 Jun 2000 08:29:04 +1200
From: "Tintin" <you.will.always.find.him.in.the.kitchen@parties>
Subject: Re: rich text & mail attachments
Message-Id: <960409638.119104@shelley.paradise.net.nz>
"Rob" <rob@megagiga.com> wrote in message
news:960397040.556916@cache.aquanet.co.il...
> How do I add attachments to email sent from a perl script (form submission
> for example) ?
>
> Also, how do I turn text submitted in a form into 'rich text' email?
Grab the MIME::Lite module from CPAN.
------------------------------
Date: Wed, 07 Jun 2000 13:51:45 -0400
From: Young <no_email@no_email.com>
Subject: Re: Simple regexp question
Message-Id: <393E8BB1.BC57AE98@no_email.com>
Hi,
First, if you want to replace the text string $INTERNAL, change the
line...
$vbl="$INTERNAL";
...to...
$vbl='$INTERNAL';
This way, Perl won't try try to use the value stored in a variable named
$INTERNAL.
Secondly, in your $newline=~ ... line, you should probably be:
$newline=~s/$vbl/$newval/g;
The 'g' makes the substitution global, so all occurrences of '$INTERNAL'
in the same line get replaced (instead of only the first one).
Hope this helps.
------------------------------
Date: Wed, 07 Jun 2000 22:04:57 +0200
From: Georg Woeste <gbw@theo1.physik.uni-stuttgart.de>
Subject: Simple socket question
Message-Id: <393EAAE9.1E73C273@theo1.physik.uni-stuttgart.de>
Hi,
I have the two scripts, "client" and "server" (see below), which should
communicate
via a socket also in the background. If I start "server" in one xterm
and
then "client" in another, it worked fine.
But if I send the server into the background
bash> server &
the connection seems to be broken. So how can I run "server" and
"client"
in the backround and let them communicate? Most simple solution is
most appreciated! Thanks!
Regards,
Georg
server:
#!/usr/bin/perl
use Socket;
$port=2345;
socket(Serversocket, PF_INET, SOCK_STREAM, 'tcp',);
bind(Serversocket, sockaddr_in($port, INADDR_ANY));
listen(Serversocket, SOMAXCONN);
while(accept(Clientsocket,Serversocket))
{
$now = localtime();
syswrite(Clientsocket, $now);
close Clientsocket;
}
############################################
client
#!/usr/bin/perl
use Socket;
$port=2345;
socket(Clientsocket,PF_INET,SOCK_STREAM,'tcp');
connect(Clientsocket, sockaddr_in($port, inet_aton(localhost)));
sysread(Clientsocket, $now,80);
print "Now: $now\n";
close Clientsocket;
------------------------------
Date: Wed, 07 Jun 2000 20:56:18 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Simple socket question
Message-Id: <SFy%4.101980$h01.805695@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <393EAAE9.1E73C273@theo1.physik.uni-stuttgart.de>,
Georg Woeste <gbw@theo1.physik.uni-stuttgart.de> writes:
>
> the connection seems to be broken. So how can I run "server" and
> "client"
> in the backround and let them communicate? Most simple solution is
> most appreciated! Thanks!
Before anyone goes hacking into your code, you should at LEAST make
sure that what you're doing works.
> use Socket;
There's a nice object interface for this that might be easier to use
than creating your socket by hand...
> socket(Serversocket, PF_INET, SOCK_STREAM, 'tcp',);
Are you sure this worked? How about an "|| die" there?
If you're going to roll your own socket interface, you can at
least make sure everything worked before proceeding with the
next step. You don't have a flipping clue where this program
is blowing up. Help yourself out and check return values.
And while you're at it, turn on warnings and "use strict", mmmkay?
> bind(Serversocket, sockaddr_in($port, INADDR_ANY));
Are you sure this worked? How about an "|| die" there?
> listen(Serversocket, SOMAXCONN);
Are you sure this worked? How about an "|| die" there?
You're getting the idea, I hope.
> syswrite(Clientsocket, $now);
Are you sure this worked? syswrite DOES have a return
value, and it's worth checking. Why are you using syswrite()
anyways? Just use print or something...sheesh.
> socket(Clientsocket,PF_INET,SOCK_STREAM,'tcp');
Are you sure this worked? How about an "|| die" there?
> connect(Clientsocket, sockaddr_in($port, inet_aton(localhost)));
Are you sure this worked? How about an "|| die" there?
If you haven't figured out how to debug this by now, re-read this
response a few dozen times. Read Debug Repeat.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Wed, 7 Jun 2000 12:17:28 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: split line like "a","b","c"
Message-Id: <MPG.13a83fa0b0e480d498ab39@nntp.hpl.hp.com>
In article <bigiain-0706001846190001@bigman.mighty.com.au> on Wed, 07
Jun 2000 18:46:19 +1000, Iain Chalmers <bigiain@mightymedia.com.au>
says...
...
> use Benchmark;
>
> timethese(1000000, {
> 'map' => sub{$_='"a","b","c"';
> ($a,$b,$c) = map { /"([^"]*)/; $1 } split /,/;},
> 'foreach' => sub{$_='"a","b","c"';
> ($a,$b,$c) = split /,/;
> foreach $x ($a,$b,$c) { s/"/$x/;}},
> 'regex' => sub{$_='"a","b","c"';
> s/"//g;
> ($a,$b,$c) = split /,/;},
> });
If you're going to benchmark, use the 'best' (fastest) way.
Replace
s/"//g;
by
tr/"//d;
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 07 Jun 2000 14:15:32 -0500
From: jlundell2@mmm.com (J. Lundell)
Subject: System() & PID
Message-Id: <393E9F54.951486C3@mmm.com>
Hi,
Is there a way on NT to create a new process and capture the Process ID
of this new process via Perl?
Thanks!
-Jim, 3M
Opinions expressed herein are my own and may not represent those of my employer.
------------------------------
Date: 7 Jun 2000 19:51:56 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: Test
Message-Id: <8hm94s$i6p$1@216.155.32.49>
In article <393BB835.88A147B1@lmc.ericsson.se>, "Martin C Dore (LMC)"
<lmcmcad@lmc.ericsson.se> wrote:
|
hmm.. test unsuccessful. no output.
null program.
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Wed, 7 Jun 2000 18:42:05 GMT
From: "Jim Ray" <jim.ray@west.boeing.com>
Subject: Text Sorting Question
Message-Id: <FvsruC.7t9@news.boeing.com>
I have question I am hoping someone can answer. I have a text file that has
7 fields delimited by ";". I want to be able to sort on either field 2 or
3. I thought I had a routine to do this, but it seems I was wrong.
Does anyone know how this can be done? I am running Perl 5.x on a Unix and
NT system.
Example:
Sort or Sort
Field1;Field2;Field3;Field4;Field5;Field6;Field7;
Field1;Field2;Field3;Field4;Field5;Field6;Field7;
Field1;Field2;Field3;Field4;Field5;Field6;Field7;
Field1;Field2;Field3;Field4;Field5;Field6;Field7;
Thank you for any help you can give me.
Jim
jaray@relaypoint.net
------------------------------
Date: Wed, 07 Jun 2000 14:05:51 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Text Sorting Question
Message-Id: <393E9D0F.80AEDA91@texas.net>
Jim Ray wrote:
>
> I have question I am hoping someone can answer. I have a text file that has
> 7 fields delimited by ";". I want to be able to sort on either field 2 or
> 3. I thought I had a routine to do this, but it seems I was wrong.
perldoc -q sort
perldoc -f sort
If you have read the docs, and need additional help, post a small piece
of working code that demonstrates your problem.
If you just want someone to do your work for you, hire a programmer.
- Tom
------------------------------
Date: Wed, 07 Jun 2000 12:40:33 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Text Sorting Question
Message-Id: <393EA531.F3E76EA6@vpservices.com>
Jim Ray wrote:
>
> I have question I am hoping someone can answer. I have a text file that has
> 7 fields delimited by ";". I want to be able to sort on either field 2 or
> 3. I thought I had a routine to do this, but it seems I was wrong.
>
> Does anyone know how this can be done? I am running Perl 5.x on a Unix and
> NT system.
>
> Example:
> Sort or Sort
> Field1;Field2;Field3;Field4;Field5;Field6;Field7;
> Field1;Field2;Field3;Field4;Field5;Field6;Field7;
> Field1;Field2;Field3;Field4;Field5;Field6;Field7;
> Field1;Field2;Field3;Field4;Field5;Field6;Field7;
You can either use sort as per Tom Briles' suggestion, or if you will be
doing other database like things to the file, you can use DBI with
either DBD::CSV or DBD::RAM, both of which will let you declare the
semicolon as the field separator, and sort by any number of columns in
either ascending or descending order as well as perform other database
selection and modification operations.
--
Jeff
------------------------------
Date: Wed, 07 Jun 2000 12:50:42 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: Text Sorting Question
Message-Id: <393EA792.C19BDCF0@My-Deja.com>
> I have question I am hoping someone can answer. I have a text file that has
> 7 fields delimited by ";". I want to be able to sort on either field 2 or
> 3. I thought I had a routine to do this, but it seems I was wrong.
snippet.
@lines = <DATA>; chomp ( @lines );
print "By second field..\n";
@out = sort { (split ';', $a, 3)[1] <=> (split ';', $b, 3)[1] } @lines;
print join "\n", @out ;
print "\n";
print "By third field..\n";
@out = sort { (split ';', $a, 4)[2] cmp (split ';', $b, 4)[2] } @lines ;
print join "\n", @out ;
print "\n";
__DATA__
Field1;1;a;Field4;Field5;Field6;Field7;
Field1;3;c;Field4;Field5;Field6;Field7;
Field1;27;w;Field4;Field5;Field6;Field7;
Field1;22;v;Field4;Field5;Field6;Field7;
------------------------------
Date: Wed, 7 Jun 2000 13:34:13 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Text Sorting Question
Message-Id: <MPG.13a851a4eb87d8ce98ab3d@nntp.hpl.hp.com>
In article <393EA792.C19BDCF0@My-Deja.com> on Wed, 07 Jun 2000 12:50:42
-0700, Makarand Kulkarni <makarand_kulkarni@My-Deja.com> says...
> > I have question I am hoping someone can answer. I have a text file that has
> > 7 fields delimited by ";". I want to be able to sort on either field 2 or
> > 3. I thought I had a routine to do this, but it seems I was wrong.
...
> @out = sort { (split ';', $a, 3)[1] <=> (split ';', $b, 3)[1] } @lines;
As a perusal of the recommended documents about sorting would show, that
solution is grossly inefficient. If there are N elements in the array,
it does O(N * log N) splits, when it can and should be done with N
splits.
<URL:http://www.hpl.hp.com/personal/Larry_Rosler/sort/>
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 07 Jun 2000 23:58:27 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Text Sorting Question
Message-Id: <s8ftjsgu8nns8jppavechqke610l9r8th2@4ax.com>
On Wed, 07 Jun 2000 12:50:42 -0700, Makarand Kulkarni
<makarand_kulkarni@My-Deja.com> wrote:
> > I have question I am hoping someone can answer. I have a text file that has
> > 7 fields delimited by ";". I want to be able to sort on either field 2 or
> > 3. I thought I had a routine to do this, but it seems I was wrong.
>
> snippet.
>
> @lines = <DATA>; chomp ( @lines );
> print "By second field..\n";
> @out = sort { (split ';', $a, 3)[1] <=> (split ';', $b, 3)[1] } @lines;
And that will split every line every time it is compared. We're talking
Camel here not Turtle!
If sorting this thing is the main objective, use Schwartzian-Transform
or Rosler/Guttman-Transform.
perldoc -f sort
http://www.perl.com/CPAN-local/doc/FMTEYEWTK/sort.html
http://www.hpl.hp.com/personal/Larry_Rosler/sort/sorting.html
--
Good luck,
Abe
------------------------------
Date: Wed, 07 Jun 2000 20:56:38 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: the end of perl?
Message-Id: <393fb0ec.814867@news.skynet.be>
Abigail wrote:
>
>This is a valid Perl program:
>
> #!/opt/perl/bin/perl -w
> use strict;
> $¥ = "foo";
> print $¥, "\n";
> __END__
>
>
>Don't tell me that ¥ (\245) is an ASCII character....
>
No. I'm a bit surprised it is acceptable for Perl. I am not surprised it
is not one of the standard "special variables", though.
--
Bart.
------------------------------
Date: Wed, 07 Jun 2000 19:30:19 GMT
From: Mike <Michael.Bukowski@usa.xerox.com>
Subject: Re: Using Unix SOURCE in PERL SYSTEM?? NEED HELP
Message-Id: <sjt8mb592t5145@corp.supernews.com>
Alex Rhomberg wrote:
>
> Mike wrote:
>
> [Huge snip. Please quote more selectively]
>
> > Yeah.. The shell script that I am trying to run sets up a bunch of
> > environment variables that are used here. I need to use those
variables in
> > my Perl script. There have been people around here that have tried to
> > convert the systembuild (shell script) into Perl but have had no
success.
> > I would like to be able to run the script and then be able to use the
> > variables within the current Perl process.
>
> You can run the script and process the output of the 'set' command which
> gives you all environment variables:
>
> my @envs = `. shellscript > /dev/null; set`;
> (The dot is /bin/sh's equivalent of csh's source)
>
> You can then use the contents of @envs to modify %ENV.
>
> > Is there a way I can run the
> > script so that is sets the environment variables for more than the
current
> > perl processs? My script spawns other scripts as It goes along which
may
> > need to use the variables in the future.
>
> Any scripts spawned by your script inherit %ENV.
>
> - Alex
Cool. I ended up writing a shell script that first runs "source
systembuild" which sets all the variables I need and then runs the perl
scripts. It seems to be working ok and I can use the variables that I
need. Thanks all for the help.
~mike
--
Posted via CNET Help.com
http://www.help.com/
------------------------------
Date: Wed, 7 Jun 2000 11:34:33 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Win32 Perl read weirdness
Message-Id: <MPG.13a83595c725d06998ab37@nntp.hpl.hp.com>
In article <Pine.GHP.4.21.0006071221550.1201-100000@hpplus03.cern.ch> on
Wed, 7 Jun 2000 12:25:39 +0200, Alan J. Flavell <flavell@mail.cern.ch>
says...
> On Wed, 7 Jun 2000, Clinton A. Pierce wrote:
>
> > perldoc -f binmode
>
> > It's a Windows/DOS misfeature that some people forget about.
>
> I think it's fair to say that there are rather few non-unix OSes that
> don't need a distinction to be made between binary and text.
>
> You might want to conclude that non-unix OSes are a misfeature, "but I
> couldn't possibly comment".
>
> The best advice seems to be to always make the conceptual distinction,
> and thus always apply binmode when relevant, even in the special case
> where it's a non-event.
I have been campaigning for all Perl writers and educators to do this.
Maybe it will start to happen. The 5.6.0 documentation for binmode()
makes a huge leap in that direction:
In other words: Regardless of platform, use binmode() on binary files,
and do not use binmode() on text files.
The 'conceptual distinction' has to do with the logical organization of
the file, which should certainly be known to the programmer.
If the file consists of records ('lines') of possibly varying lengths,
then it is a 'text file', and reading it with the diamond operator <> or
the readline() function by default causes one such record to be read
into a string. The string is terminated with the single character "\n",
no matter what the external representation of the record is. On
Windows/DOS, it may be a segment of a stream of characters terminated
with "\15\12"; on some systems it may be a distinct record maintained by
the file system, with a length but no terminator (if memory serves, ISAM
files work that way also).
If the file consists of records of fixed lengths, it may be treated as a
binary file and read using read() or sysread(). The binmode() function
inhibits any translation from the external representation.
Setting $/ to other than the default, "\n", blurs the line-oriented
concept of a text file somewhat by changing the definition of a record
as read by <>. But even then, the programmer should have full knowledge
of the situation and should act accordingly.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 3282
**************************************