[9564] in Perl-Users-Digest
Perl-Users Digest, Issue: 3158 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 14 20:07:20 1998
Date: Tue, 14 Jul 98 17:00:39 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 14 Jul 1998 Volume: 8 Number: 3158
Today's topics:
Re: "Telnet" Perl Script <rpsavage@ozemail.com.au>
Re: cgi module confusion (Michael J Gebis)
Re: Chomp() on win32 and unix perl (Jeffrey Drumm)
Re: compare arrays (Larry Rosler)
Re: Dynamic HTML document in new browser window? (-)
Re: efficiency: print<<"xxx" vs. print <dfan@harmonixmusic.com>
formatting the date <sammy@blast.net>
Re: formatting the date <ms@xy.org>
Re: HELP: Internet Database Design questions... <macdonaldrj@bv.com>
Re: HELP: Internet Database Design questions... (Patrick Timmins)
Re: How can you encrypt a CGI script on a server so it (-)
How to get proccess info in perl <xiangdong.xu@gs.com>
Re: Looking for simple/dirty text editing scripts <rpsavage@ozemail.com.au>
Re: newbie question on pattern match <*@qz.to>
Re: NEWBIE TO PERL <rpsavage@ozemail.com.au>
Re: Password script (-)
Re: Perl Beautifier Home Page (Ilya Zakharevich)
Re: Perl Beautifier Home Page <tchrist@mox.perl.com>
Re: Perl Beautifier Home Page (Ilya Zakharevich)
Re: Perl Beautifier Home Page (Larry Rosler)
Perl to PostgreSql problem <paula@2lm.com>
ping scan <nessenj@ns.net>
Platform-independent uname? alreadyscooter@my-dejanews.com
problem using Expect.pm (Stunt Pope)
qn on string substitution vibhu@fjst.com
Re: s: simple-database (Jonathan Stowe)
Re: Sticking in NULL after split (Sean McAfee)
Re: talking to POP3 servers (-)
Re: WebBots (-)
Re: What's the substitute for #! /usr/bin/perl in Win32 (Jonathan Stowe)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Jul 1998 23:44:53 GMT
From: "Ron Savage" <rpsavage@ozemail.com.au>
Subject: Re: "Telnet" Perl Script
Message-Id: <01bdaf83$43c06220$43ea1286@steelres-pcm657.resmel.bhp.com.au>
#!/usr/gnu/bin/perl -w
#
# Name:
# xterm.pl.
#
# Purpose:
# Run under Win95 & start an XTerm on dilbert.
# Start free Win95 X server first - See www.microimges.com.
use integer;
use strict;
use Net::Telnet;
#---------------------------------------------------------------------------
---
my($host, $username, $password, $prompt, $logFileName) =
(
'dilbert',
'username',
'password',
'/username\@dilbert\[.+\]\[\d+\] /',
'sgi.log',
);
my($session);
$session = new Net::Telnet
(
Timeout => 10,
Prompt => $prompt
);
$session -> input_log($logFileName);
$session -> open($host);
$session -> login($username, $password);
$session -> cmd('red'); # Run a command to start an XTerm.
$session -> cmd('blue'); # Run a command to start an XTerm.
$session -> cmd('yellow'); # Run a command to start an XTerm.
$session -> cmd('green'); # Run a command to start an XTerm.
$session -> close();
Vlado Baskot <v.baskot@hydro.on.ca> wrote in article
<35AB9DE6.FF90D667@hydro.on.ca>...
> Could anyone please help me to find Perl "Script" to telnet and check if
> process is running [ps -ef OR ps -ax]
> Thanks Vlado [v.baskot@hydro.on.ca]
>
>
------------------------------
Date: 14 Jul 1998 23:08:03 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: cgi module confusion
Message-Id: <6ogocj$ajq@mozo.cc.purdue.edu>
Juli@my-dejanews.com writes:
}I'm new to "cgi" perl programming.
}What is the difference between these two lines?
}I know one uses the cgi perl library and the other uses
}the cgi perl module.
}What's the difference between the two,
}and which one is better to use with cgi scripting?
}require "cgi-lib.pl";
}use CGI;
use "use CGI;" In the meanwhile, get your virtual self down to
http://stein.cshl.org/WWW/software/CGI/cgi_docs.html
and
http://www.perl.com/
and
http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html
(Yes that last one sort of implicitly calls you an idiot. It's still
a good page. Don't be offended. At least you haven't been _explicitly_
called an idiot by the author. I have. :)
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Tue, 14 Jul 1998 23:26:36 GMT
From: drummj@mail.mmc.org (Jeffrey Drumm)
Subject: Re: Chomp() on win32 and unix perl
Message-Id: <35abe481.1120852066@news.mmc.org>
On Tue, 14 Jul 1998 18:50:13 GMT, Marc.Haber-usenet@gmx.de (Marc Haber)
wrote:
>Jonathan Feinberg <jdf@pobox.com> wrote:
>> Also: use ASCII mode when transferring your file between platforms;
>>this will automagically translate end-of-line sequences between
>>platforms.
>
>This is not an option if you are using Samba or NFS.
>
>Greetings
>Marc
Of course it's an option. It just isn't as *simple* an option.
IOW, Samba and NFS don't stop your FTP server from serving, or your FTP
client from, uh, clienting. unless, of course, you've done something
horribly wrong . . . ;-)
--
Jeffrey R. Drumm, Systems Integration Specialist
Maine Medical Center Information Services
420 Cumberland Ave, Portland, ME 04101
drummj@mail.mmc.org
"Broken? Hell no! Uniquely implemented." -me
------------------------------
Date: Tue, 14 Jul 1998 15:21:36 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: compare arrays
Message-Id: <MPG.101579cb597b064e989711@nntp.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <6oe6qj$5ov$8@marina.cinenet.net> on 13 Jul 1998 23:56:03 GMT,
Craig Berry <cberry@cinenet.net> says...
> M.J.T. Guy (mjtg@cus.cam.ac.uk) wrote:
> : Craig Berry <cberry@cinenet.net> wrote:
> : >Alberto Brosich (brosich@univ.trieste.it) wrote:
> : >
> : >: How can i compare two arrays other then with a loop?
> : >
> : >Short answer: You can't do it without looping.
> :
> : Not strictly true. (Or rather, you can get Perl to do the looping
> : for you.) Using the techniques from the FAQ that Craig refers to
> : (untested code):
> [snip]
>
> Yes, I was speaking in the 'computational theory' mode, not the
> 'notational convenience' mode. It *is* possible to sweep the looping
> under the rug, in many cases. But it's still going on, down there in the
> darkness.
Here's an effective way of hiding the loops neatly, which requires that
there exist a character that is known not to appear in the data ("\0"
comes to mind immediately):
#!/usr/local/bin/perl -w
use Benchmark;
sub a_eq {
my ($ar, $br) = @_;
my ($a, $b);
local $" = "\0";
@$ar == @$br && length($a = "@$ar") == length($b = "@$br") &&
$a eq $b
}
sub b_eq { # By Craig Berry.
my ($ar, $br) = @_;
return 0 unless @$ar == @$br;
for (my $i = 0; $i < @$ar; $i++)
{ return 0 unless $$ar[$i] eq $$br[$i] }
return 1;
}
my @a = (('x' x 100) x 100, (''));
my @b = (('x' x 100) x 100, ('x')); # Different length.
my @c = (('x' x 100) x 100, ('y')); # Differs at the back.
my @d = (('x'), ('x' x 100) x 100); # Differs at the front.
timethese(1 << 12, {
Join_aa => sub { my $x = a_eq(\@a, \@a) },
Join_ab => sub { my $x = a_eq(\@a, \@b) },
Join_bc => sub { my $x = a_eq(\@b, \@c) },
Join_cd => sub { my $x = a_eq(\@c, \@d) },
Loop_aa => sub { my $x = b_eq(\@a, \@a) },
Loop_ab => sub { my $x = b_eq(\@a, \@b) },
Loop_bc => sub { my $x = b_eq(\@b, \@c) },
Loop_cd => sub { my $x = b_eq(\@c, \@d) },
});
Benchmark: timing 4096 iterations of Join_aa, Join_ab, Join_bc, Join_cd,
Loop_aa, Loop_ab, Loop_bc, Loop_cd...
Join_aa: 24 secs ( 5.10 usr 0.06 sys = 5.16 cpu)
Join_ab: 15 secs ( 4.01 usr 0.05 sys = 4.06 cpu)
Join_bc: 18 secs ( 5.19 usr 0.06 sys = 5.25 cpu)
Join_cd: 18 secs ( 4.02 usr 0.05 sys = 4.07 cpu)
Loop_aa: 38 secs ( 9.50 usr 0.11 sys = 9.61 cpu)
Loop_ab: 37 secs (10.64 usr 0.10 sys = 10.74 cpu)
Loop_bc: 46 secs (10.80 usr 0.12 sys = 10.92 cpu)
Loop_cd: 2 secs ( 0.44 usr 0.01 sys = 0.45 cpu)
These results are amusing, but not hard to explain (except why Loop_ab
and Loop_bc are 13% slower than Loop_aa).
FOOTNOTE TO PERL DEVELOPERS: I found that adding the check of lengths of
strings before using 'eq' speeded a_eq() significantly (>20%). Should
this optimization be built into 'eq/ne', or would it slow down the normal
(short) case inordinately? (In terms of a guess at the implementation,
two strlen's followed by strncmp instead of simply strcmp?)
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 14 Jul 1998 23:30:14 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: Dynamic HTML document in new browser window?
Message-Id: <35abe959.57970461@nntp.idsonline.com>
Sabine Cremer <sabine@ikt.de> Said this:
>I wrote a simple perl application to get an answer from a database.
>Because it is called from a frame too small for the output, I want to
>put the dynamically generated data into a new browser window. How to do
>it??
Just like you would with any other document you want to open in a
different window or frame.
You are confusing yourself by trying to figure out how to get the CGI
script to force itself somewhere - It cannot.
However, if you target correctly in the document that accesses your
CGI, it will open where ever you want:
<form action="mycgi.cgi" target="anotherframe">
<input type="text" name="blah">
<input type ........etc etc.......
etc etc
</form>
or
<a href="mycgi.cgi?somedata_and_whatever" target="anotherframe">This
will open in a new frame other than the one you are currently in</a>
------------------------------
Date: 14 Jul 1998 17:54:32 -0400
From: Dan Schmidt <dfan@harmonixmusic.com>
Subject: Re: efficiency: print<<"xxx" vs. print
Message-Id: <wku34kp087.fsf@turangalila.harmonixmusic.com>
rjking@blue.seas.upenn.edu (Rachel J King) writes:
| I'm wondering about the efficiency of using print<<"xxx" versus that of
| just writing a whole bunch of print statements. Is there any huge
| difference in terms of the lower-level machine code that actually gets
| executed? I'm asking b/c I wrote a bunch of code just using a lot of print
| statements before I learned the other way and I'm wondering how worth my
| time it is to go and change it all or if I could leave it the way it is
| without wasting a huge amount of time each time the scripts are run.
I didn't see any difference when I tried it.
====
use Benchmark;
open TMPFILE, ">tmpfile" or die;
timethese (50000, {
'Heredoc' => sub {
print TMPFILE <<FOO
I'm wondering about the efficiency of using print<<"xxx" versus that of
just writing a whole bunch of print statements. Is there any huge
difference in terms of the lower-level machine code that actually gets
executed? I'm asking b/c I wrote a bunch of code just using a lot of print
statements before I learned the other way and I'm wondering how worth my
time it is to go and change it all or if I could leave it the way it is
without wasting a huge amount of time each time the scripts are run.
FOO
},
'Prints' => sub {
print TMPFILE "I'm wondering about the efficiency of using print<<\"xxx\" versus that of\n";
print TMPFILE "just writing a whole bunch of print statements. Is there any huge\n";
print TMPFILE "difference in terms of the lower-level machine code that actually gets\n";
print TMPFILE "executed? I'm asking b/c I wrote a bunch of code just using a lot of print\n";
print TMPFILE "statements before I learned the other way and I'm wondering how worth my\n";
print TMPFILE "time it is to go and change it all or if I could leave it the way it is\n";
print TMPFILE "without wasting a huge amount of time each time the scripts are run\n";
}
});
====
Benchmark: timing 50000 iterations of Heredoc, Prints...
Heredoc: 18 secs (17.69 usr 0.00 sys = 17.69 cpu)
Prints: 18 secs (17.89 usr 0.00 sys = 17.89 cpu)
--
Dan Schmidt -> dfan@harmonixmusic.com, dfan@alum.mit.edu
Honest Bob & the http://www2.thecia.net/users/dfan/
Factory-to-Dealer Incentives -> http://www2.thecia.net/users/dfan/hbob/
Gamelan Galak Tika -> http://web.mit.edu/galak-tika/www/
------------------------------
Date: Tue, 14 Jul 1998 21:58:23 GMT
From: "Rich Burkert" <sammy@blast.net>
Subject: formatting the date
Message-Id: <Ew3uA2.FuH@news2.new-york.net>
How do I format the date?
------------------------------
Date: 15 Jul 1998 00:34:04 +0200
From: magnus stahre <ms@xy.org>
Subject: Re: formatting the date
Message-Id: <87iul0rrj7.fsf@harmless.xy.org>
"Rich Burkert" <sammy@blast.net> writes:
> How do I format the date?
Use strftime from the POSIX package.
-ms
------------------------------
Date: Tue, 14 Jul 1998 13:48:53 -0500
From: "dogmat" <macdonaldrj@bv.com>
Subject: Re: HELP: Internet Database Design questions...
Message-Id: <6ogl04$69d$1@bvbsd2.kc.bv.com>
- wrote in message <35aa9523.19867848@nntp.idsonline.com>...
>
>Just because you've had a pc on your desk for a couple years does not
>make you technically literate. Using word, or netscape is not a
>computer skill, it's being a computer user. Being a computer user
>does not qualify you to make suggestions about network environments.
>
Such insight. You probably hang out with your other lonely guy colleagues
making fun of all those silly users.
Grow up. And if you have any brains, keep an eye on NT. It may not be better
than Unix, but it wasn't any better than the Mac either.
------------------------------
Date: Tue, 14 Jul 1998 22:11:05 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: HELP: Internet Database Design questions...
Message-Id: <6ogl1p$1vk$1@nnrp1.dejanews.com>
In article <6og8t2$48u$1@bvbsd2.kc.bv.com>,
"dogmat" <macdonaldrj@bv.com> wrote:
[snip]
> Such insight. You probably hang out with your other lonely guy colleagues
> making fun of all those silly users.
> Grow up. And if you have any brains, keep an eye on NT. It may not be better
> than Unix, but it wasn't any better than the Mac either.
Literally, 3rd rate and proud of it.
Patrick Timmins
U. Nebraska Medical Center
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Tue, 14 Jul 1998 23:37:09 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: How can you encrypt a CGI script on a server so it will not get "stolen"?
Message-Id: <35abeafc.58389873@nntp.idsonline.com>
mgjv@comdyn.com.au (Martien Verbruggen) Said this:
>> If you try to encrypt the script, and then write a script that
>> decrypts it, anyone who wants to "steal" your source just needs to
>
>Read the FAQ.
>
If you meant that as a continuation of the sentence, then it's funny,
but then you just answered this person's question..... we've already
demonstrated that people will outright RUN from a FAQ, they will
refuse, even under threat of death, to read the FAQ, therefore, if
reading the FAQ is all someone needs to do to figure out how to steal
source code, everyone's source code is safe!!!
(well, nobody ever reads the FAQ, as is all too apparent from reading
this newsgroup)
------------------------------
Date: Tue, 14 Jul 1998 19:34:12 -0400
From: Xiangdong Xu <xiangdong.xu@gs.com>
Subject: How to get proccess info in perl
Message-Id: <35ABEAF4.732B6B6D@gs.com>
Hi folks,
Is there a perl module to collect the process info just like ps does?
Thanks in advance,
Xiangdong
------------------------------
Date: 14 Jul 1998 23:54:34 GMT
From: "Ron Savage" <rpsavage@ozemail.com.au>
Subject: Re: Looking for simple/dirty text editing scripts
Message-Id: <01bdaf84$9df588a0$43ea1286@steelres-pcm657.resmel.bhp.com.au>
There are modules on CPAN (Comprehensive Perl Archive Network) designed to
do this. Start at http://www.perl.com, perhaps.
[snip]
> What I'm specifically looking for is a way to insert one text file into
> a base file
> at marker points.
[snip]
------------------------------
Date: 14 Jul 1998 23:25:03 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: newbie question on pattern match
Message-Id: <eli$9807141906@qz.little-neck.ny.us>
In comp.lang.perl.misc, wings <xuchu@iscs.nus.edu.sg> wrote:
> i am reading "Programming Perl" 2nd edition and when trying to "put commas
> in the right places in an integer", the book told me to do this:
>
> 1 while s/(\d)(\d\d\d)(?!\d)/$1,$2/; #P74
>
> it does work but i wonder why my way doesnt work:
>
> 1 while s/(\d)(\d\d\d)([^\d]*)/;
>
> anybody mind telling me the reason?
Well, for starters, your susbstition is not closed: there are only
two /s in that.
Assuming you meant:
1 while s/(\d)(\d\d\d)([^\d]*)/$1,$2$3/;
The $3 is needed so that you don't eat whatever the third paren
group matches.
This will fail becuase "[^\d]*" matches the empty string, and what
is needed here is to match a point that is not followed by a number.
If you "correct" that to:
1 while s/(\d)(\d\d\d)([^\d]+)/$1,$2$3/;
Then the final parenthesis group must match at least one byte, so
when the number is at the end of $_ nothing will ever happen.
Here, a demonstration:
#!/usr/bin/perl
sub test {
$pat = shift;
$_ = "1234567890";
1 while s/$pat/$1,$2$3/;
print "No trailing chars: $_ \t trailing chars: ";
$_ = "1234567890\n";
1 while s/$pat/$1,$2$3/;
print
}
@REs = ( '(\d)(\d\d\d)(?!\d)()', # no-op () so all have three groups
'(\d)(\d\d\d)([^\d]*)',
'(\d)(\d\d\d)([^\d]+)'
);
foreach $re (@REs) {
print "Trying $re:\n";
&test($re);
print "\n";
}
__END__
Trying (\d)(\d\d\d)(?!\d)():
No trailing chars: 1,234,567,890 trailing chars: 1,234,567,890
Trying (\d)(\d\d\d)([^\d]*):
No trailing chars: 1,2,3,4,5,6,7,890 trailing chars: 1,2,3,4,5,6,7,890
Trying (\d)(\d\d\d)([^\d]+):
No trailing chars: 1234567890 trailing chars: 1,234,567,890
Elijah
------
#!/usr/bin/perl -00-#rekcah lrep NEW YORK rehtona tsuj#_$ esrever ralacs tnirp
open 0;$_=<0>;s/[A-Z\s]*/reverse$&/eg;##;ge/&$esrever/*]s\Z-A[/s;>0<=_$;0 nepo
print scalar reverse $_#just another KROY WEN perl hacker#-00- lrep/nib/rsu/!#
------------------------------
Date: 14 Jul 1998 23:51:03 GMT
From: "Ron Savage" <rpsavage@ozemail.com.au>
Subject: Re: NEWBIE TO PERL
Message-Id: <01bdaf84$202ce940$43ea1286@steelres-pcm657.resmel.bhp.com.au>
Perl stands for Perfect Language. You fell for the old obfuscation joke.
See The Perl Journal @ http:/tpj.com for the Annual Obfuscated Perl
Contest.
[snip]
> Perl stands for 'practical extraction and report language' or, more
> nicely 'pathologically eclectic rubbish lister', and I am sure that
> there are a few more statements around which summarise Perl's abilities.
[snip]
------------------------------
Date: Tue, 14 Jul 1998 23:33:07 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: Password script
Message-Id: <35abea1e.58167131@nntp.idsonline.com>
Andy Bold <bytealite@yahoo.com> Said this:
>brian d foy wrote:
>>
>> In article <6o2p42$8k1$1@nnrp1.dejanews.com>, rpearce@my-dejanews.com posted:
>>
>> >In article <35a18936.1650343@dub-news.tpgi.com.au>,
>> > mail@moggy.com (Bee Pee) wrote:
>> >>
>> >> I'm lookin for a password script (free one preferrably) which will
>> >> protect a bunch of directories (not necessarily in the same root dir).
>> >>
>> >Use .htaccess built in to unix.
>>
>> my unix doesn't have that feature.
>
Hahahah... Someone's pulling a microsoft user!!! if it's there when
they turn it on, then it belongs to whomever's logo appears most
prominently on that computer.
Remember when people used to say "I found this thing called "Yahoo!"
in netscape" and then "Gee, I'm really glad netscape has such a nice
guide". It wasn't "the internet" it was "netscape"
Shit, most of you people probably haven't even been around long enough
to have heard that. ;)
------------------------------
Date: 14 Jul 1998 22:02:03 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl Beautifier Home Page
Message-Id: <6ogkgr$sbu$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Christiansen
<tchrist@mox.perl.com>],
who wrote in article <6ogdco$h0g$1@csnews.cs.colorado.edu>:
> :It is documented indeed, but is documented as deprecated. Thus not
> :Perl5.
> Your grasp of English is not as good as your grasp of Russian.
> That's not a valid interpretation of what's happening here.
Calling names as a way to gain momentum?
> There's nothing "wrong" with foo'bar() from the compiler or the
> documentation's point of view. You just don't like it because you
> can't figure out how to parse it.
Read Perl documentation! In a privite mail I even spelled out the
page to look into. But since you have no access to Perl docs, here is
the snippet:
value to which it refers. Most often, it consists of a single
I<identifier>, that is, a string beginning with a letter or underscore,
and containing letters, underscores, and digits. In some cases, it
may be a chain of identifiers, separated by C<::> (or by C<'>, but
that's deprecated); all but the last are interpreted as names of
packages, to locate the namespace in which to look
up the final identifier (see L<perlmod/Packages> for details).
Ilya
------------------------------
Date: 14 Jul 1998 22:20:32 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl Beautifier Home Page
Message-Id: <6ogljg$qv9$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
:> Your grasp of English is not as good as your grasp of Russian.
:> That's not a valid interpretation of what's happening here.
:
:Calling names as a way to gain momentum?
What names? I just pointed out that because English isn't your
first language, that some subtleties might be missed. There was
no knock. And yes, I honestly do wish I could speak Russian.
Anyway, "deprecated" in Perl-speak has various meanings, none
of which include making a program no longer compilable.
:Read Perl documentation!
I cited it to you. Didn't you read what I sent you? In this case, there
are no warnings under any circumstances. I don't think it's an issue.
Don't you think that you are just being the problematic emacs user?
You should try to "beautify" my other scripts in Tom's Script Archive.
--tom
--
It is Unix. It is possible to overcome any number of these bogus features. --pjw
------------------------------
Date: 14 Jul 1998 22:48:54 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl Beautifier Home Page
Message-Id: <6ogn8m$5dj$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Christiansen
<tchrist@mox.perl.com>],
who wrote in article <6ogljg$qv9$1@csnews.cs.colorado.edu>:
> Anyway, "deprecated" in Perl-speak has various meanings, none
> of which include making a program no longer compilable.
I'm afraid you are wrong. Deprecated means exactly this, maybe not
now (and definitely not now WRT foo'bar), but at an unspecified moment
in the future.
This moment in the future may be after all the memory of Perl is long
erased, but relying on this is a bad programming practice.
Ilya
------------------------------
Date: Tue, 14 Jul 1998 16:35:42 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl Beautifier Home Page
Message-Id: <MPG.10158b2c959d48b1989712@nntp.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author and to Tom Christiansen.]
In article <6ogn8m$5dj$1@mathserv.mps.ohio-state.edu> on 14 Jul 1998
22:48:54 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> says...
> [A complimentary Cc of this posting was sent to Tom Christiansen
> <tchrist@mox.perl.com>],
> who wrote in article <6ogljg$qv9$1@csnews.cs.colorado.edu>:
> > Anyway, "deprecated" in Perl-speak has various meanings, none
> > of which include making a program no longer compilable.
>
> I'm afraid you are wrong. Deprecated means exactly this, maybe not
> now (and definitely not now WRT foo'bar), but at an unspecified moment
> in the future.
>
> This moment in the future may be after all the memory of Perl is long
> erased, but relying on this is a bad programming practice.
>
> Ilya
In "standards-speak" 'deprecated' has a very specific meaning: "May be
removed from the language in a future revision of the standard." This
isn't a value judgment about the feature or its use, just a warning that
it may go away some day.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 14 Jul 1998 16:45:19 -0700
From: Paula Gibb <paula@2lm.com>
Subject: Perl to PostgreSql problem
Message-Id: <35ABED8F.15B@2lm.com>
Hi there,
First the good news: I finally installed the latest version of
PostgreSql as well as the Postgres interface written by K. Vivek. onto
my Linux server last week. I could also successfully execute a little
Perl script that would count the number of entries in a table (whoopee!)
from telnet.
The bad news: When I try to execute the Perl script from an HTML form
(read: from an HTML browser), I am receiving a server error.
Do I need to somehow indicate to the httpd server that I am doing a
database process, or is there something else that I am completely
missing?
Thanks for any input you can provide...
Paula G.
------------------------------
Date: Tue, 14 Jul 1998 16:10:38 -0700
From: James Nessen <nessenj@ns.net>
Subject: ping scan
Message-Id: <Pine.HPP.3.96.980714160844.4449G-100000@hornet.ns.net>
I was curious if anyone has developed a perl application that will ping a
range of ip's to see if anything is alive, ie you give it
xxx.xxx.xxx.xxx/24 and it will ping the entire class c? or a /26, /29 etc.
if anyone has, id be curious to see, ive been trying but i dont know where
to start :-)
Jim
------------------------------
Date: Tue, 14 Jul 1998 22:33:54 GMT
From: alreadyscooter@my-dejanews.com
Subject: Platform-independent uname?
Message-Id: <6ogmci$4dr$1@nnrp1.dejanews.com>
Is there a platform independent perl implementation of uname
out there? The $OSNAME variable available within perl doesn't
tell me what I want to know; I want to know the version info
of the box my script is running on, which may be different
from the version info of the box on which the perl binary was
compiled. On SunOS, I would use uname -sr to give me the OS
and its release number. But I want a means of getting OS info
on SunOS, Linux, HP-UX, or NT 4.0.
- Mark McClelland
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 14 Jul 1998 23:15:14 GMT
From: markjr@mail.PrivateWorld.com (Stunt Pope)
Subject: problem using Expect.pm
Message-Id: <6ogoq2$6fl@news.inforamp.net>
------------------------Begin ROT26 Encoded Text
This has had me stumped all day. I'm using Expect.pm 1.07. I am already
using this in a script that changes system passwds just fine. I simply
copied that script and changed to suit, and for the life of me I can't
get it start up the stronghold server (version Stronghold/1.3.4
Ben-SSL/1.3 Apache/1.1.3).
To me it looks like it traps the "Enter PEM Passphrase:" prompt just
fine, but it doesn't seem to want to write the passwd back to it.
The annoying thing is it works *occasionally*, like 1 try out of 20.
The essential snippets of code look like so:
use Expect;
$passwd = "not_our_real_passwd";
# Turn off viewability.
$Expect::Log_Stdout=1;
$Expect::Debug=1;
#$Expect::Exp_Internal=1;
$HTTPS = Expect->spawn('/export/https/start');
if($HTTPS->expect(3,'Enter PEM pass phrase:')) { print $HTTPS "$passwd\r"; }
else { &puke("Prompt timeout."); }
print $HTTPS->error if $HTTPS->error;
And it enters the conditional after $HTTPS->expect() just fine. The server
never starts up however. I also tried $HTTPS->send_slow() to no avail.
$HTTPS->error never gets set at all.
As far as termination on $passwd, I've tried \n, \r and even ^M.
Any ideas would be appreciated.
Here's the debugging output when I set $Expect::Debug:
Spawned '/export/https/start dummy' (spawn id(3))
Pid: 16417
Tty: /dev/ttya0
Beginning expect from spawn id(3).
Accumulator: ''
Expect timeout time: 3 seconds.
expect: Pty=spawn id(3), time=900456294, loop_time=3
expect: handle spawn id(3) ready.
expect: read 24 byte(s) from spawn id(3).
expect: handle spawn id(3) ready.
expect: read 27 byte(s) from spawn id(3).
expect: handle spawn id(3) ready.
expect: read 26 byte(s) from spawn id(3).
expect: handle spawn id(3) ready.
expect: read 22 byte(s) from spawn id(3).
Matched pattern 1 ('Enter PEM pass phrase:')!
Before match string: 'trans.PrivateWorld.com: Tue Mar 31 16:22:40 1998 - Wed Mar 31 16:22:40 1999\r\n'
Match string: 'Enter PEM pass phrase:'
After match string: ''
Returning from expect successfully.
Accumulator: ''
-mark
------------------------End ROT26 Encoded Text
Mark Jeftovic aka: mark jeff or vic, stunt pope.
markjr@shmOOze.net http://www.shmOOze.net/~markjr
PWC's BOFH http://www.PrivateWorld.com
irc: L-bOMb Keep `em Guessing
------------------------------
Date: Tue, 14 Jul 1998 23:33:07 GMT
From: vibhu@fjst.com
Subject: qn on string substitution
Message-Id: <6ogprj$an2$1@nnrp1.dejanews.com>
#!/usr/is/gnu/bin/perl -w
$n1 = "q[0]"; # 1
$n2 = "q[0]"; # 2
$sign = "a b c $n1 d"; # 3
print STDOUT "$sign\n"; # 4
$n2 =~ s/\[/\\[/g; # 5
$sign =~ s/$n2/DONE/; # 6
print STDOUT "$sign\n"; # 7
print STDOUT "-$n1-$n2-\n"; # 8
-------------------
$sign could have come from any other source. I want to substitute
the q[0] with "DONE". The substitution statement in line 6 does not
work, as is. Line 5 is also rewquired. Why? The "[" is being considered
as a (array) range? How can I make the substitution work without having
to do line 5? Can anyone explain/point me to the right resource to find out?
Interestingly, if I use the "\" in line 2 itself, and get rid of line 5,
it does not work. Why?:
#!/usr/is/gnu/bin/perl -w
$n1 = "q[0]"; # 1
$n2 = "q\[0]"; # 2
$sign = "a b c $n1 d"; # 3
print STDOUT "$sign\n"; # 4
### $n2 =~ s/\[/\\[/g; # 5
$sign =~ s/$n2/DONE/; # 6
print STDOUT "$sign\n"; # 7
print STDOUT "-$n1-$n2-\n"; # 8
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Tue, 14 Jul 1998 22:33:31 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: s: simple-database
Message-Id: <35abd66e.3086565@news.btinternet.com>
On Mon, 13 Jul 1998 17:47:10 +0200, Adam Kopacz wrote :
>Larry Rosler <lr@hpl.hp.com> wrote:
<snip>
>> Regexes have their place, but the operator you want here is 'eq'.
>
>eq? how i use this ?
>the perl5 manual pages aren't the best :(
>
Uh oh.
I dont think you wanted to say that here ;-0
Think operators think perl think perlop.
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Tue, 14 Jul 1998 23:10:58 GMT
From: mcafee@moonpatrol.rs.itd.umich.edu (Sean McAfee)
Subject: Re: Sticking in NULL after split
Message-Id: <6ARq1.3751$24.21597441@news.itd.umich.edu>
In article <6ogfea$4ug$1@cronkite.cc.uga.edu>,
Benjamin Dixon <beatle@arches.uga.edu> wrote:
>I am trying to write a perl script that will generate a create statement
>for an SQL server. Its pretty much just parsing an ascii file exported
>from a different server... anyways, I split the thing into separate
>variables like so:
>($var1, $var2, $var3) = split(/:/);
>then I want to print the results, separated by commas like so:
>print "$var1, $var2, $var3";
>But say $var2 is an empty string... so that the output is:
>var1,,var3
>In this case I see that I could just use s// and get the output to look
>like this var1,NULL,var3. but if I have more than two commas, say
>var1,,,var3, or even 100, how can I place the word 'NULL' inbetween each?
>Probably a simple answer but I'm pretty new to perl. Thanks.
This should do the trick:
($var1, $var2, $var3) = map { $_ || "NULL" } split /:/;
Or, generally, you can replace ($var1, $var2, $var3) with @any_array.
--
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
| tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: Tue, 14 Jul 1998 23:24:29 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: talking to POP3 servers
Message-Id: <35abe3e5.56580647@nntp.idsonline.com>
Simon Wistow <smw3@doc.ic.ac.uk> Said this:
>
>I apologise in adavnce if this causes mass groaning in the news group
>but I only started learning Perl last weekend on a 6am ferry from
>Ostende to Dover :/
>
>I am writing a POP3toWeb script (I know there are loads out there
>already but I'm doing it as a learning experience) and so far it will
>connect, logon and receive single line messages from the server however
>it all falls over when I try and get multiline responses (in my case
>the reply to the "TOP x 0" command).
Maybe you are just doing this as a learning exercise, but if you want
to get the easiest solution to "webifying" your email, just make use
of .forward files in the user directories of each email account you
want to "webify".
Like this:
.forward file located in /home/username:
"|~/webmail"
This tells sendmail to pipe messages into the executable named
"webmail" also located in the user's home directory. Then in webmail,
you just need to write the messages into either individual "message"
files (I use the message-id header to get a unique file name) or write
it to a "spool" file much the same as the normal /var/spool/mail file.
I suppose you could just write your scripts to directly access the
/var/spool/mail/username mailbox file, but I prefer to keep any "web
mail" seperate from normal sendmail/POP3 managed mailboxes.
I was playing around and came up with a fairly decent email interface,
it had an in box, and out box, a trash bin, reply, forward, new
message, etc... I modeled it after Eudora, as far as how the In Box
displayed information (Status, From, size, Subject, Date) (if there
was a reply or forwarded message in the out box, it showed an F or R
in the status field.
If you are interested in seeing a working demo, email me at
webmaster AT lmnet dot com. I'll give you the URL and a password to
login with - It is a live, working script that will even send messages
so I'm not about to announce to the world how to access it.
The bottom line is that talking to a POP3 server is somewhat overkill
to turn email into a "web app" - I mean, if it's a web app, it's
running on a machine that is internet connected, so most likely it is
running the MTA (mail transfer agent) on the very same machine. If
that is the case, building up sockets and tearing them down again is a
lot of unnecessary overhead when a simple open() can get your mail for
you. You don't have to go through a POP3 connection to read your
email. If you really really wanted to, you could simply open
/var/spool/mail/your_user_name and read it right from the "mailbox"
file. It's just a text file, it's not encoded or anything. In fact,
here's a sample of a mailbox with one message in it:
(I added the dashes to delimit the mailbox from the rest of this
posting)
---------------------------------------------------------------------------
>From lmnet Tue Jul 14 04:41:07 1998
Return-Path: <lmnet>
Received: (from lmnet@localhost)
by lmnet.cd-music.com (8.8.7/8.8.7) id EAA27773;
Tue, 14 Jul 1998 04:41:07 -0400
Date: Tue, 14 Jul 1998 04:41:07 -0400
From: Online CD Shop <lmnet>
Message-Id: <199807140841.EAA27773@lmnet.cd-music.com>
To: lmnet
Subject: Sample email message as seen in the spool file
This is a sample message. It's plainly readable directly from the
spool file.
---------------------------------------------------------------------------
each message in your mailbox is listed one after the other, with a
line between each one.
------------------------------
Date: Tue, 14 Jul 1998 23:57:41 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: WebBots
Message-Id: <35abebe0.58618086@nntp.idsonline.com>
"Darren Sweeney" <darrensw@pacbell.net> Said this:
>Hi all,
>
>Is there a benefit to using perl/cgi rather than Frontpage WebBots. i need
>to make a decision which one to focus on.
>
when you say "focus on" I'm assuming you intend to learn one or the
other as a resume building type of thing? Then in that case, trash
and burn anything to do with webbots. They are just canned toys made
by underskilled microsoft programmers - people who probably never saw
a real internet server or real internet development team in action.
Perl and CGI are unstoppable. Knowing how to program in perl gives
you more than just "CGI", it allows you to do administrative tasks on
unix and other operating systems, automate certain things like email,
log rotation, and so on and so on... plus of course, the CGI aspect.
With Perl (or any other language for that matter) you have unlimited
possibilities with what you can accomplish, whereas with a webbot, if
they don't make a web bot that sends email, then you won't be able to
send email - with perl, there's about a thousand different ways to go
about sending email from a web page (as just one of a billion
examples).
Plus, once you've "mastered" perl, you can do anything you can imagine
(well, for the most part). If you wanted to write a script that
checks the weather, and then gets a person's horoscope, it's possible
to do with perl = providing you can find a source for that
information. I doubt a webbot could handle that.
Anything frontpage is mostly intended for non-serious stuff, like the
ubiquitous "My name is John. I like cheese" web pages out there...
you know, "even though they've been talking about the internet for the
last 5 years I only found out about it last week so I want to build my
very first home page" kind of stuff. ;)
Business oriented web pages require something a little more than those
rinky-dink webbot toys.
------------------------------
Date: Tue, 14 Jul 1998 22:33:33 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: What's the substitute for #! /usr/bin/perl in Win32 Perl?
Message-Id: <35abd74b.3307748@news.btinternet.com>
On 13 Jul 1998 15:07:57 GMT, scott@softbase.com wrote :
>> I'm using the ActiveState Win32 Perl on an NT 4.0 system... what do I
>> use in place of the first line (#! /usr/bin/perl) in Unix versions of
>> the script ?
>
>You don't. NT doesn't support this "magic number" style of
>execution.
>
Perl however *does* - whilst the NT (ahem) shell doesnt support this
kind of execution of interpreted programs - if you put a shebang line
in your script with some switches then Perl will use them - infact if
you put a shebang line with some completely different interpreter and
then run your script with perl then perl will (should) start that
interpreter and pass your script to it. Fun hey ?
>
>If you are trying to run a CGI Perl program, get and install the ISAPI
>version of Perl. The command line Perl doesn't work with IIS or PWS.
>(If it does, getting it to work wouldn't be worth the hassle. I've
>never gotten it to work in 2-3 years.)
This is just not true. Given the correct registry setting as
adequately documented in the IIS manual perl.exe can be made to work
in <10mins. But of course this is not the appropriate forum to
discuss this stuff. Also one should be aware that if the ISAPI dll
should crash (and I have no particular reason to believe that it will
but who knows) then its all over for your Web Server as well - if
perl.exe fails then the worst that will happen is that you will get a
confusing message in your browser.
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 3158
**************************************