[16304] in Perl-Users-Digest
Perl-Users Digest, Issue: 3716 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 18 10:02:57 2000
Date: Tue, 18 Jul 2000 07:02:47 -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: <963928967-v9-i3716@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 18 Jul 2000 Volume: 9 Number: 3716
Today's topics:
how to append lines to the end of file ()
Re: how to convert "1.2.3.10" to "01020310"? (Godzilla!)
Re: how to convert "1.2.3.10" to "01020310"? (Abigail)
Re: how to convert "1.2.3.10" to "01020310"? (Craig Berry)
Re: how to convert "1.2.3.10" to "01020310"? (Abigail)
Re: how to convert "1.2.3.10" to "01020310"? (Craig Berry)
Re: how to convert "1.2.3.10" to "01020310"? (Keith Calvert Ivey)
Re: how to convert "1.2.3.10" to "01020310"? (Abigail)
Re: how to convert "1.2.3.10" to "01020310"? (Craig Berry)
Re: how to convert "1.2.3.10" to "01020310"? (Abigail)
How to get the machine (archtechture) type in Perl? (J. H. Park)
Re: How to get the machine (archtechture) type in Perl? (NP)
Re: How to get the machine (archtechture) type in Perl? (Abigail)
Re: How to get the machine (archtechture) type in Perl? (Gwyn Judd)
Re: How to get the machine (archtechture) type in Perl? (Mariusz £)
How to kill Win95 process (Sébastien Cottalorda)
Re: how to make my program with csh (doco)
Re: how to make my program with csh (doco)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Jul 2000 08:20:01 GMT
From: tvn007@my-deja.com.bbs@openbazaar.net ()
Subject: how to append lines to the end of file
Message-Id: <3bOb12$XD_@openbazaar.net>
Hi,
I am trying to write a small script to count number of
lines in the file. If number of lines in a file is less than
500 than you have to add whatever number of lines to the
end of the file so that
the total of lines in that file is 500 lines.
The line you need to add is: XXX
Here what I have so far:
#########################################
$data_file ='test.file';
open(SCORES,$data_file)|| die "cannot open test file";
$i=0;
$expression = "p_S|p_X";
while (<SCORES>){
chomp;
if ($_ =~ /$expression/){
$i++;
}
}
if ($i <500){
$line_to_add = 500 - $i;
# can some one show me how to add
# extra lines at the end of test.file so that
the total number of line is 500 lines?
where each line is: XXX
}
}
Example:
line1 abc
line2 xyz
..
...
line 498 fxt
line 499 XXX
line 500 XXX
Thanks for any help,
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 14 Jul 2000 08:10:03 GMT
From: godzilla@stomp.stomp.tokyo.bbs@openbazaar.net (Godzilla!)
Subject: Re: how to convert "1.2.3.10" to "01020310"?
Message-Id: <3bOaaR$YyJ@openbazaar.net>
ethan wrote:
> Hope there someone who can help me with this. I am new to PERL...
This seems a required preamble to virtually every
article orginating from a fake email address,
especially deja, bigfoot and hotmail. Anymore,
ninety-nine percent of all interrogatory articles
indicate "newbie" in some form or fashion.
This phenomenon's event odds seems to exceed a person's
chances of winning a state lottery or being struck dead
by a bolt of lightning.
Odd don't you think?
Even odder is this capitalization of PERL in so many
articles from newbies, very suddenly and within a short
time frame. You would have better odds of proving
O.J. Simpson guilty than the odds of this happening,
as purely mathematical coincidence.
Think I will refrain from commenting on numerous other
unique idioms appearing in virtually all newbie articles.
Has to be Divine or Devilish intervention, of which, I know
better than to question or comment upon, other than to mimic
dearly departed Carl Sagan in saying the odds are in the,
"...billions and billions."
Frustrating to be an English teacher, very frustrating.
We often notice between the lines what shouldn't be.
> facing the problem of convert a string of "2.1.3.14" format
> to "02010314" format.
A very simple alternative to methods posted so far:
$string =~ s/\./0 /g;
$string =~ s/(.*)0 (\d+)/$1$2/;
$string =~ s/ //g;
Some test results are below with my test script.
This simple method seems to work well for those
four tests performed. Don't mix in =~tr/// with
this method. A bug will appear.
Godzilla!
PRINTED RESULTS:
________________
Test One Input: 2.1.3.14
Test One Output: 2010314
Test Two Input: 1.2.3.0
Test Two Output: 102030
Test Three Input: 123.456.789.10
Test Three Output: 1230456078910
Test Four Input: 10.987.654.3210
Test Four Output: 10098706543210
TEST SCRIPT:
____________
#!/usr/local/bin/perl
print "Content-Type: text/plain\n\n";
$string = "2.1.3.14";
print "Test One Input: $string\n";
&Do_It;
print "Test One Output: $string\n\n";
$string = "1.2.3.0";
print "Test Two Input: $string\n";
&Do_It;
print "Test Two Output: $string\n\n";
$string = "123.456.789.10";
print "Test Three Input: $string\n";
&Do_It;
print "Test Three Output: $string\n\n";
$string = "10.987.654.3210";
print "Test Four Input: $string\n";
&Do_It;
print "Test Four Output: $string\n\n";
sub Do_It
{
$string =~ s/\./0 /g;
$string =~ s/(.*)0 (\d+)/$1$2/;
$string =~ s/ //g;
}
exit;
------------------------------
Date: 17 Jul 2000 20:00:09 GMT
From: abigail@delanet.com.bbs@openbazaar.net (Abigail)
Subject: Re: how to convert "1.2.3.10" to "01020310"?
Message-Id: <3bRNaA$W1m@openbazaar.net>
Jim Mauldin (mauldin@netstorm.net) wrote on MMDX September MCMXCIII in
<URL:news:3970F51A.CC6CFCA4@netstorm.net>:
** jason wrote:
**
** > ethan wrote ..
** > >Hope there someone who can help me with this. I am new to PERL and am
** > >facing the problem of convert a string of "2.1.3.14" format
** > >to "02010314" format.
** >
** > printf '%02d%02d%02d%02d' => split /\./ => '2.1.3.14';
**
** Or even
** printf '%02d' x 4 , split /\./ , '2.1.3.14';
Yeah, but that still requires you to count by hand.
map {printf "%02d" => $_} split /\./ => '2.1.3.14';
Abigail
--
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print
qq{Just Another Perl Hacker\n}}}}}}}}}' |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w
------------------------------
Date: 18 Jul 2000 00:00:01 GMT
From: cberry@cinenet.net.bbs@openbazaar.net (Craig Berry)
Subject: Re: how to convert "1.2.3.10" to "01020310"?
Message-Id: <3bRU05$TvW@openbazaar.net>
Abigail (abigail@delanet.com) wrote:
: map {printf "%02d" => $_} split /\./ => '2.1.3.14';
Mapping in a void context? Abigail?? And using double-quotes for a
static string, too. Why not do
printf '%02d', $_ foreach split /\./ => '2.1.3.14';
instead? (I still like my regex solution better, though.)
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Beauty and strength, leaping laughter and delicious
| languor, force and fire, are of us." - Liber AL II:20
------------------------------
Date: 18 Jul 2000 01:30:03 GMT
From: abigail@delanet.com.bbs@openbazaar.net (Abigail)
Subject: Re: how to convert "1.2.3.10" to "01020310"?
Message-Id: <3bRWGT$X5z@openbazaar.net>
Craig Berry (cberry@cinenet.net) wrote on MMDXIII September MCMXCIII in
<URL:news:sn77qujao5388@corp.supernews.com>:
:: Abigail (abigail@delanet.com) wrote:
:: : map {printf "%02d" => $_} split /\./ => '2.1.3.14';
::
:: Mapping in a void context? Abigail??
Cargo cult answers? Craig??
Once again. There is absolutely nothing wrong with map in a void context.
If you don't like side-effect, please ditch Perl and use something like
Haskell, or another functional language. As for the potential inefficiency,
that has been known for years, and never considered inefficient enough to
actually fix. And that's a bug in the implementation of perl, and should
not be hold against a programmer of Perl.
:: And using double-quotes for a
:: static string, too.
What the fuck is wrong with that?
:: Why not do
::
:: printf '%02d', $_ foreach split /\./ => '2.1.3.14';
Because this is Perl and having more than one way to do it is a feature?
And besides, I first had everything in a string of printing it, and wrote:
join "" => map {sprintf "%02d" => $_} split /\./ => '2.1.3.14';
Why change paradigms just because you are printing to STDOUT instead of
collecting it in a string?
Abigail
--
perl -Mstrict -we '$_ = "goto F.print chop;\n=rekcaH lreP rehtona tsuJ";F1:eval'
------------------------------
Date: 18 Jul 2000 02:20:02 GMT
From: cberry@cinenet.net.bbs@openbazaar.net (Craig Berry)
Subject: Re: how to convert "1.2.3.10" to "01020310"?
Message-Id: <3bRXV2$WTd@openbazaar.net>
Abigail (abigail@delanet.com) wrote:
: Craig Berry (cberry@cinenet.net) wrote on MMDXIII September MCMXCIII in
: <URL:news:sn77qujao5388@corp.supernews.com>:
: :: Abigail (abigail@delanet.com) wrote:
: :: : map {printf "%02d" => $_} split /\./ => '2.1.3.14';
: ::
: :: Mapping in a void context? Abigail??
:
: Cargo cult answers? Craig??
Nope. This is reasoned. map must accumulate results and build a list
only to throw it away; for does not carry this overhead. As the two have
roughly equal notational convenience, it makes sense to use the more
efficient choice.
: Once again. There is absolutely nothing wrong with map in a void context.
: If you don't like side-effect, please ditch Perl and use something like
: Haskell, or another functional language.
I enjoy functional languages -- did a lot of Lisp a while back, for
example -- but also like procedural languages. I merely try to use the
appropriate tools for the style I'm currently applying.
: As for the potential inefficiency,
: that has been known for years, and never considered inefficient enough to
: actually fix. And that's a bug in the implementation of perl, and should
: not be hold against a programmer of Perl.
This one goes into the double-quoted static string category for me. It
works, the efficiency delta is minimal...and yet, when I'm reading code
(including my own) and see double-quotes, my predictive parser starts
scanning for the interpolation points, and has to do a backtrack if there
aren't any. Similarly, map makes me start thinking in terms of "Okay,
where will the resulting list go?", which must be abandoned when the void
context registers.
A lot of this stuff falls into the same more general category as e.g.
indenting your code, or including comments. Perl doesn't care, but *you*
will, or the maintenance programmer who comes after you.
: :: And using double-quotes for a
: :: static string, too.
:
: What the fuck is wrong with that?
See above.
: :: Why not do
: ::
: :: printf '%02d', $_ foreach split /\./ => '2.1.3.14';
:
: Because this is Perl and having more than one way to do it is a feature?
Of course; and we can each pick the subset of WTDI which make us more
productive, now and in the future.
: And besides, I first had everything in a string of printing it, and wrote:
:
: join "" => map {sprintf "%02d" => $_} split /\./ => '2.1.3.14';
:
: Why change paradigms just because you are printing to STDOUT instead of
: collecting it in a string?
Ask the poster to whom I responded; again, I still like my regex version,
which solved the orginal to-string version and thus the printing problem
as well.
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Beauty and strength, leaping laughter and delicious
| languor, force and fire, are of us." - Liber AL II:20
------------------------------
Date: 18 Jul 2000 02:50:03 GMT
From: kcivey@cpcug.org.bbs@openbazaar.net (Keith Calvert Ivey)
Subject: Re: how to convert "1.2.3.10" to "01020310"?
Message-Id: <3bRYKS$Wjx@openbazaar.net>
cberry@cinenet.net (Craig Berry) wrote:
>Abigail (abigail@delanet.com) wrote:
>: map {printf "%02d" => $_} split /\./ => '2.1.3.14';
>
>Mapping in a void context? Abigail??
Why are you surprised? Abigail is the foremost proponent of map
in a void context.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
(Free at last from the forced spamsig of
Newsfeeds.com, cursed be their name)
------------------------------
Date: 18 Jul 2000 03:30:04 GMT
From: abigail@delanet.com.bbs@openbazaar.net (Abigail)
Subject: Re: how to convert "1.2.3.10" to "01020310"?
Message-Id: <3bRZMU$Xfg@openbazaar.net>
Craig Berry (cberry@cinenet.net) wrote on MMDXIII September MCMXCIII in
<URL:news:sn7fk2i4o53172@corp.supernews.com>:
[] Abigail (abigail@delanet.com) wrote:
[] : Craig Berry (cberry@cinenet.net) wrote on MMDXIII September MCMXCIII in
[] : <URL:news:sn77qujao5388@corp.supernews.com>:
[] : :: Abigail (abigail@delanet.com) wrote:
[] : :: : map {printf "%02d" => $_} split /\./ => '2.1.3.14';
[] : ::
[] : :: Mapping in a void context? Abigail??
[] :
[] : Cargo cult answers? Craig??
[]
[] Nope. This is reasoned. map must accumulate results and build a list
[] only to throw it away; for does not carry this overhead. As the two have
[] roughly equal notational convenience, it makes sense to use the more
[] efficient choice.
map, of course, doesn't have to. Every other function in Perl is able
to figure out its context, and act accordingly. I've never heard any
convincing argument (in fact, I've never heard any argument) why map
has to build a list regarding of its context. The fact that map does is
a bug in perl. In perl that is, not in Perl. There's no reason to avoid
map in Perl. There is a reason to fix the implementation of map in perl
though. However, it has been known for a long, long time, but hasn't been
found important enough to fix.
[] : Once again. There is absolutely nothing wrong with map in a void context.
[] : If you don't like side-effect, please ditch Perl and use something like
[] : Haskell, or another functional language.
[]
[] I enjoy functional languages -- did a lot of Lisp a while back, for
[] example -- but also like procedural languages. I merely try to use the
[] appropriate tools for the style I'm currently applying.
[]
[] : As for the potential inefficiency,
[] : that has been known for years, and never considered inefficient enough to
[] : actually fix. And that's a bug in the implementation of perl, and should
[] : not be hold against a programmer of Perl.
[]
[] This one goes into the double-quoted static string category for me. It
[] works, the efficiency delta is minimal...and yet, when I'm reading code
[] (including my own) and see double-quotes, my predictive parser starts
[] scanning for the interpolation points, and has to do a backtrack if there
[] aren't any. Similarly, map makes me start thinking in terms of "Okay,
[] where will the resulting list go?", which must be abandoned when the void
[] context registers.
I don't see a reason to change my programming habits for your strange
parser. If you see a print, do you think "where will the resulting
value go"? As for strings, I am really baffled. Why on earth would you
backtrack? How do you read single quoted strings? If you read English,
do you do that letter by letter as well? I guess that use of qq or q
gives you a nervous break down. All those different delimiters! I hope
noone will ever tell you about autoquoted barewords. You'd experience
a brainmelt!
[] A lot of this stuff falls into the same more general category as e.g.
[] indenting your code, or including comments. Perl doesn't care, but *you*
[] will, or the maintenance programmer who comes after you.
If a programmer gets confused if there's no interpolation happening in
a double quoted string, then than programmer should not program.
BTW, don't tell me you ever do s/^\s+//;, you should of course be doing
s'^\s+'';. You wouldn't want to confuse the maintenance programmer, having
to backtrack a 4 character string for missing interpolation!
Abigail
--
$_ = "\x3C\x3C\x45\x4F\x54";
print if s/<<EOT/<<EOT/e;
Just another Perl Hacker
EOT
------------------------------
Date: 18 Jul 2000 06:10:03 GMT
From: cberry@cinenet.net.bbs@openbazaar.net (Craig Berry)
Subject: Re: how to convert "1.2.3.10" to "01020310"?
Message-Id: <3bRdUR$WOM@openbazaar.net>
Abigail (abigail@delanet.com) wrote:
: [] Nope. This is reasoned. map must accumulate results and build a list
: [] only to throw it away; for does not carry this overhead. As the two have
: [] roughly equal notational convenience, it makes sense to use the more
: [] efficient choice.
:
: map, of course, doesn't have to. Every other function in Perl is able
: to figure out its context, and act accordingly. I've never heard any
: convincing argument (in fact, I've never heard any argument) why map
: has to build a list regarding of its context. The fact that map does is
: a bug in perl. In perl that is, not in Perl. There's no reason to avoid
: map in Perl. There is a reason to fix the implementation of map in perl
: though. However, it has been known for a long, long time, but hasn't been
: found important enough to fix.
Of course. And more important, the efficiency argument is far less
central than the documentation-of-intent argument. foreach communicates
an intention to operate purely for side effects; map communicates an
intention to operate functionally. Speaking as someone who has had to
maintain a *lot* of old code (my own included), I state with some force:
The more you can do through coding conventions (applied fairly uniformly,
if informally) to make your code easy to eyeball-parse, the easier your
job will be when you're trying to brush aside the cobwebs a year from now.
: I don't see a reason to change my programming habits for your strange
: parser. If you see a print, do you think "where will the resulting
: value go"? As for strings, I am really baffled. Why on earth would you
: backtrack? How do you read single quoted strings? If you read English,
: do you do that letter by letter as well? I guess that use of qq or q
: gives you a nervous break down. All those different delimiters! I hope
: noone will ever tell you about autoquoted barewords. You'd experience
: a brainmelt!
Reductio ad absurdem won't get you far. I'm not saying I can't read any
arbitrary odd use of Perl syntax, nor that I apply a uniform and
mechanical rule requiring e.g. checking of print's return value. I *am*
saying that I take the easy "eyeball parser optimizations" -- things like
choosing quote syntax and map vs. foreach based on intended use -- as
consistently as I can managed. Even if I save only a tenth of a second of
brain processing per line of code read, that still adds up to a long lunch
on Friday. :)
: [] A lot of this stuff falls into the same more general category as e.g.
: [] indenting your code, or including comments. Perl doesn't care, but *you*
: [] will, or the maintenance programmer who comes after you.
:
: If a programmer gets confused if there's no interpolation happening in
: a double quoted string, then than programmer should not program.
I think perhaps you're picturing me coming to a screeching halt, jaw
hanging slack as I stare dumbfounded at the interplation-free dquoted
string. It's more like a flash of mental setup followed instants later by
a flash of self-correction. I see e.g.
$foo = "Here's a very &//? long and sym&^bol-\$rich string blah blah!";
deep inside the program somewhere. I can't grok that string all at once,
so I prepare to scan it for stuff of interest. Being double-quoted, I'm
looking for the whole family of escapes, plus interpolations. At the same
time, I'm forming hypotheses about what $foo might be used for just below,
what variables might be important that were mentioned right above, and how
they might help build $foo. Then I actually scan the string, find it
could have been single-quoted, and change my model to fit the '$foo starts
off as a statically-defined string' reality. All of this goes on in an
instant, without conscious effort, since I've been doing this for a while.
But it *does* take a tiny bit more work and time than would be the case if
the string were single-quoted. And tiny bits add up.
: BTW, don't tell me you ever do s/^\s+//;, you should of course be doing
: s'^\s+'';. You wouldn't want to confuse the maintenance programmer, having
: to backtrack a 4 character string for missing interpolation!
Again, reductio ad absurdem. Oh, and I reserve the right to pick and
choose, too. :)
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Beauty and strength, leaping laughter and delicious
| languor, force and fire, are of us." - Liber AL II:20
------------------------------
Date: 18 Jul 2000 08:00:12 GMT
From: abigail@delanet.com.bbs@openbazaar.net (Abigail)
Subject: Re: how to convert "1.2.3.10" to "01020310"?
Message-Id: <3bRgOH$V8Q@openbazaar.net>
Craig Berry (cberry@cinenet.net) wrote on MMDXIII September MCMXCIII in
<URL:news:sn7t63sno53115@corp.supernews.com>:
-- Abigail (abigail@delanet.com) wrote:
-- : [] Nope. This is reasoned. map must accumulate results and build a list
-- : [] only to throw it away; for does not carry this overhead. As the two hav
-- : [] roughly equal notational convenience, it makes sense to use the more
-- : [] efficient choice.
-- :
-- : map, of course, doesn't have to. Every other function in Perl is able
-- : to figure out its context, and act accordingly. I've never heard any
-- : convincing argument (in fact, I've never heard any argument) why map
-- : has to build a list regarding of its context. The fact that map does is
-- : a bug in perl. In perl that is, not in Perl. There's no reason to avoid
-- : map in Perl. There is a reason to fix the implementation of map in perl
-- : though. However, it has been known for a long, long time, but hasn't been
-- : found important enough to fix.
--
-- Of course. And more important, the efficiency argument is far less
-- central than the documentation-of-intent argument. foreach communicates
-- an intention to operate purely for side effects; map communicates an
-- intention to operate functionally. Speaking as someone who has had to
-- maintain a *lot* of old code (my own included), I state with some force:
-- The more you can do through coding conventions (applied fairly uniformly,
-- if informally) to make your code easy to eyeball-parse, the easier your
-- job will be when you're trying to brush aside the cobwebs a year from now.
Where is this "intent" defined? Or is this arbirary, just as using
tr/// to remove letters, and y/// to remove digits?
I find these "intent" arguments not very convincing, but if you really
want Python, you know where to get it.
But, for me, the intent of map is to mainly apply a function to each
element of a list. Whether that function has a side effect or not is
irrelevant. map {printf "%02d" => $_} @array couldn't be clearer.
-- : I don't see a reason to change my programming habits for your strange
-- : parser. If you see a print, do you think "where will the resulting
-- : value go"? As for strings, I am really baffled. Why on earth would you
-- : backtrack? How do you read single quoted strings? If you read English,
-- : do you do that letter by letter as well? I guess that use of qq or q
-- : gives you a nervous break down. All those different delimiters! I hope
-- : noone will ever tell you about autoquoted barewords. You'd experience
-- : a brainmelt!
--
-- Reductio ad absurdem won't get you far.
Reduction ad absurdem is an important, and often beautiful, technique
when proving theorems. I wouldn't want to leave home without it.
-- I'm not saying I can't read any
-- arbitrary odd use of Perl syntax, nor that I apply a uniform and
-- mechanical rule requiring e.g. checking of print's return value. I *am*
-- saying that I take the easy "eyeball parser optimizations" -- things like
-- choosing quote syntax and map vs. foreach based on intended use -- as
-- consistently as I can managed. Even if I save only a tenth of a second of
-- brain processing per line of code read, that still adds up to a long lunch
-- on Friday. :)
--
-- : [] A lot of this stuff falls into the same more general category as e.g.
-- : [] indenting your code, or including comments. Perl doesn't care, but *you*
-- : [] will, or the maintenance programmer who comes after you.
-- :
-- : If a programmer gets confused if there's no interpolation happening in
-- : a double quoted string, then than programmer should not program.
--
-- I think perhaps you're picturing me coming to a screeching halt, jaw
-- hanging slack as I stare dumbfounded at the interplation-free dquoted
-- string.
That's how you describe yourself, yes. And complaining a FOUR character
string which was double quoted only confirms that impression.
-- It's more like a flash of mental setup followed instants later by
-- a flash of self-correction. I see e.g.
--
-- $foo = "Here's a very &//? long and sym&^bol-\$rich string blah blah!";
--
-- deep inside the program somewhere. I can't grok that string all at once,
-- so I prepare to scan it for stuff of interest. Being double-quoted, I'm
-- looking for the whole family of escapes, plus interpolations. At the same
-- time, I'm forming hypotheses about what $foo might be used for just below,
Really? I'd say that if you need to analyze the content of a string to see
what it is being used for, something is wrong. Context, variable name, or
even comment should make it clear.
I also find it utterly amazing that while someone can't grasp the
string
"Here's a very &//? long and sym&^bol-\$rich string blah blah!",
all at once, he apparently *can* grasp
'Here\'s a very &//? long and sym&^bol-$rich string blah blah!'
all at once. After all, if one can't, it would not matter what quotes are
used, would it?
Me, I would look at the first string, see there's no interpolation
going on, so I wouldn't care at all what the quotes are. As for the
single quotes form, I'd probably think "hmmm, $rich isn't a variable,
oh, that's ok, it's single quoted anyway".
-- what variables might be important that were mentioned right above, and how
-- they might help build $foo. Then I actually scan the string, find it
-- could have been single-quoted, and change my model to fit the '$foo starts
-- off as a statically-defined string' reality. All of this goes on in an
-- instant, without conscious effort, since I've been doing this for a while.
-- But it *does* take a tiny bit more work and time than would be the case if
-- the string were single-quoted. And tiny bits add up.
You picked an interesting example as "counter argument", as the funny
string contains a single quote.
-- : BTW, don't tell me you ever do s/^\s+//;, you should of course be doing
-- : s'^\s+'';. You wouldn't want to confuse the maintenance programmer, having
-- : to backtrack a 4 character string for missing interpolation!
--
-- Again, reductio ad absurdem. Oh, and I reserve the right to pick and
-- choose, too. :)
Tell me, which of your arguments you use to promote single quotes when no
interpolation takes place, while reserving double quotes only when there's
interpolation, doesn't apply to s///?
Abigail
--
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
------------------------------
Date: 17 Jul 2000 14:50:01 GMT
From: jong@ebi.ac.uk.bbs@openbazaar.net (J. H. Park)
Subject: How to get the machine (archtechture) type in Perl?
Message-Id: <3bRFWP$Ubx@openbazaar.net>
**** Post for FREE via your newsreader at post.usenet.com ****
Hi
I want to tell if the machine I am in
is a LINUX or SGI IRIX.
Is there an easy way to do so in Perl?
Or is there Shell variable already
defined?
Thanks,
Jong
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
*** Usenet.com - The #1 Usenet Newsgroup Service on The Planet! ***
http://www.usenet.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
------------------------------
Date: 17 Jul 2000 14:50:01 GMT
From: nvp@spamnothanks.speakeasy.org.bbs@openbazaar.net (NP)
Subject: Re: How to get the machine (archtechture) type in Perl?
Message-Id: <3bRFWQ$Ufw@openbazaar.net>
On Mon, 17 Jul 2000 16:55:27 +0100, J. H. Park <jong@ebi.ac.uk> wrote:
:
: I want to tell if the machine I am in
: is a LINUX or SGI IRIX.
Check the 'perlvar' man page.
--
Nate II
------------------------------
Date: 17 Jul 2000 22:40:03 GMT
From: abigail@delanet.com.bbs@openbazaar.net (Abigail)
Subject: Re: How to get the machine (archtechture) type in Perl?
Message-Id: <3bRRi5$UDp@openbazaar.net>
J. H. Park (jong@ebi.ac.uk) wrote on MMDXII September MCMXCIII in
<URL:news:39732C6F.F426A944@ebi.ac.uk>:
:) **** Post for FREE via your newsreader at post.usenet.com ****
:)
:) Hi
:)
:) I want to tell if the machine I am in
:) is a LINUX or SGI IRIX.
:)
:) Is there an easy way to do so in Perl?
:) Or is there Shell variable already
:) defined?
man perlvar
Abigail
--
perl -e '$_ = q *4a75737420616e6f74686572205065726c204861636b65720a*;
for ($*=******;$**=******;$**=******) {$**=*******s*..*qq}
print chr 0x$& and q
qq}*excess********}'
------------------------------
Date: 18 Jul 2000 01:30:03 GMT
From: tjla@guvfybir.qlaqaf.bet.bbs@openbazaar.net (Gwyn Judd)
Subject: Re: How to get the machine (archtechture) type in Perl?
Message-Id: <3bRWGS$X1w@openbazaar.net>
I was shocked! How could J. H. Park <jong@ebi.ac.uk>
say such a terrible thing:
>**** Post for FREE via your newsreader at post.usenet.com ****
>
>Hi
>
>I want to tell if the machine I am in
>is a LINUX or SGI IRIX.
>
>Is there an easy way to do so in Perl?
>Or is there Shell variable already
>defined?
print `uname`;
--
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
Reading is thinking with someone else's head instead of one's own.
------------------------------
Date: 18 Jul 2000 08:00:10 GMT
From: mariusz.lukasiewicz@lido-tech.net.bbs@openbazaar.net (Mariusz £)
Subject: Re: How to get the machine (archtechture) type in Perl?
Message-Id: <3bRgOA$UiJ@openbazaar.net>
--------------D38648BB314756FB6CD1FF41
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
perldoc Config
see example there ;-)
"J. H. Park" wrote:
> **** Post for FREE via your newsreader at post.usenet.com ****
>
> Hi
>
> I want to tell if the machine I am in
> is a LINUX or SGI IRIX.
>
> Is there an easy way to do so in Perl?
> Or is there Shell variable already
> defined?
>
> Thanks,
>
> Jong
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> *** Usenet.com - The #1 Usenet Newsgroup Service on The Planet! ***
> http://www.usenet.com
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
--
Rgds
Mariusz.
----------------------------------------------------------------
Mariusz £ukasiewicz Lido Mail: lukmar1@mail.lido-tech tel. ext 30
Lido Technology E-mail : mariusz.lukasiewicz@lido-tech.net
--------------D38648BB314756FB6CD1FF41
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<br>perldoc Config
<p>see example there ;-)
<br>
<p>"J. H. Park" wrote:
<blockquote TYPE=CITE>**** Post for FREE via your newsreader at post.usenet.com
****
<p>Hi
<p>I want to tell if the machine I am in
<br>is a LINUX or SGI IRIX.
<p>Is there an easy way to do so in Perl?
<br>Or is there Shell variable already
<br>defined?
<p>Thanks,
<p>Jong
<p>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
<br> *** Usenet.com - The #1 Usenet Newsgroup Service on The Planet!
***
<br>
<a href="http://www.usenet.com">http://www.usenet.com</a>
<br>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=</blockquote>
<pre>--
Rgds
Mariusz.
----------------------------------------------------------------
Mariusz £ukasiewicz Lido Mail: lukmar1@mail.lido-tech tel. ext 30
Lido Technology E-mail : mariusz.lukasiewicz@lido-tech.net</pre>
</html>
--------------D38648BB314756FB6CD1FF41--
------------------------------
Date: 17 Jul 2000 14:40:02 GMT
From: sebastien.cottalorda1@libertysurf.fr.bbs@openbazaar.net (Sébastien Cottalorda)
Subject: How to kill Win95 process
Message-Id: <3bRFK2$Tzj@openbazaar.net>
Hi all,
I manage to fork Win95 process, but now I've problem killing (or exiting) my
program.
I'd like that parent dies when child dies.
I've tried : waitpid($pid,0)
But it doesn't seem to work : the child ever die before parent in my
program.
I would like to know how my child can kill the parent (I didn't get getppid
works at yet).
Any clue is appreciate.
S2bastien
------------------------------
Date: 17 Jul 2000 08:50:02 GMT
From: is83024@cis.nctu.edu.tw.bbs@openbazaar.net (doco)
Subject: Re: how to make my program with csh
Message-Id: <3bR6ER$Va9@openbazaar.net>
Drew Simonis (care227@attglobal.net) ´£¨ì:
: doco wrote:
: > Drew Simonis (care227@attglobal.net) ´£¨ì:
: > I need to know "Redirect the standard output to a file" under PERL
: > using "csh" commands,not "sh".
: > Tell me in details,please. Thx.
: Perl uses sh when it executes external commands via any of the means
: I've specified. And besides, you shouldn't be trying to use csh
: syntax in Perl, thats backwards. If you are going to use Perl,
: USE it. You'll find Perl is much more powerfull than csh once you
: get a little more comfortable.
PERL FAQ8
How do I make my program run with sh and csh?
See the eg/nih script (part of the perl source distribution).
--
*
I can see through the star into your heart *¡@¡¯
So no mater where you are , it's never far
¡D . ¡@¡@ I hold you in my soul you always be
Here with me forever you must believe
I am wating¡@for you ¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡¯
I am wating for you in my heart.......
¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@ *.
------------------------------
Date: 17 Jul 2000 08:40:02 GMT
From: is83024@cis.nctu.edu.tw.bbs@openbazaar.net (doco)
Subject: Re: how to make my program with csh
Message-Id: <3bR623$UuM@openbazaar.net>
Drew Simonis (care227@attglobal.net) ´£¨ì:
Thank you.
--
*
I can see through the star into your heart *¡@¡¯
So no mater where you are , it's never far
¡D . ¡@¡@ I hold you in my soul you always be
Here with me forever you must believe
I am wating¡@for you ¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡¯
I am wating for you in my heart.......
¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@ *.
------------------------------
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 3716
**************************************