[6956] in Perl-Users-Digest
Perl-Users Digest, Issue: 581 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 6 14:21:37 1997
Date: Fri, 6 Jun 97 11:00:46 -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 Fri, 6 Jun 1997 Volume: 8 Number: 581
Today's topics:
Checking if write to file is complete <zmievski@ispi.net>
Re: Checking if write to file is complete <rootbeer@teleport.com>
Re: Error in openning a file ... (Jot Powers)
Re: File locking <rootbeer@teleport.com>
Re: File locking <brooks-n-janet@worldnet.att.net>
Re: find out no.of lines in open file (Chipmunk)
Re: find out no.of lines in open file (Craig Berry)
Re: From Unix Perl programming to NT Perl Programming.. (Tech Support)
Re: How can I set up this server to run perl faster?... (David Hinds)
Interpolated regular expressions (Matthew Burnham)
Re: Is It Possible to Call the HALT Function in a Perl <rootbeer@teleport.com>
Re: Is there a reccomended method for... (Hashes/Arrays <rootbeer@teleport.com>
Re: looping question (Chipmunk)
Re: odd problem with readdir (Jeff Stampes)
Output of shell script to html <yangma@cig.mot.com>
Re: pack template that packs like 'a' but unpacks like <rootbeer@teleport.com>
Re: pack template that packs like 'a' but unpacks like <uwe@ptc.spbu.ru>
Re: Perl 5.002 socket call on DEC OSF/1 - HELP (M Kent Dawson)
Perl obfuscated contest <cswanson@io.com>
Re: Perl program to probe for Web servers <rootbeer@teleport.com>
Re: Perl program to probe for Web servers <brooks-n-janet@worldnet.att.net>
Perl Win32 not working with browser... <rvprivate@mantamedia.com>
Re: Perl Win32 not working with browser... (Nathan V. Patwardhan)
Re: Perl Win32 not working with browser... <rootbeer@teleport.com>
Re: perlxs questions (Randy J. Ray)
Printing Prime Numbers <darrylc@eznet.com>
question about behavior of $& ekoontz@acsu.buffalo.edu
Re: script for log file <brooks-n-janet@worldnet.att.net>
Re: Shared DBM files <brooks-n-janet@worldnet.att.net>
Re: String Compare Problem (Chipmunk)
Re: Tricky Syntax Question <rootbeer@teleport.com>
Re: Tricky Syntax Question <tycage@infi.net>
Re: Tricky Syntax Question <news@alf.impaq.com.pl>
Re: Tricky Syntax Question (Chipmunk)
Re: Tricky Syntax Question <rootbeer@teleport.com>
Re: Works in Shell, not as cgi <rootbeer@teleport.com>
Re: WTD: perl script for HTML list of Ph servers on the (Matthew Burnham)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 06 Jun 1997 10:31:31 -0500
From: Andrey Zmievski <zmievski@ispi.net>
Subject: Checking if write to file is complete
Message-Id: <33982D53.330@ispi.net>
I need to write a script that when periodically launched by cron will
check a certain directory for all the new files since the last time it
checked and do a certain operation on those files. The files in the
directory will be ftp'ed from outside. But! if a file is still being
written to, I don't want to do that operation on it.
So, how can I check if a file is currently being modified or written to?
--
Andrey Zmievski | tel: +1.402.441.3295 | To understand recursion,
Code Wizard | fax: +1.402.483.5418 | first you must
zmievski@ispi.net | URL: http://www.ispi.net | understand recursion.
------------------------------
Date: Fri, 6 Jun 1997 10:21:37 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Andrey Zmievski <zmievski@ispi.net>
Subject: Re: Checking if write to file is complete
Message-Id: <Pine.GSO.3.96.970606101801.21788a-100000@kelly.teleport.com>
On Fri, 6 Jun 1997, Andrey Zmievski wrote:
> I need to write a script that when periodically launched by cron will
> check a certain directory for all the new files since the last time it
> checked and do a certain operation on those files. The files in the
> directory will be ftp'ed from outside. But! if a file is still being
> written to, I don't want to do that operation on it.
>
> So, how can I check if a file is currently being modified or written to?
I don't think that that can be done, but it's not hard to check that its
last modification time is at least, say, an hour ago. Check out stat and
-M in perlfunc. Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 6 Jun 1997 16:16:15 GMT
From: jot@tmp.medtronic.com (Jot Powers)
Subject: Re: Error in openning a file ...
Message-Id: <5n9d4f$j6g$1@gazette.corp.medtronic.com>
In article <5n7t9m$oun$1@skipper.netrail.net>, marti@netrail.net (Dennis Marti) writes:
>Jot Powers (jot@tmp.medtronic.com) wrote:
>: Your next line is an attempt to access $stuff[2.xxxx]. A fractional index
>: to an array isn't going to work.
>
>Yes it will. Try either one of these:
I stand corrected. I thought I had tested that but obviously hadn't.
( DB<1> @stuff = (1..10)
DB<2> p $stuff[1.234]
2
)
I'd still argue you _shouldn't_, but TIMTOWTDI. :)
>: Notice, it says EXPR not ARRAY. So, you want to change that and
>
>Your understanding of EXPR is off.
*sigh*
You are correct. I was thinking "regular expression" and not EXPR.
My fault.
>
>The fatal problem with the original script (and this was in the error
>message provided) was the use of a quote instead of a filename to cat.
>(Look for the easy answers first. ;)
wimp. ;)
Thanks for the corrections.
-Jot
--
Jot Powers jot@tmp.medtronic.com
Unix System Administrator, Medtronic Micro-Rel
"Subtlety is the art of saying what you think and getting out of the way
before it is understood."
------------------------------
Date: Fri, 6 Jun 1997 08:07:11 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Gordon Hunt <flash@webfresco.com>
Subject: Re: File locking
Message-Id: <Pine.GSO.3.96.970606080642.21788Q-100000@kelly.teleport.com>
On Thu, 5 Jun 1997, Gordon Hunt wrote:
> Can anyone help me with file locking under Solaris. flock() doesn't
> work.
It should work if you install 5.004, which is probably easier than you
think. :-) Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 6 Jun 1997 16:09:47 GMT
From: "Brooks Davis" <brooks-n-janet@worldnet.att.net>
Subject: Re: File locking
Message-Id: <01bc7294$20ef2100$1f8493cf@Brooks.st.hmc.edu>
Gordon Hunt <flash@webfresco.com> wrote in article
<33975BA3.2181@webfresco.com>...
> Can anyone help me with file locking under Solaris. flock() doesn't
> work. If anyone has some sample code using fcntl() I would appreciate
> it.
What versions of Solaris and Perl are you using? With Solaris 2.5.1 and
Perl 5.003 the following code snipit will give you an exclusive lock on a
file (I even tested it it make sure it actually worked :-).
open(LOCKFILE, ">$lockfile") || die "Could not open lockfile: $!";
flock LOCKFILE, 2; # Get an exclusive lock on the lock file.
# We're dead here if we don't get the lock.
------------------------------
Date: 6 Jun 1997 14:17:03 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: find out no.of lines in open file
Message-Id: <5n964v$tsc$1@dartvax.dartmouth.edu>
Pui Ming WONG (s11976@net2.hkbu.edu.hk) wrote:
: I have a trivial question as i just get started on perl
:
: In my program i have opened a file,i.e.
: open(COUNT,"$myfilename")
:
: Now i would like to know the total no. of lines in this file COUNT,
: what statements are available, perl's own
$/ = undef;
$text = <COUNT>;
$text =~ tr/\n//cd;
$lines = length($text);
As every knows, you can use length() to get the length of a string.
;-)
Chipmunk
------------------------------
Date: 6 Jun 1997 17:07:12 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: find out no.of lines in open file
Message-Id: <5n9g40$qj$1@marina.cinenet.net>
Chipmunk (Ronald.J.Kimball@dartmouth.edu) wrote:
: Pui Ming WONG (s11976@net2.hkbu.edu.hk) wrote:
:
: : I have a trivial question as i just get started on perl
: :
: : In my program i have opened a file,i.e.
: : open(COUNT,"$myfilename")
: :
: : Now i would like to know the total no. of lines in this file COUNT,
: : what statements are available, perl's own
:
: $/ = undef;
: $text = <COUNT>;
: $text =~ tr/\n//cd;
: $lines = length($text);
I'm surprised nobody has mentioned:
@lines = <COUNT>;
$line_count = @lines;
In a scalar context, a list evaluates to its entry count.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Fri, 06 Jun 1997 15:10:14 GMT
From: techsupport@mail.advertisnet.com (Tech Support)
Subject: Re: From Unix Perl programming to NT Perl Programming... Help!
Message-Id: <5n992i$alq$1@news1.i1.net>
The NT email program is BLAT. It sends text files thru email.
jay@dam.net
junkmail@sysc.abdn.ac.uk (Kyzer) wrote:
>When Eric Foster-Johnson met comp.lang.perl.misc....:
>: I believe there's a freeware program called Blast that
>: can send email from NT systems.
>Interestingly, there's a program called Blast for unix/X that plays with the
>shape extension, allowing you to knock circular holes in windows with the
>mouse, accompanied with interesting sound-effects.....
>But that's off-topic :)
>--
>Stuart 'Kyzer' Caie - Kyzer/CSG |undergraduate of Aberdeen University |100%
>http://www.abdn.ac.uk/~u13sac |My opinions aren't those of Aberdeen |Amiga -
>kyzer@4u.net kyzer@hotmail.com |University or AUCC, thankfully.***** |always!
>--
>Random sig of the day:
>AtheistCode(v1.0) ACv1.0 DUR5 STR4 BIT4 ACT1 DEF4 DEB5 CON1 SLM5 XTN4 PUB2
------------------------------
Date: 6 Jun 1997 16:48:18 GMT
From: dhinds@hyper.stanford.edu (David Hinds)
Subject: Re: How can I set up this server to run perl faster?...
Message-Id: <5n9f0i$dl5$1@nntp.Stanford.EDU>
Scott M. Hinnrichs (smh@netserv.com) wrote:
: I don't know why I haven't seen this idea posted before. It seemed pretty
: obvious to me. Anyway...
: I first ran into this for a medical library site, they had one swap
: partition, and the access time for that partition was *really* long. Even
: though they had 512MB of memory they still had slow CGI performance.
: The problem is that everytime a bin runs it creates an entry in swap,
: whether it ever uses it or not.
This might have once been true, but it is not true of any modern Unix
implementation that I'm aware of. Certainly not true of Linux, IRIX,
DEC Unix, Solaris. Even if the OS preallocates swap space for a
process, this doesn't require any IO: it just marks some amount of
space as reserved in a kernel data structure. The preallocation is
also not explicitly of swap space: it is a preallocation of virtual
memory, as the sum of memory + swap, so you've got to do it whether
you've actually got any swap space or not.
If you have enough memory so that there is never a need to swap, I
guess it is still conceivable that for some system loads, it might be
better to turn swap off completely, but I would be very surprised if
the effect is ever large. And if you ever do run short on memory in
this configuration, your performance will truly suck. If just adding
swap space (without any actual swapping) slows the system down, that's
a bug. It is not a common attribute of Unix systems in general.
-- Dave Hinds
------------------------------
Date: Fri, 06 Jun 1997 17:44:22 GMT
From: danew@enterprise.net (Matthew Burnham)
Subject: Interpolated regular expressions
Message-Id: <339d46fa.6817707@194.72.192.4>
I'm trying to add a prefix to the from of a subject to send an email but
only do it if it's already there (I also need to check for Re: prefix
but that's just something I forgot because someone interrupted me when I
was messing with it). The problem is that if the prefix is [FM] then:
m/^Re: $prefix/i
will interpret the [FM] as a character class - how can I stop perl from
interpolating the $prefix variable to that extent? I can't find anything
in the man pages that explains how to do it - although I might be just
confused. What I 've done as a cludge is this, but have I covered all
the special characters?:
if ($prefix ne '')
{
@escape = ("\\(", "\\)", "\\{", "\\}",
"\\[", "\\]");
$_ = $prefix_escaped = $prefix;
for $char (@escape)
{
$_ = $prefix_escaped;
s/$char/$char/g;
$prefix_escaped = $_;
}
$_ = $subject;
unless (m/^Re: $prefix_escaped/i)
#($subject ne "$prefix $subject")
{
$subject = "$prefix $subject";
}
}
}
--
Matthew Burnham, Manager, MindWeb | danew@enterprise.net
Commercial web design and hosting, reasonable rates
UKP24/Mb/Year for DIY space | mindweb@pobox.co.uk
FTP, CGI, password protection, etc. too!
http://www.virtual-pc.com/mindweb/
------------------------------
Date: Fri, 6 Jun 1997 08:05:22 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: $j,u?OE" <swsung.bbs@cis.nctu.edu.tw>
Subject: Re: Is It Possible to Call the HALT Function in a Perl Program??? How???
Message-Id: <Pine.GSO.3.96.970606080414.21788N-100000@kelly.teleport.com>
On 6 Jun 1997, =A4j=AC=F5=BFO=C5=A2 wrote:
> Subject: Is It Possible to Call the HALT Function in a Perl Program??? H=
ow???
Are you trying to shut down your computer? That's possible from Perl, if
you're running as root (of course! :-). Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Fri, 6 Jun 1997 07:39:06 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: mark@turnergroup.com
Subject: Re: Is there a reccomended method for... (Hashes/Arrays/Complex Structures)
Message-Id: <Pine.GSO.3.96.970606073313.21788J-100000@kelly.teleport.com>
On Thu, 5 Jun 1997, Mark Bainter wrote:
> removing items from a complex structure?
You can use delete() on a hash element. You can use splice(), pop(), or
shift() on an array. Are these what you want?
> The only way I know of to do this is to step through each item and if it
> matches, put it in another array. At the end, list the array for the
> user to confirm. If confirmed, step through the array again and this
> time create a second complex structure matching the first, but don't
> include the ones you want to delete. Then write it all out to a file.
If you're already making a complex structure and you can't bear to delete
a part of it :-) then maybe you'll want to make it mork complex. Let's
say that you have a hash for each item. Simply add an element with a key
of 'delete' and a value of 1, say, and when it's time to re-write your
file you'll know which ones to omit.
Alternatively, you could keep either a list or a hash of which elements to
keep - or which to omit.
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 6 Jun 1997 14:45:01 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: looping question
Message-Id: <5n97pd$k8u$2@dartvax.dartmouth.edu>
In article <3396DA5B.5594@deltastar.nb.ca>
Brian Freeze <webmaster@deltastar.nb.ca> writes:
> I have the following piece of code which I want to have loop if
> conditions are not right. How do I end the statement in the sleep
> portion so that after it sleeps it will go back to the first part of the
> loop? ( I want it to call uptime again.)
>
> Thanks in advance.
Is this where you want the loop to start?
while (1) {
# repeat until the loop is exited from within
> open (UPTIME, "$process |") || die "I can't open this process: $!\n";
> while (<UPTIME>) {
> chop;
If you have perl5, you should consider using chomp instead.
> print "$_ is the result\n"; # this gives full stats now lets split this
> to get last 15 min.
> @load = split (/\s+/);
> chop $load[10];
> print "$load[10]\n";
>
> if ($load[10] < 2.5) {
>
> print "The load is fine we can ftp\n";
>
>
> # system $ftp $files[0] # call ftp script to start a download.
last;
# exit the loop from within
last exits the loop, next goes to the next iteration, and redo repeats
the current iteration
> }
>
> else{
> sleep 60 # at this point if it goes to the sleep portion I want it
> to go through the full process again of calling up uptime.
> }
>
> }
Don't forget to indent your code. :-)
Chipmunk
------------------------------
Date: 6 Jun 1997 14:22:34 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: odd problem with readdir
Message-Id: <5n96fa$s2j$1@neocad.com>
chris (cwg-spambegone@pobox.com) wrote:
: Hey..
: I am having the strangest problems with readdir.
Actually, it's not so strange...you even posted the answer!
: @target_contents = readdir(TARGET) || die "couldn't read directory: $!";
: "In list context, it [readdir] returns all the rest of the entries in
: the directory..."
So, put readdir in a list context then:
DB<1> $incoming = '/tmp'
DB<2> opendir(TARGET, $incoming) || die "couldn't open $incoming: $!";
DB<3> @target_contents = (readdir TARGET)
DB<4> x @target_contents
0 '.'
1 '..'
2 '.pcmcia'
3 'ps_data'
4 '.X11-unix'
5 '.X11-pipe'
6 'bom_check_670_dir'
7 'sdtdbcache_:0'
8 'textsw_shelf'
9 'gm'
Hope this helps...
Jeff
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: Fri, 06 Jun 1997 11:26:55 -0500
From: "Mai Yang [I]" <yangma@cig.mot.com>
Subject: Output of shell script to html
Message-Id: <33983A4F.41C67EA6@cig.mot.com>
Hi,
I am trying to write a perl script which will run a shell script
and return the output to a webpage. The code is like this:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<HEAD>\n<TITLE>Command Results:</TITLE>\n</HEAD>\n";
$cmd ="command"; #### problem here!!!
print `$cmd`;
If the above "command" is a standard UNIX command, such "date",
"cal", etc, the output will be displayed in the webpage. But
if "command" is a shell script(ksh, csh, perl), the output
doesn't show up on the web page. I run this script from command line,
I found the `$cmd` is replace by the output of $cmd, whether it
is a unix cmd or shell script.
I also tried to get around this by replace "print `$cmd`" by :
open(IN,"$cmd|");
@rst=<IN>;
close(IN);
print "@rst";
But it didn't work. Would anyone provide me any reason or solution
to this problem? Any help is appriciated.
Thank.
--
Mai
* *
*** ***
***** *****
I I
--=_--_== -_-_==
------------------------------
Date: Fri, 6 Jun 1997 07:42:59 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Valeriy E. Ushakov" <uwe@ptc.spbu.ru>
Subject: Re: pack template that packs like 'a' but unpacks like 'A'
Message-Id: <Pine.GSO.3.96.970606073952.21788K-100000@kelly.teleport.com>
On Fri, 6 Jun 1997, Valeriy E. Ushakov wrote:
> On Thu, 5 Jun 1997, Tom Phoenix wrote:
> > If I have binary data, it may have null values as valid
> > data. I'd pack it in a fixed-width field, either using substr or a
> > different pack template character than 'a'.
>
> Hmm, just curious, which one?
Depends upon the data! 'I' for some things, 'l' for others.
Thanks for sending your patch to the Perl development team. I haven't seen
any objections to it. I'll try to ensure that it's adopted, unless I hear
a good reason that it shouldn't be.
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Fri, 6 Jun 1997 18:57:23 +0400
From: "Valeriy E. Ushakov" <uwe@ptc.spbu.ru>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: pack template that packs like 'a' but unpacks like 'A'
Message-Id: <%PTCmzYoUX@snark.ptc.spbu.ru>
On Fri, 6 Jun 1997, Tom Phoenix wrote:
> Thanks for sending your patch to the Perl development team. I haven't seen
> any objections to it. I'll try to ensure that it's adopted, unless I hear
> a good reason that it shouldn't be.
Thanks for constructive discussion.
SY, Uwe
--
uwe@ptc.spbu.ru | Zu Grunde kommen
http://www.ptc.spbu.ru/~uwe/ | Ist zu Grunde gehen
------------------------------
Date: Fri, 06 Jun 1997 14:33:43 GMT
From: kent.dawson@atl.bluecross.ca (M Kent Dawson)
Subject: Re: Perl 5.002 socket call on DEC OSF/1 - HELP
Message-Id: <33981af2.852766433@news>
On Wed, 21 May 1997 19:41:56 +1000, loi huynh <lhuynh@newscorp.com.au>
wrote:
>Here is the sample CLIENT:
>#!/usr/bin/perl
>
>
>
>($them,$port) = @ARGV;
>$port = 7011 unless $port;
>$them = 'localhost' unless $them;
>
>require 'sys/socket.ph';
Again, I am not a Perl or socket programming expert, but I've been
playing around a bit.
Try using:
use Socket;
Instead of:
require 'sys/socket.ph';
This uses the 'h2xs' utility instead of the 'h2ph' utility. I as far
as I can see, it dynamically translates the entries in the C header
files as it needs them. So, you don't have to translate them manually
with 'h2ph'.
I hacked your client code into a DAYTIME service client. Basically,
it uses a socket to request the date and time from another host
running the DAYTIME service. It works really well for me, so here it
is:
#!/bin/perl
use Socket;
$them = "remote_host";
$sockaddr = 'S n a4 x8';
$hostname = "local_host";
$proto = getprotobyname('tcp');
$port = getservbyname('daytime', 'tcp');
$thisaddr = gethostbyname($hostname);
$thataddr = gethostbyname($them);
$this = pack($sockaddr, &AF_INET, 0, $thisaddr);
$that = pack($sockaddr, &AF_INET, $port, $thataddr);
socket(S, &PF_INET, &SOCK_STREAM, $proto) || die "socket: $!";
bind(S, $this) || die "bind: $!";
connect(S, $that) || die "connect: $!";
while (read(S, $line, 80))
{
print (<STDOUT>, $line);
}
Hope this helps! Let me know.
Kent...
------------------------------
Date: 6 Jun 1997 15:02:53 GMT
From: "CS" <cswanson@io.com>
Subject: Perl obfuscated contest
Message-Id: <01bc7289$ef89e910$c5f814dd@vorlan>
Can any kind soul tell me where the Perl obfuscation contest hangs out. Web
site, email, news group, etc?
Thanks much,
Carl
cswanson@mos8synapse.sps.mot.com
------------------------------
Date: Fri, 6 Jun 1997 08:03:42 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Matthew V. McClung" <commcclu@ihc.SPAMBLOCKER.com>
Subject: Re: Perl program to probe for Web servers
Message-Id: <Pine.GSO.3.96.970606080150.21788M-100000@kelly.teleport.com>
On 5 Jun 1997, Matthew V. McClung wrote:
> I was about to write a perl program to probe a segment on our network
> for unauthorized web servers that are running on a specified port.
Could it be....... SATAN? :-)
[ For the uninitiated: SATAN is a system administrators' tool, written in
Perl, which searches for (among other things) unexpected servers running
on user ports. ]
Would that do what you want?
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 6 Jun 1997 16:04:34 GMT
From: "Brooks Davis" <brooks-n-janet@worldnet.att.net>
Subject: Re: Perl program to probe for Web servers
Message-Id: <01bc7293$669f34c0$1f8493cf@Brooks.st.hmc.edu>
Matthew V. McClung <commcclu@ihc.SPAMBLOCKER.com> wrote in article
<5n7a82$bjn@dali>...
> I was about to write a perl program to probe a segment on our network
> for unauthorized web servers that are running on a specified port.
There is a nice little program called strobe (not written in perl) that
should do the job. The official distribution is available at:
ftp://suburbia.apana.org.au:/pub/users/proff/original/strobe.tgz
-- Brooks
------------------------------
Date: Fri, 06 Jun 1997 10:27:29 -0400
From: Roger Vernon <rvprivate@mantamedia.com>
Subject: Perl Win32 not working with browser...
Message-Id: <33981E51.728E@mantamedia.com>
I installed PERL Win/32. Everything installed great and my script runs
great from the command line. But when I have an HTML form call the
script it returns:
HTTP/1.0 501 Not Supported
What does this mean? Any help would be greatly appreciated.
------------------------------
Date: 6 Jun 1997 16:19:27 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Perl Win32 not working with browser...
Message-Id: <5n9daf$rh0@fridge-nf0.shore.net>
Roger Vernon (rvprivate@mantamedia.com) wrote:
: HTTP/1.0 501 Not Supported
: What does this mean? Any help would be greatly appreciated.
It means you're in the wrong newsgroup for your question. Please
refer to comp.infosystems.www.authoring.cgi and/or
comp.infosystems.www.servers.misc where your question would be
properly answered.
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: Fri, 6 Jun 1997 10:22:26 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Roger Vernon <rvprivate@mantamedia.com>
Subject: Re: Perl Win32 not working with browser...
Message-Id: <Pine.GSO.3.96.970606102208.21788b-100000@kelly.teleport.com>
On Fri, 6 Jun 1997, Roger Vernon wrote:
> Subject: Perl Win32 not working with browser...
> HTTP/1.0 501 Not Supported
When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to
solving such problems. It's available on the perl.com web pages. Hope
this helps!
http://www.perl.com/perl/
http://www.perl.com/perl/faq/
http://www.perl.com/perl/faq/idiots-guide.html
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 06 Jun 1997 10:43:53 -0600
From: rjray@tremere.ecte.uswc.uswest.com (Randy J. Ray)
Subject: Re: perlxs questions
Message-Id: <uowwwo7smuu.fsf@tremere.ecte.uswc.uswest.com>
Jon Slenk <jces@hotwired.com> writes:
>
> 2) the system has a whole slew of .h files that i guess i need to run
> through h2xs. i can't seem to get h2xs to process more than one .h file
> at a time. is that really how it's supposed to work? i mean, do i run it
> for each one and then somehow merge the results? or can i have it munge
> the whole set of include files at once (oh please)?
>
Unfortunately, h2xs can only auto-scan one header for an invocation. When
starting the Fvwm module, I have to run h2xs twice and merge the results.
Randy
--
===============================================================================
Randy J. Ray -- U S WEST Technologies IAD/CSS/DPDS Phone: (303)595-2869
Denver, CO rjray@uswest.com
"It's not denial. I'm just very selective about the reality I accept." --Calvin
------------------------------
Date: 6 Jun 1997 16:58:20 GMT
From: Darryl Caldwell <darrylc@eznet.com>
Subject: Printing Prime Numbers
Message-Id: <5n9fjc$p43$1@pepper.eznet.com>
A friend told me about a software test he had to do at a job interview.
He was told "print out all the prime numbers between 1 and 50." Coming
from a liberal arts background, I had to first find out what a prime
number _is_, then I set to working it out in Perl.
The result is below. Essential it first prints out 1 since we know that
it a prime number, then it discards even numbers. Next, it runs a series
of tests on the remain odd numbers. If the variable $b holds a decimal
number, it skips to the next TRY test, if it holds a whole number other
than 1, it stops the TRY test and begins the whole series again with the
next number from the initial range.
It took me a night to think about it to get it to work. I'm curious if
there are more efficient approaches. I am really interested in algorithms
-- one of my weaker areas. I wouldn't have been able to come up with
anything on the spot. I would appreciate any comments. Thanks.
#!perl
MAIN: foreach (1..50) { #grab main number from initial range
if ($_ =~ /^1\b/) { #1 is a prime, so print it
print "$_\n";
next;
}
$a = $_ / 2;
next MAIN if $a !~ /\./; #next if an even number
TRY: foreach $test (2..$_) { #start sublevel testing on odd
numbers
$b = $_ / $test;
next TRY if $b =~ /\./; #next if matches a decimal
if ($b !~ /^1\b/) {
last TRY; #whole number is not $_
} else {
print "$_\n";
last TRY;
}
}
}
Darryl Caldwell Oikiasuchou School
___________________________________________________
The Practice Hall: http://www.eznet.com/bravo/ph/ph.html
Myth & Martial Culture
------------------------------
Date: Fri, 06 Jun 1997 11:27:44 -0400
From: ekoontz@acsu.buffalo.edu
Subject: question about behavior of $&
Message-Id: <33982C70.32FB@cedar.buffalo.edu>
The following program :
-----------------------
#!/usr/local/bin/perl
$string1 = "hello";
$_ = $string1;
/hello/;
print "\$& contains $&\n";
/goodbye/;
print "\$& still contains $&\n";
------------------------
produces the output :
$& contains hello
$& still contains hello
According to the camel book, "$& returns the entire matched string",
p(105)
but it seems that what is actually going in is that
$& returns the last *SUCCESSFULLY* matched string.
Anyone know how to "clear" $& so that we can test for failed matches by
doing :
if (!$&) {
print "the regexp matching failed!";
}
Apologies if this is in the FAQ! Please refer me to the URL of the FAQ
if
so.
-Eugene Koontz
------------------------------
Date: 6 Jun 1997 16:38:18 GMT
From: "Brooks Davis" <brooks-n-janet@worldnet.att.net>
Subject: Re: script for log file
Message-Id: <01bc7298$1d0518c0$1f8493cf@Brooks.st.hmc.edu>
[CC sent to origional poster]
webadmin <webadmin@prestel.net> wrote in article
<339826BB.E4DB0287@prestel.net>...
> Does anyone know of a script which goes through access logs and just
> prints out byte usage, for each user. The users are not virtual users.
You'll find one I wrote at:
http://www3.hmc.edu/~brdavis/resources/programming/perl/scripts/
You'll definatly need to edit it some since it assumes things about
directory structure that are probably not valid for you, but the user part
should work fine.
-- Brooks
------------------------------
Date: 6 Jun 1997 16:24:32 GMT
From: "Brooks Davis" <brooks-n-janet@worldnet.att.net>
Subject: Re: Shared DBM files
Message-Id: <01bc7296$309281e0$1f8493cf@Brooks.st.hmc.edu>
Gene Johannsen <gej@spamalot.mfg.sgi.com> wrote in article
<5n91hl$3lh$1@murrow.corp.sgi.com>...
> I am working on a project where I'd like to use a DBM file to share
> data between two perl scripts, running at the same time.
>
> The problem is that there seems to be some sort of buffering causing
> the reading script not to see the data the writing script puts in
> there.
>
> Now, I know I can close and reopen the hash in order to get the data,
> but I'm wondering, is there an easier way?
With standard DBM, the answer is no. On the other hand, there are
syncronization and locking functions in Berkley DB.
-- Brooks
------------------------------
Date: 6 Jun 1997 14:33:07 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: String Compare Problem
Message-Id: <5n9733$k8u$1@dartvax.dartmouth.edu>
In article <5n718f$n2k$1@news.netusa.net>
Eli the Bearded <usenet-tag@qz.little-neck.ny.us> writes:
> Chipmunk <Ronald.J.Kimball@dartmouth.edu> wrote:
> > pcartier@ix.netcom.com (Paul Cartier) writes:
> > > Could someone give me an example on how I can search the
> > > begining of a string for a match.
> > ^ matches the beginning of a string.
> > $ matches the end of a string.
>
> Close, but no cigar. ^ matches the beginning of a line (or string)
> $ matches the end of a line (or string). \A matches the begining of
> a string. \Z matches the end of a string.
For the perlre manpages:
By default, the "^" character is guaranteed to match only at the
beginning of the string, the "$" character only at the end (or
before
the newline at the end)
In order to make ^ and $ match at the beginning/end of a line, you need
to use the /m modifier.
Chipmunk
------------------------------
Date: Fri, 6 Jun 1997 08:23:16 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Helmut Jarausch <jarausch@numa1.igpm.rwth-aachen.de>
Subject: Re: Tricky Syntax Question
Message-Id: <Pine.GSO.3.96.970606081735.21788S-100000@kelly.teleport.com>
On 6 Jun 1997, Helmut Jarausch wrote:
> my C++ background let my try the following construct which Perl (5.004)
> didn't like.
>
> push ( /\! / ? @Rest : @Selected ),$_;
>
> it says: Type of arg 1 to push must be array
>
> Now the question is - what is the type of a conditional expression
> if both alternatives are arrays?
In this case, they're lists instead of arrays. (The variable, which is an
array, is expanded to a list in that expression.)
I think this should do what you want. (I don't think you needed the
backslash in the regular expression, so I took it out.)
push @{ /! / ? \@Rest : \@Selected }, $_;
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Fri, 06 Jun 1997 11:10:40 -0400
From: Ty Cage Warren <tycage@infi.net>
Subject: Re: Tricky Syntax Question
Message-Id: <33982870.61B1C0A2@infi.net>
Helmut Jarausch wrote:
>
> Hi,
> my C++ background let my try the following construct which Perl (5.004)
> didn't like.
>
> push ( /\! / ? @Rest : @Selected ),$_;
This is returning the value of the array @Rest or the array @Selected,
which
isn't an lvalue, so you can't push something into it. You need to Have
the
?: return a reference to the array and then dereference it.
> it says: Type of arg 1 to push must be array
>
> Now the question is - what is the type of a conditional expression
> if both alternatives are arrays?
>
> Thanks for your opinions - current Perl's opinion isn't mine.
Try this:
push @{(/\! / ? \@Rest : \@Selected)},$_
\@Rest and \@Selected are references to the arrays.
the @{ } dereferences it into the array again.
Hope this helps,
Ty
+---+
Ty Cage Warren tycage@infi.net
Systems Engineer InfiNet
The Web Site of Love: http://tazer.engrs.infi.net/mst3k/
PGP Public Key: http://tazer.engrs.infi.net/~tycage/pgpkey.html
PGP Fingerprint: FF C1 28 CA 80 B5 31 78 B1 24 2E 8C AB DA FB D2
------------->Never invoke anything bigger than your head.<-------------
------------------------------
Date: Fri, 06 Jun 1997 17:56:34 +0200
From: Andrew Filip <news@alf.impaq.com.pl>
To: Helmut Jarausch <jarausch@numa1.igpm.rwth-aachen.de>
Subject: Re: Tricky Syntax Question
Message-Id: <33983332.D765258E@alf.impaq.com.pl>
Helmut Jarausch wrote:
> Hi,
> my C++ background let my try the following construct which Perl
> (5.004)
> didn't like.
>
> push ( /\! / ? @Rest : @Selected ),$_;
>
> it says: Type of arg 1 to push must be array
>
> Now the question is - what is the type of a conditional expression
> if both alternatives are arrays?
If I guess correctly this is what you want:
push @{ /! / ? \@Rest : \@Selected }, $_;
--
common sense is uncommon
------------------------------
Date: 6 Jun 1997 15:05:06 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Tricky Syntax Question
Message-Id: <5n98v2$33q$1@dartvax.dartmouth.edu>
In article <5n8nnu$h17$1@news.rwth-aachen.de>
jarausch@numa1.igpm.rwth-aachen.de (Helmut Jarausch) writes:
> push ( /\! / ? @Rest : @Selected ),$_;
>
> it says: Type of arg 1 to push must be array
>
> Now the question is - what is the type of a conditional expression
> if both alternatives are arrays?
This works:
push (1 ? @Rest : @Selected), $_;
However, note that $_ is not an argument to push in that line, because
of the parentheses.
This works and does what you expect:
push ( (1 ? @Rest : @Selected), $_);
Unfortunately, I can't get it to work with a pattern match as the
conditional, and I don't know why.
Chipmunk
------------------------------
Date: Fri, 6 Jun 1997 10:24:53 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Chipmunk <Ronald.J.Kimball@dartmouth.edu>
Subject: Re: Tricky Syntax Question
Message-Id: <Pine.GSO.3.96.970606102310.21788c-100000@kelly.teleport.com>
On 6 Jun 1997, Chipmunk wrote:
> This works and does what you expect:
> push ( (1 ? @Rest : @Selected), $_);
>
> Unfortunately, I can't get it to work with a pattern match as the
> conditional, and I don't know why.
The reason that that "works" is (I believe) that the optimizer replaces
the first argument with @Rest directly. So it's only useful if the
condition is known at compile time. :-(
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Fri, 6 Jun 1997 08:06:10 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Xran <xran@aol.com>
Subject: Re: Works in Shell, not as cgi
Message-Id: <Pine.GSO.3.96.970606080554.21788O-100000@kelly.teleport.com>
On 6 Jun 1997, Xran wrote:
> Subject: Works in Shell, not as cgi
When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to
solving such problems. It's available on the perl.com web pages. Hope
this helps!
http://www.perl.com/perl/
http://www.perl.com/perl/faq/
http://www.perl.com/perl/faq/idiots-guide.html
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Fri, 06 Jun 1997 17:43:42 GMT
From: danew@enterprise.net (Matthew Burnham)
Subject: Re: WTD: perl script for HTML list of Ph servers on the fly
Message-Id: <339b45cf.6518491@194.72.192.4>
atstarr@negia.net (Andrew Starr) wrote:
>See http://www.amherst.edu/~atstarr/computers/ph.html
>
>Currently, the table is created initially (or after losing track of what
>updates I've done manually) by obtaining the complete list of known Ph
>servers from ns.nwu.edu:
>
> ph://ns.nwu.edu/query%20ns-servers
>
>or
>
> in English: send command of "query ns-servers" to the Qi/Ph server:
> ns.nwu.edu
>
>I then used Word Perfect to do some search/replaces, imported the columns
>into a table, and used WordPerfect's save as HTML feature. Then, as I
>receive reports of updates or new servers, I pass them along to the person
>at Northwestern, and manually enter them into my HTML. When I fall behind
>and can't be sure I've found the various e-mails with the last few updates
>(yet knowing I forward them to NWU instantly upon reading the messages), I
>just redo the process described above for starting from scratch.)
So is the stuff received from ph://ns.nwu.edu/query%20ns-servers up to
date? Could that be queried and processed for each request (or say one a
day/week to make a 'static' html page that wouldn't need to access the
ph server all the time?)
--
Matthew Burnham, Manager, MindWeb | danew@enterprise.net
Commercial web design and hosting, reasonable rates
UKP24/Mb/Year for DIY space | mindweb@pobox.co.uk
FTP, CGI, password protection, etc. too!
http://www.virtual-pc.com/mindweb/
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 581
*************************************