[18059] in Perl-Users-Digest
Perl-Users Digest, Issue: 219 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 5 21:05:42 2001
Date: Mon, 5 Feb 2001 18:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <981425111-v10-i219@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 5 Feb 2001 Volume: 10 Number: 219
Today's topics:
Re: "Average of List of Numbers" by Abigail (Martien Verbruggen)
Re: "Average of List of Numbers" by Abigail <mischief@velma.motion.net>
Re: "Average of List of Numbers" by Abigail <tore@extend.no>
Re: A Meta-Hack for your enjoyment (Martien Verbruggen)
A Meta-Hack, further explanation (motives and thoughts) (Clinton A. Pierce)
Re: getting line number n of a file <ccx138@coventry.ac.uk>
Re: getting line number n of a file (Craig Berry)
Re: getting line number n of a file (Abigail)
How to tell which Perl is running <lynn@swcp.com>
Is scalar a float, int or string? <occitan@esperanto.org>
Re: newbie - grep non-used uid from passwd jimjim123@my-deja.com
Re: newbie - grep non-used uid from passwd (Wyzelli)
Re: newbie: simple question on FTPing (David Efflandt)
non-English perl pluralization algorithm <jezebel_cries@my-deja.com>
Re: Params by .shtml (David Efflandt)
Re: Passwd and Shadow <ddunham@redwood.taos.com>
Re: Passwd and Shadow (Abigail)
Re: perl & expect - STDOUT vs. redirect to file <bogus@bogus.com>
Pros / Cons of upgrading from 5.005 to 5.6.0 <metaperl@MailAndNews.com>
Re: Radical readdir suggestion <iltzu@sci.invalid>
Reading the file again (Beginner) <shino_korah@yahoo.com>
Re: Reading the file again (Beginner) (Craig Berry)
Re: stupid eval tricks (Tarael200)
Re: This is driving me nuts and I need a guru <jdf@pobox.com>
Re: This is driving me nuts and I need a guru <gaverth@home.com>
trouble reopening file <Travis.Stevens@noaa.gov>
Re: trouble reopening file <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 06 Feb 2001 00:41:23 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: "Average of List of Numbers" by Abigail
Message-Id: <slrn97uhvf.64e.mgjv@verbruggen.comdyn.com.au>
On Mon, 05 Feb 2001 21:13:40 -0000,
Chris Stith <mischief@velma.motion.net> wrote:
> In comp.lang.perl.misc Terrence Brannon <brannon@lnc.usc.edu> wrote:
>
>> The Museum of Modern Programming is proud to present its first work:
>
>> "Average of List of Numbers" by Abigail.
>
>> The Museum of Modern Programming: http://www.momp.org
>
> on 5 February:
>
> $ nslookup www.momp.org
> Server: dns1.motion.net
> Address: 216.1.104.12
>
> *** dns1.motion.net can't find www.momp.org: Non-existent host/domain
$ nslookup
Default Server: wula.comdyn.com.au
Address: 172.18.240.18
> www.momp.org
Server: wula.comdyn.com.au
Address: 172.18.240.18
Non-authoritative answer:
Name: www.momp.org
Address: 209.132.1.73
> server dns1.motion.net
Default Server: dns1.motion.net
Address: 216.1.104.12
> www.momp.org
Server: dns1.motion.net
Address: 216.1.104.12
*** dns1.motion.net can't find www.momp.org: Query refused
Seems the problem is with your server.
Martien
--
Martien Verbruggen |
Interactive Media Division | In the fight between you and the
Commercial Dynamics Pty. Ltd. | world, back the world - Franz Kafka
NSW, Australia |
------------------------------
Date: Tue, 06 Feb 2001 00:48:15 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: "Average of List of Numbers" by Abigail
Message-Id: <t7uiefbtrlb68b@corp.supernews.com>
In comp.lang.perl.misc Chris Stith <mischief@velma.motion.net> wrote:
> In comp.lang.perl.misc Terrence Brannon <brannon@lnc.usc.edu> wrote:
>> The Museum of Modern Programming is proud to present its first work:
>> "Average of List of Numbers" by Abigail.
>> The Museum of Modern Programming: http://www.momp.org
[nameserver problem report snipped]
I have seen the page, and although I admit Abigail usually does
impress me (and does so to an extent with this example), I find it
hard to call the example "strikingly elegant".
Below is a threesome of ways to find averages in only a few
characters. It also includes a control. The first two are
written by me, and only need to have $avg preset to zero if
they are not the first assignment to it. The third is
Abigail's. Since the first does use more divisions, it does
build up more floating point imprescision and it shows this
when { @nums = (1..10000); } for example. The fourth set of
lines that figure average is the control for how to very
obviously do this.
If you call elegance a lack of length, then mine share that.
If you call elegance speed and clarity, then the control
wins hands down. If you call elegance a somewhat unusual
use of a feature, mine share that. My less precise method
is even shorter, including the presetting of the variable.
Granted, my methods are a little clunkier before the eyes,
since they require multiple statements. Still, though, can
you afford a 92% slowdown from the obvious implementation?
Is that elegance? Perhaps it's elegant because it is only
one statement (which could be arguable on some level
since it uses both do and eval)?
Like I mentioned earlier, Abigail's knowledge of the language
impresses me, including in this example. I doubt, though, that
Abigail herself would call her example "strikingly elegant".
Impressive in how it's done, perhaps. Impressive in its length
or its speed, no.
#!/usr/bin/perl -w
use strict;
my $avg;
my @nums = (1..10);
### less precise map()
### 11003.90 per second averaging 1..10
### 0.78 per second averaging 1..100_000
$avg = 0; map ($avg += ($_ / @nums) => @nums);
print $avg . "\n";
### more precise map()
### 17837.98 per second averaging 1..10
### 1.47 per second averaging 1..100_000
$avg = 0; map ($avg += $_ => @nums); $avg /= @nums;
print $avg . "\n";
### Abigail's do()
### 1929.00 per second averaging 1..10
### 0.31 per second averaging 1..100_000
$avg = do {local $" = "+"; (eval "@nums") / @nums};
print $avg . "\n";
### foreach() as control
### 24908.89 per second averaging 1..10
### 4.67 per second averaging 1..100_000
$avg = 0; foreach( @nums ) { $avg += $_; } $avg /= @nums;
print $avg . "\n";
Chris
--
Christopher E. Stith
Parking for people we like only. All other vehicles will be vandalized.
------------------------------
Date: Tue, 6 Feb 2001 01:55:48 +0100
From: Tore Aursand <tore@extend.no>
Subject: Re: "Average of List of Numbers" by Abigail
Message-Id: <MPG.14e969ffe837dc83989890@news.online.no>
In article <t7u5s4l8eanb69@corp.supernews.com>,
mischief@velma.motion.net says...
> *** dns1.motion.net can't find www.momp.org: Non-existent host/domain
Your DNS server - or the one your computer is configured to "talk" to -
haven't been updated with this domain name yet.
Try using http://lnc.usc.edu/~brannon/domains/momp.org/ instead, but
change back to www.momp.org when you know that it's working alright.
Disclaimer; I have nothing to do with www.momp.org, but I like the
site already. :)
--
Tore Aursand - tore@extend.no - http://www.extend.no/~tore/
------------------------------
Date: Tue, 06 Feb 2001 00:25:32 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: A Meta-Hack for your enjoyment
Message-Id: <slrn97uh1o.64e.mgjv@verbruggen.comdyn.com.au>
On Mon, 05 Feb 2001 13:09:55 GMT,
Bart Lateur <bart.lateur@skynet.be> wrote:
> Clinton A. Pierce wrote:
>
>>require 5.6; # We accept summer whenever it arrives
>
> In old style, make that 5.006. In the new style, you've already been
> corrected, but I'm not sure that version can even be compiled on older
> systems. Heh, it wopuld be funny if it couldn't!
Hmmm..
$ perl5.00503 -e 'require 5.006'
Perl 5.006 required--this is only version 5.00503, stopped at -e line 1.
$ perl5.00503 -e 'require 5.6.0'
Can't locate 5.60 in @INC (@INC contains:
/opt/perl5.00503/lib/5.00503/i686-linux /opt/perl5.00503/lib/5.00503
/opt/perl5.00503/lib/site_perl/5.005/i686-linux
/opt/perl5.00503/lib/site_perl/5.005 .) at -e line 1.
Heh... that's a good one indeed.
> This answers the question "Did he really spend his time figuring out how
> to puzzle together such a program?", but another question crops up
> instead: how did you get to the idea of the encrypting program?
I haven't looked too deeply at the source code, but it's a technique
commonly known as steganography, which is often applied to hiding
information in digital images or data streams. It's the first time
I've seen it applied to ascii art though :). Pretty cool.
Martien
--
Martien Verbruggen |
Interactive Media Division | Failure is not an option. It comes
Commercial Dynamics Pty. Ltd. | bundled with your Microsoft product.
NSW, Australia |
------------------------------
Date: Tue, 06 Feb 2001 01:40:50 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: A Meta-Hack, further explanation (motives and thoughts)
Message-Id: <CCIf6.282533$hD4.68487113@news1.rdc1.mi.home.com>
In article <slrn97uh1o.64e.mgjv@verbruggen.comdyn.com.au>,
mgjv@tradingpost.com.au (Martien Verbruggen) writes:
>> This answers the question "Did he really spend his time figuring out how
>> to puzzle together such a program?", but another question crops up
>> instead: how did you get to the idea of the encrypting program?
>
> I haven't looked too deeply at the source code, but it's a technique
> commonly known as steganography, which is often applied to hiding
> information in digital images or data streams. It's the first time
> I've seen it applied to ascii art though :). Pretty cool.
I'm never one to pass up a teaching opportunity, so here goes:
The thought process started with Skrewtape in #perl, when he asked in
channel about "finding the longest repeated substring in a string".
I came up with a quick answer, but he had already left. No-one saw it.
Someone repeated that query on the FWP mailing list and fun ensued.
I guess. I've been frustrated posting to the list so I'm not subscribed
anymore. But I came up with a solution myself: a shorter version of
what now appears as longest().
And I sat on that. Filed it away.
Then someone posted to perlmonks.org a tree-like thing that printed
the standard JAPH message. It was okay, but he used code for the
tree-like thing. Messy. And it looked lollipop-ish.
That bugged me.
And it bugged me more. Why didn't he draw the tree with something less
blocky? Well, long keywords would look blocky, so a tree of code won't
work. What about just leaf-like characters? Airy things like {} and []?
Sure. Personally I thought:
'MULTILINE STUFF IN HERE'=~m/(.*)/s;$_=$1;
Was cool so that the message could appear before any perl code. Okay,
that solves the problem of the leafy tree. The trunk can be the decoder,
the tree will hold the message.
Slept on it.
Went to endless meetings on Thursday. Bad day.
Went to endless meetings on Friday. Took my laptop. Hacked when I should
have been listening. Much better day for me.
I wanted the message encoded so I thought: octal, hex, binary, decimal.
I couldn't find 16 "airy" characters that didn't conflict with the branch-
building characters (which I thought were necessary to keep it from being
a lollipop). And I couldn't use the branch-building characters as part of
the message. No hex. Couldn't really find 8 either -- no octal. Binary?
Sure, but encoding "I think I shall never..." in binary is 488
characters long. I can make leaves out of <> and {} though. They look
nice but the tree is ENORMOUS.
I thought about run-length encoding. 0's and 1's would compress nicely
that way. But the decoding would have needed more code, but I wouldn't
have needed %e. (Future hack for someone else? :).
Then I remembered Skrewtape's question.
Compressed the data one way and it dropped to 263 characters. Not bad.
Tinkered a bit, got better compression. Encoded the data into <> {} and
a few other characters.
Drew the tree freehand. That sucked. Making sure I took all of the right
characters out of the encoded string and one-by-one putting them on the
tree left-to-right, top-to-bottom. So I just used a substitute character
to draw the tree and then "patched" it. (The "#Now encode the top" part.)
Posted to perlmonks.com and comp.lang.perl.misc. Rave reviews. Some nice
e-mail too. (Thanks! :) The usual stupid sub-threads on clpm with no code
and just complaints. Life goes on I guess.
And lots of questions on..."gee how'd you do that?"
The original program, with all of my "exit;" statements is at:
http://geeksalad.org/typi24h/tree.txt
Read it from the bottom up to see the evolution of the process.
I thought..."ya know, this can be generalized to do this to ANY ASCII
art."
So I went back, cleaned up the routines I was using. longest() now tried
a couple of different solutions, whereas I chose by hand before. Changed
the tree encoder to tell you when you used too much of one or not enough
of the other. Documented.
Found another ASCII picture, encoded a small message. Made a self-
explanatory demo out of it. Tested it. [Being bugged to go to the movies]
Remembered the "Use 5.6!" "5.6 isn't any good!" rant in c.l.p.m..
[Being bugged to leave...have to post this now though!] Added the
"require 5.6" line. Posted it. Left for the movies.
Got there and said "DOH!" when I remembered that needed to be 5.6.0. :)
I'm just glad the warning Perl issues for that is idiot-proof.
--
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: Mon, 05 Feb 2001 22:51:40 +0000
From: John Tutchings <ccx138@coventry.ac.uk>
Subject: Re: getting line number n of a file
Message-Id: <3A7F2E7B.D8F0EC34@coventry.ac.uk>
On unix you can
head -4 file |tail -1
so you could backtick it.
Craig Berry wrote:
> Andre Bonhote (andre.bonhote@linux.ch) wrote:
> : do you know a way to get eg. line number four of a file without too much
> : code?
>
> For files short enough to fit into memory, and from which you don't want
> any other lines,
>
> $line4 = (<FILE>)[3];
>
> is probably about as short as you can get.
>
> --
> | Craig Berry - http://www.cinenet.net/~cberry/
> --*-- "When the going gets weird, the weird turn pro."
> | - Hunter S. Thompson
------------------------------
Date: Tue, 06 Feb 2001 00:52:09 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: getting line number n of a file
Message-Id: <t7uilp99ci2jfa@corp.supernews.com>
John Tutchings (ccx138@coventry.ac.uk) wrote:
: On unix you can
: head -4 file |tail -1
: so you could backtick it.
Shelling out is normally excluded from golf tournaments. Otherwise
anybody could claim that their FooQuuxShell featured a builtin 'q' command
that returned the fourth line of its argument, and who could argue?
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "When the going gets weird, the weird turn pro."
| - Hunter S. Thompson
------------------------------
Date: 6 Feb 2001 01:43:00 GMT
From: abigail@foad.org (Abigail)
Subject: Re: getting line number n of a file
Message-Id: <slrn97ull4.sk5.abigail@tsathoggua.rlyeh.net>
Craig Berry (cberry@cinenet.net) wrote on MMDCCXVI September MCMXCIII in
<URL:news:t7uilp99ci2jfa@corp.supernews.com>:
!! John Tutchings (ccx138@coventry.ac.uk) wrote:
!! : On unix you can
!! : head -4 file |tail -1
!! : so you could backtick it.
!!
!! Shelling out is normally excluded from golf tournaments. Otherwise
!! anybody could claim that their FooQuuxShell featured a builtin 'q' command
!! that returned the fourth line of its argument, and who could argue?
FooQuuxShell isn't a "standard" Unix command; head and tail are.
For most commands, it's quite clear whether they are "standard Unix",
or not.
Abigail
--
BEGIN {$^H {q} = sub {$_ [1] =~ y/S-ZA-IK-O/q-tc-fe-m/d; $_ [1]}; $^H = 0x28100}
print "Just another PYTHON hacker\n";
------------------------------
Date: Mon, 05 Feb 2001 17:11:47 -0700
From: Lynn Wilson <lynn@swcp.com>
Subject: How to tell which Perl is running
Message-Id: <3A7F4143.9158ED5F@swcp.com>
I want to write some perl scripts that will run under ActiveState (launched from a DOS shell) and under the /usr/local/bin/perl in a Cygwin environment. The ActiveState doesn't understand that a '/c/program files/path' is the same as the 'c:/program files/path' that it understands.
Cygwin contains a built-in 'cygpath' function that will convert between the two but how do I know when to call it?
Is there a $Variable that will tell me the name of the perl that I'm running under (not $] $PERL_VERSION which only tells me 5.006 etc.)?
Thanks.
Lynn
------------------------------
Date: Mon, 05 Feb 2001 23:39:35 GMT
From: Daniel Pfeiffer <occitan@esperanto.org>
Subject: Is scalar a float, int or string?
Message-Id: <95ndjm$ps9$1@nnrp1.deja.com>
Saluton Retanoj!
When treating a number passed in as a scalar, I need to do nothing if it
is an int, split it up if it is a float, transform it and possibly split
it up if it is a string. Question is, how can I tell what it is _very_
efficiently, i.e. without potentially casting it to a string and then
parsing that.
Background is that I am currently rewriting Math::BigInt, which was
lousy and has now become faster by a varying (enormous in some cases)
factor. And I need this for an optimal "new" method.
I hope Perl doesn't completely hide this from me! But I am absolutely
clueless how to find out!
-- Daniel
--
Bring text-docs to life! Erwecke Textdokumente zum Leben!
http://beam.to/iPerl/
Vivigu tekstodokumentojn!
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 05 Feb 2001 23:51:31 GMT
From: jimjim123@my-deja.com
Subject: Re: newbie - grep non-used uid from passwd
Message-Id: <95nea1$qeu$1@nnrp1.deja.com>
What you could do is grab each uid from the /etc/passwd into a list or
array with split, then sort the list/array. Then, step thru the list
until the current element does not equal the last element + 1....
That's kinda easy, but kinda processor intensive. I'd be keen to see a
more elegant/less processor intensive solution.
Cheers!
Hamish Rickerby.
> Is possible to grep from my /etc/passwd the 1st non-used uid in
> range from 100 to 999?
>
> ex:
> user1:x:100:100:....
> user2:x:101:100:....
> user3:x:102:100:....
> user4:x:106:100:....
> user5:x:107:100:....
> user6:x:108:100:....
>
> In this example is 1st non-used uid '103' ...
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 06 Feb 2001 01:15:05 GMT
From: wyzelli@yahoo.com (Wyzelli)
Subject: Re: newbie - grep non-used uid from passwd
Message-Id: <Xns9040666C1wyzelliyahoocom@203.39.3.131>
"- = k o l i s k o = -" <kolisko@penguin.cz> wrote in
<3a7ed39c$1@news.cvut.cz>:
>Hello!
>
>I am newbie to perl.
>
>Is possible to grep from my /etc/passwd the 1st non-used uid in
>range from 100 to 999?
>
>ex:
>user1:x:100:100:....
>user2:x:101:100:....
>user3:x:102:100:....
>user4:x:106:100:....
>user5:x:107:100:....
>user6:x:108:100:....
>
>In this example is 1st non-used uid '103' ...
>
Here is a short working example of one way to address this type of issue.
You will need to handle the modifications to read from the actual file. Note
that the regex is pretty loose, but may be tightened up depending on your real
data. (I don't have an /etc/passwd to play with here)
#!/usr/bin/perl -w
use strict;
my @uids = ();
while (<DATA>){ # modify to read from file
push @uids, $1 if m/.*:.*:(\d+):.*:.*/; # grab uids
}
@uids = sort @uids; # ensure uids are sorted
my $newuid = $uids[0]; # set to comparison to match first uid
foreach my $uid (@uids) {
unless ($newuid == $uid){
print $newuid; # print the first one that doesn't match
last;
}
$newuid++; # increment the comparison
}
__END__
user1:x:100:100:....
user2:x:101:100:....
user4:x:106:100:....
user5:x:107:100:....
user6:x:108:100:....
user3:x:102:100:....
Note that I changed the order of the sample data to ensure the sort was needed.
If you know your data is always in numeric order the sort may not be so
necessary, but I think better safe than sorry.
Wyzelli
--
#beer v2
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";
------------------------------
Date: Tue, 6 Feb 2001 01:20:29 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: newbie: simple question on FTPing
Message-Id: <slrn97uk99.7mi.efflandt@efflandt.xnet.com>
On Sun, 04 Feb 2001 17:58:25 GMT, Boris Golub <bgolub@student.math.hr> wrote:
>What is the best way to write a simple perl script that tries to fetch
>a file from a host and
>
>1. there is a time limit to establishing a connection with host
>2. number of tries is also limited
perldoc Net::FTP
Or if that does not tell you anything, install the 'libnet' package of
modules, which includes it.
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Tue, 06 Feb 2001 00:29:50 GMT
From: Jezebel <jezebel_cries@my-deja.com>
Subject: non-English perl pluralization algorithm
Message-Id: <95nghk$sf7$1@nnrp1.deja.com>
I'm looking for a perl implementation of a non-english pluralization
algorithm, something along the lines of Lingua::EN:Inflect... but for
western european languages like Spanish, French & Danish. Does anyone
know of something like this freely available?
Thanks in advance,
Jez
--
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 6 Feb 2001 01:25:11 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Params by .shtml
Message-Id: <slrn97uki3.7mi.efflandt@efflandt.xnet.com>
On Tue, 6 Feb 2001 00:04:55 +0300, Punches <punches@zlob.net.ru> wrote:
>How to pass parametrs to perl-script using shtml-document?
>
>It must look like this:
>
>http://coolsite.com/main.shtml?param1=value1¶m2=value2
This is not a Perl question. For apache go to http://www.apache.org/ and
lookup mod_include in the server docs. Pay particular attention to what
it says about the difference between "exec cgi" and "include virtual"
regarding query string.
Or for other servers, consult the docs for your web server.
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Mon, 05 Feb 2001 23:46:19 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: Passwd and Shadow
Message-Id: <fXGf6.30$qv1.86525@news.pacbell.net>
Stuart Lowes <stuart@zerostate.co.uk> wrote:
> Hi
> I am writing a web interface for user admin and other things, like apache on
> a solaris box. I am learning perl and unix as I go for my final year degree
> project.
> Can anyone suggest good ways of modifying the passwd and shadow files as
> well as the other obvious admin files.
There's no common method for doing so across all systems.
> I have found in my research the shadow module, has anyone used it and is it
> any good and does it get round the permissions problems?
Generally the permissions on /etc/shadow are not considered a "problem",
and I doubt it could "get around it". Which module are you referring
to? I did a search on cpan for "shadow" and only got two hits. I did
see CfgTie::TieShadow, but it doesn't appear to do any type of file
locking. As such, I imagine it would have race conditions when used for
modifications.
--
Darren Dunham ddunham@taos.com
Unix System Administrator Taos - The SysAdmin Company
Got some Dr Pepper? San Francisco, CA bay area
< Please move on, ...nothing to see here, please disperse >
------------------------------
Date: 6 Feb 2001 01:53:14 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Passwd and Shadow
Message-Id: <slrn97um8a.sk5.abigail@tsathoggua.rlyeh.net>
Darren Dunham (ddunham@redwood.taos.com) wrote on MMDCCXV September
MCMXCIII in <URL:news:fXGf6.30$qv1.86525@news.pacbell.net>:
,, Stuart Lowes <stuart@zerostate.co.uk> wrote:
,, > Hi
,,
,, > I am writing a web interface for user admin and other things, like apache o
,, > a solaris box. I am learning perl and unix as I go for my final year degre
,, > project.
,,
,, > Can anyone suggest good ways of modifying the passwd and shadow files as
,, > well as the other obvious admin files.
,,
,, There's no common method for doing so across all systems.
And besides that, if you have to ask how to modify such important
files, YOU SHOULD NOT BE DOING SO.
You wouldn't let one tinker with your internal organs after (s)he
asks how to do so, now would you?
(I've yet to find a Solaris (or some other non-Linux Unix admin) who
wants to admin his/her boxes with a web wowser.)
Adminning Unix boxes is a non-trivial task, which should be left to
experienced people, not someone new to Unix, writing a web wowser
interface in a language (s)he is new to. That's a garantee for disaster.
,, > I have found in my research the shadow module, has anyone used it and is it
,, > any good and does it get round the permissions problems?
,,
,, Generally the permissions on /etc/shadow are not considered a "problem",
,, and I doubt it could "get around it".
If you can get "around them", your system has a security problem.
Permission weren't invented to annoy the (l)users (oh, I'd wish!),
but they have an actual use.
To get to the information in /etc/shadow, you'd need superuser privs.
Only fools would run a CGI program with superuser privs. (Hello, skr1p+ k1ddoz!)
Abigail
--
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'
------------------------------
Date: Mon, 05 Feb 2001 17:19:36 -0600
From: Perl User <bogus@bogus.com>
Subject: Re: perl & expect - STDOUT vs. redirect to file
Message-Id: <3A7F3508.876BBBEB@bogus.com>
This worked!
Thanks. I had used $AUTOFLUSH thinking that it was the same
as $|++. Guess not.
Thanks again,
MJB
bits101010@my-deja.com wrote:
>
> Try adding $|++; to both programs.
>
> Sent via Deja.com
> http://www.deja.com/
------------------------------
Date: Mon, 5 Feb 2001 18:54:27 -0500
From: Terrence Brannon <metaperl@MailAndNews.com>
Subject: Pros / Cons of upgrading from 5.005 to 5.6.0
Message-Id: <3A7F6AC1@MailAndNews.com>
The new company I am at is running Perl 5.005 and I have to deal with the
problems that release had:
- perl Makefile.PL PREFIX=$PREFIX doesn't set the man3 prefix correctly
- no 'our' available.
And I am not sure what else.
Would someone mind telling what risks are involved in such an upgrade?
I checked the Perl FAQ on this and found what appears to be out of date
information:
Which version of Perl should I use?
You should definitely use version 5. Version 4 is old, limited, and no
longer maintained; its last patch (4.036) was in 1992, long ago and far
away.
Sure, it's stable, but so is anything that's dead; in fact, perl4 had been
called a dead, flea-bitten camel carcass. The most recent production
release is 5.005_03 (although 5.004_05 is still supported). The most
cutting-edge development release is 5.005_57. Further references to the Perl
language in this document refer to the production release unless
otherwise specified. There may be one or more official bug fixes by the time
you read this, and also perhaps some experimental versions on the way to the
next release. All releases prior to 5.004 were subject to buffer
overruns, a grave security issue.
------------------------------------------------------------
Get your FREE web-based e-mail and newsgroup access at:
http://MailAndNews.com
Create a new mailbox, or access your existing IMAP4 or
POP3 mailbox from anywhere with just a web browser.
------------------------------------------------------------
------------------------------
Date: 6 Feb 2001 00:16:40 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Radical readdir suggestion
Message-Id: <981417544.13640@itz.pp.sci.fi>
In article <t7u8mcejgcbhb0@corp.supernews.com>, Chris Stith wrote:
>
>Those directory entries should show up on systems that have them.
>The programmer can take steps such as checking $^O to see whether
>or not '.' and '..' should be treated specially.
Urgh. I sort of thought the point of high-level languages, and Perl
specifically, was to make programming easier, not harder. At least if
I was writing in C, I could check it during the build process and then
not have to worry about it.
I also think there's a small but fundamental error in the paragraph
you wrote -- it's not "can", but "must".
>If we make it so that Unix/Linux and DOS/Windows can't see their
>special directory entires, what's next? Do we make Perl itself
>translate between short and long filenames on Microsoft's
>operating systems?
No need, works fine as is, no special handling required.
>Do we make Perl find a way to differentiate between pipes and regular
>files on systems with broken file systems that don't report the
>difference?
Perhaps. Depends on whether it'd be worth the effort. We already
have a heuristic test for binary/text files on platforms that don't
actually support such metadata.
>Should Perl automatically know, without the ability to use binmode(),
>that it needs to adjust or not adjust the OS and FS ideas about line
>endings?
And here I thought that the point of binmode() is precisely that, as
long as you use it to tell Perl which kind of a file you're expecting,
Perl will give you what you want regardless of the underlying details.
Obviously I must've been completely wrong..
(Hmm.. actually, this is how it should be implemented. binmode() for
dirhandles. Ask for child links only, and "." / ".." won't be among
the entries. You could also ask only for visible files, which would
omit dotfiles under Unix and hidden-flagged files under DOS.)
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"I've never run across any Medieval Welsh slash fiction, although I suppose
I could try writing some" -- Heather Rose Jones in rec.arts.sf.composition
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Mon, 5 Feb 2001 16:40:09 -0800
From: "terminalsplash" <shino_korah@yahoo.com>
Subject: Reading the file again (Beginner)
Message-Id: <95nh5a$8jk@news.or.intel.com>
Hi
In perl if i have to read the file more than once should i reopen it all the
time?
is there a way to get over it ?
------------------------------
Date: Tue, 06 Feb 2001 01:08:25 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Reading the file again (Beginner)
Message-Id: <t7ujk9375v7uf4@corp.supernews.com>
terminalsplash (shino_korah@yahoo.com) wrote:
: In perl if i have to read the file more than once should i reopen it
: all the time? is there a way to get over it ?
Your options are:
* If the file is small, read it into an array once, and iterate over the
array as needed.
* Use seek() to reset the read pointer to the beginning of the file when
desired.
* Close and reopen the file when you wish to reread it.
The first option is most flexible -- you have true random access to the
array of lines from the file. But be careful if you need to work with
huge files which might fill memory.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "When the going gets weird, the weird turn pro."
| - Hunter S. Thompson
------------------------------
Date: 06 Feb 2001 00:23:45 GMT
From: tarael200@aol.com (Tarael200)
Subject: Re: stupid eval tricks
Message-Id: <20010205192345.06374.00000715@ng-cv1.aol.com>
Ahh, you could just do eval("\"$string\"");
.. that's what I've used before instead of the intermediate variable..
-Malander
"Intermediate variables are for wussies!"
------------------------------
Date: 05 Feb 2001 18:14:14 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: This is driving me nuts and I need a guru
Message-Id: <lmrkiuyh.fsf@pobox.com>
"John W" <jwgws@hotZEROSPAMmail.com> writes:
> It's not even like I'm a newsgroup newbie. This is the first
> newsgroup I've run across (of many I've participated in) where
> "Jeopardy-style" was such an "issue" it had a name. And a knee-jerk
> reaction.
Notwithstanding your experience elsewhere, that's how it is here! It
comes from years of experience of "gimme gimme" attitude from people
who don't know any better. Because that type of behavior is
correlated with other, quantifiable (by gnus scorefiles) phenomena,
those phenomena are selected against.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Tue, 06 Feb 2001 01:39:22 GMT
From: "Tim Gaverth" <gaverth@home.com>
Subject: Re: This is driving me nuts and I need a guru
Message-Id: <eBIf6.70157$B6.17911130@news1.rdc1.md.home.com>
John W <jwmsng@greatNOSPAMwebsolutions.com> wrote in message
news:3a7ed27a_3@goliath2.newsfeeds.com...
> > "" my $dbh = $self->{'dbh'}; #this is inherited
> > "" my $query = (
> > "" "select fieldone, fieldtwo ",
> > "" "from db1..table1 ",
> > "" "where crit = value ",
> > "" );
> >
> > A print $query would help. -w would have told you so.
>
> Mmm. Problem here. Is this indeed close to the actual code?
>
> JW
>
Well, now that I understand the Jeopardy issue, I'll make sure that doesn't
happen again.
Anyway John, yes that's close to the actual.
Also, I think I tracked down the underlying problem today, and fixed it. I
should know for sure
tomorrow when I get my hands on my on-site logs, if so, thanks for all the
schooling.
------------------------------
Date: Mon, 05 Feb 2001 17:18:28 -0700
From: Travis Stevens <Travis.Stevens@noaa.gov>
Subject: trouble reopening file
Message-Id: <3A7F42D4.356422FC@noaa.gov>
--------------1BA42D3A1DC2CD2012D9431C
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
hi,
well, basically here is my problem.
I am opening a file with open(IN,"<$filename[$i]");
i do a :while (<IN>){stuff}
I read till the end of this file then: close(IN);
I want to read this file again, so I: open(IN,"<$filename[$i]");
then i do a while(<IN>){
but at this point, i print ("line:$_\n");
and $_ is empty. I've double, triple checked my code, and I feel I am
doing what I'm supposed to be doing.
any ideas?
Trav
my actual source code:
for ($i=0;$i<$nfiles;$i++){
$maxlat = -2000;
$maxlon = -2000;
$minlat = 2000;
$minlon = 2000;
$numpoints=0;
open (IN,"<$fnames[$i]");
while (<IN>){
chomp;
($nu,$nu,$nu,$nu,$id,$lat,$lon,$nu,$nu) = split(/\^/,$_,9);
if ($lat>$maxlat){
$oldmaxlat=$maxlat;
$maxlat=$lat;
}
if ($lat<$minlat){
$oldminlat=$minlat;
$minlat=$lat;
}
if ($lon>$maxlon){
$oldmaxlon=$maxlon;
$maxlon=$lon;
}
if ($lon<$minlon){
$oldminlon=$minlon;
$minlon=$lon;
}
$numpoints++;
}
close(IN);
open (ERR,">$id.err");
#we will open the file again, this time checking to see if
#if the whole world should be shown, or just the edges
if ($maxlon > 90 && $minlon <-90 && $numpoints>1){
$maxlon2=-2000;
$minlon2=2000;
print ERR "doing update lat lon\n";
$showall=0; #if there is a point between -90 and 90, then showall
print ERR "opening file name: $fnames[$i]\n";
open (IN,"<$fnames[$i]") || die "can't open $fnames[$i]\n";
while (<IN> && !$showall){
print ERR "line:$_\n"; #ERROR, $_ is empty!
chomp;
($nu,$nu,$nu,$nu,$nu,$lat,$lon,$nu,$nu) = split(/\^/,$_,9);
if ($lon < 90 && $lon > -90){
$showall=1;
print ERR "show all is true because lon:$lon\n";
}
else {
if ($lon < -90 && $lon >$maxlon2){
$maxlon2 = $lon;
}
if ($lon > 90 && $lon < $minlon2){
$minlon2 = $lon;
}
}
if (!showall){
print ERR "changing lon's to minlon:$minlon2:max:$maxlon2\n";
$minlon=$minlon2;
$maxlon=$maxlon2;
}
}
}
close (IN);
--------------1BA42D3A1DC2CD2012D9431C
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
hi,
<p>well, basically here is my problem.
<br>I am opening a file with <b>open(IN,"<$filename[$i]");</b>
<br>i do a :<b>while (<IN>){stuff}</b>
<br>I read till the end of this file then:<b> close(IN);</b>
<br>I want to read this file again, so I: <b>open(IN,"<$filename[$i]");</b>
<br>then i do a <b>while(<IN>){</b>
<br>but at this point, i <b>print ("line:$_\n");</b>
<br>and $_ is empty. I've double, triple checked my code, and I feel
I am doing what I'm supposed to be doing.
<br>any ideas?
<p>Trav
<p>my actual source code:
<br>
<br>
<p>for ($i=0;$i<$nfiles;$i++){
<br> $maxlat = -2000;
<br> $maxlon = -2000;
<br> $minlat = 2000;
<br> $minlon = 2000;
<br> $numpoints=0;
<br> open (IN,"<$fnames[$i]");
<br> while (<IN>){
<br> chomp;
<br> ($nu,$nu,$nu,$nu,$id,$lat,$lon,$nu,$nu)
= split(/\^/,$_,9);
<br> if ($lat>$maxlat){
<br> $oldmaxlat=$maxlat;
<br> $maxlat=$lat;
<br> }
<br> if ($lat<$minlat){
<br> $oldminlat=$minlat;
<br> $minlat=$lat;
<br> }
<br> if ($lon>$maxlon){
<br> $oldmaxlon=$maxlon;
<br> $maxlon=$lon;
<br> }
<br> if ($lon<$minlon){
<br> $oldminlon=$minlon;
<br> $minlon=$lon;
<br> }
<br> $numpoints++;
<br> }
<br> close(IN);
<br> open (ERR,">$id.err");
<br>
<br>#we will open the file again, this time checking to see if
<br>#if the whole world should be shown, or just the edges
<br>
<br> if ($maxlon > 90 && $minlon <-90 &&
$numpoints>1){
<br> $maxlon2=-2000;
<br> $minlon2=2000;
<br> print ERR "doing update lat lon\n";
<br> $showall=0; #if there is a point
between -90 and 90, then showall
<br> print ERR "opening file name: $fnames[$i]\n";
<br> open (IN,"<$fnames[$i]") || die "can't
open $fnames[$i]\n";
<br> while (<IN> && !$showall){
<br> print ERR "line:$_\n";
#ERROR, $_ is empty!
<br> chomp;
<br> ($nu,$nu,$nu,$nu,$nu,$lat,$lon,$nu,$nu)
= split(/\^/,$_,9);
<br> if ($lon < 90 &&
$lon > -90){
<br>
$showall=1;
<br>
print ERR "show all is true because lon:$lon\n";
<br>
}
<br> else {
<br> if ($lon < -90
&& $lon >$maxlon2){
<br>
$maxlon2 = $lon;
<br>
}
<br> if ($lon > 90 &&
$lon < $minlon2){
<br> $minlon2
= $lon;
<br> }
<br> }
<br> if (!showall){
<br> print ERR "changing
lon's to minlon:$minlon2:max:$maxlon2\n";
<br> $minlon=$minlon2;
<br> $maxlon=$maxlon2;
<br> }
<br> }
<br> }
<br> close (IN);
<br>
<br> </html>
--------------1BA42D3A1DC2CD2012D9431C--
------------------------------
Date: Tue, 06 Feb 2001 01:54:29 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: trouble reopening file
Message-Id: <3A7F59F9.B4E6B5A5@rochester.rr.com>
Travis Stevens wrote:
>
> hi,
>
> well, basically here is my problem.
> I am opening a file with open(IN,"<$filename[$i]");
> i do a :while (<IN>){stuff}
> I read till the end of this file then: close(IN);
> I want to read this file again, so I: open(IN,"<$filename[$i]");
> then i do a while(<IN>){
No you don't. In your code, you *actually* do a
while(<IN> && !$showall){
That is *not* the same as:
while(<IN>){
unless($showall){
which is something along the lines of what you probably intended. See:
perldoc perlop
looking in particular at the second and third paragraphs under the I/O
Operators section.
> but at this point, i print ("line:$_\n");
> and $_ is empty. I've double, triple checked my code, and I feel I am
> doing what I'm supposed to be doing.
> any ideas?
>
> Trav
...
--
Bob Walton
------------------------------
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 V10 Issue 219
**************************************