[24539] in Perl-Users-Digest
Perl-Users Digest, Issue: 6717 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 22 21:05:50 2004
Date: Tue, 22 Jun 2004 18:05:06 -0700 (PDT)
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, 22 Jun 2004 Volume: 10 Number: 6717
Today's topics:
Re: 2 queries- first day of month and reading zipped f <ittyspam@yahoo.com>
Re: alternative to cwd() <usenet@morrow.me.uk>
anonymous fork, one writer, many readers (Edouard GAULUE)
Re: Help! - Need a CGI redirect which passes a querystr (Damon)
Re: Help! - Need a CGI redirect which passes a querystr <noreply@gunnar.cc>
Re: Help! - Need a CGI redirect which passes a querystr <matthew.garrish@sympatico.ca>
Idiom for partitioning array? <jkrugman345@yahbitoo.com>
Re: Idiom for partitioning array? <postmaster@castleamber.com>
Re: Idiom for partitioning array? <kha@rogers.com>
Re: Idiom for partitioning array? <wpiper@us.ibm.com>
Re: Idiom for partitioning array? ctcgag@hotmail.com
Re: Idiom for partitioning array? (J. Romano)
Re: if statement w/hash and subroutines <Joe.Smith@inwap.com>
IO:Select and writing a client <perl@my-header.org>
Re: IO:Select and writing a client <pinyaj@rpi.edu>
Re: IO:Select and writing a client <perl@my-header.org>
IRIX, freeware, ar, DynaLoader warning (Walter Roberson)
Re: join (@a, @b, @c) <Joe.Smith@inwap.com>
Re: Perl DNS reverse lookups -- multiple IP addresses p (Maynard)
Perl editors and debuggers <Bill_Fields@azb.uscourts.gov>
Re: Perl editors and debuggers <no_spam_for_jkeen@verizon.net>
Re: Perl editors and debuggers <invalid-email@rochester.rr.com>
Re: Problems with Mail::Mailer (Bill)
Re: uninit value puzzler <vticau@excite.com>
Using Perl to create user accounts on Windows 2003 (Maynard)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 22 Jun 2004 14:10:41 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: 2 queries- first day of month and reading zipped files directly off server
Message-Id: <20040622140641.I23512@dishwasher.cs.rpi.edu>
On Tue, 22 Jun 2004, Shalini Joshi wrote:
> Subject: 2 queries- first day of month and reading zipped files directly
> off server
It's usually better to restrict each message to a single topic.
> I am supposed to be writing perl code which , opens and reads a
> particular file only if it's the first day of the month; otherwise it
> reads another file always. I'd really appreciate any comments on how
> to proceed with this one.
What part do you need help with? What have you done so far? Where did
you get stuck?
Check out the documentations:
perldoc -f open
perldoc -f readline
perldoc Date::Manip
(as well as a plethora of various Date/Time modules available at cpan.org)
> Also, I would be reading the files off of a remote server, which
> stores these files in zipped format. The server allows us to download
> these files and then read them(parse them too), but I was wondering if
> to save on the download time(the files are financial price
> files....huge and updated daily) we could read the zipped files
> directly from the server???
I would think that depends on what kind of permissions you have on the
server. Do you have the ability to create new files, even temporary ones,
on the server? That would be the result of unzipping a zipped file to get
at its contents.
For actually making the transfers, try
perldoc Net::FTP or perldoc Net::SFTP
For the unzipping, search for 'zip' on CPAN.
> Can I accomplish all this in perl? Any help would be welcome, and as
> always, thanks a bunch for the help and tips in advance.
Read the documentations, make an attempt, and then post what you have when
you get stuck.
Paul Lalli
------------------------------
Date: Wed, 23 Jun 2004 00:13:55 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: alternative to cwd()
Message-Id: <cbai03$ge6$1@wisteria.csv.warwick.ac.uk>
Quoth ctcgag@hotmail.com:
> "Sunil" <sunil_franklin@hotmail.com> wrote:
> > Hi All,
> > I need to find the current working directory, Is there any
> > alternative to
> > use Cwd;
> > $pwd = cwd();
> >
> > I am looking for a solution other than using system() or backtics
> > (``).
>
> Ask Cwd how it does it.
>
> vi `perldoc -l Cwd`
or simply perldoc -m Cwd.
Ben
--
Although few may originate a policy, we are all able to judge it.
- Pericles of Athens, c.430 B.C.
ben@morrow.me.uk
------------------------------
Date: 22 Jun 2004 14:43:02 -0700
From: Edouard.Gaulue@ensg.ign.fr (Edouard GAULUE)
Subject: anonymous fork, one writer, many readers
Message-Id: <77a8fc.0406221343.19870327@posting.google.com>
Hi,
I'm lookink for help on a little script using the perl 'pipe' :
- pipe creation
- writing in the pipe (with $|=1)
- closing the writing side
- fork 1
while :
* reading in the pipe and showing
* waiting randomly
exit
- fork 2
while :
* reading in the pipe and showing
* waiting randomly
exit
- père
while :
* reading in the pipe and showing
* waiting randomly
exit
If I write in my pipe :
aze
qsd
wxc
I get 3 time those lines (whatever the order). I thought after a fork,
childrens and father dealt with the same count on the file in their
file descriptor so that a line read by one couldn't be read by
another.
Is that wrong ? How to do ? Is this link with the way 'pipe' has been
implemented in perl ? Will it work with a named pipe (I would have
prefered not to give any filename that mean controling access right to
this file) ? Your opinion ?
Thanks for your answers, EG
------------------------------
Date: 22 Jun 2004 16:52:37 -0700
From: damon@tribbledesigns.com (Damon)
Subject: Re: Help! - Need a CGI redirect which passes a querystring value
Message-Id: <fcd2095.0406221552.429e37ea@posting.google.com>
Thanks Matt,
My only problem now is that this is all happening on a windows server.
The code you provided doesn't seem to work in this environment. I just
get the following error: "%1 is not a valid Win32 application."
You see, we have several links hard-coded into our desktop application
like "http://www.mydomain.com/myPage.cgi?cnt=50" which now need to
point to "http://www.mydomain.com/myPage.aspx?cnt=50".
Is there any way to make myPage.cgi?cnt=50 redirect and preserve the
querystring on a windows server?
-Damon
"Matt Garrish" <matthew.garrish@sympatico.ca> wrote in message news:<ExMBc.8742$MU4.440144@news20.bellglobal.com>...
> "Damon" <damon@tribbledesigns.com> wrote in message
> news:fcd2095.0406211800.d1f3058@posting.google.com...
> > Hi all,
> >
> > I'm not very familiar with Perl and could use some help.
> >
> > I need to have the page "myPage.cgi?cnt=60" redirect to
> > "myPage.aspx?cnt=60". Can anyone give me an easy script for doing this
> > redirect?
> >
>
> Assuming that is the only variable you're expecting, you could use the
> following in myPage.cgi:
>
> use strict;
> use warnings;
> use CGI;
>
> my $q = new CGI;
>
> my $cnt = $q->param('cnt');
>
> print $q->redirect("http://wherever/myPage.aspx?cnt=$cnt");
>
>
> Matt
------------------------------
Date: Wed, 23 Jun 2004 02:28:37 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Help! - Need a CGI redirect which passes a querystring value
Message-Id: <2js16lF13b4tqU1@uni-berlin.de>
Damon wrote:
> Is there any way to make myPage.cgi?cnt=50 redirect and preserve the
> querystring on a windows server?
I don't understand why Matt's suggestion would not work on Windows.
Anyway, as long as the key and value only consist of ASCII characters,
this should be sufficient:
print 'Location: http://www.mydomain.com/myPage.aspx?',
"$ENV{QUERY_STRING}\n\n";
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 22 Jun 2004 20:29:58 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Help! - Need a CGI redirect which passes a querystring value
Message-Id: <fb4Cc.25944$Nz.1083541@news20.bellglobal.com>
"Damon" <damon@tribbledesigns.com> wrote in message
news:fcd2095.0406221552.429e37ea@posting.google.com...
> Thanks Matt,
>
> My only problem now is that this is all happening on a windows server.
> The code you provided doesn't seem to work in this environment. I just
> get the following error: "%1 is not a valid Win32 application."
>
> You see, we have several links hard-coded into our desktop application
> like "http://www.mydomain.com/myPage.cgi?cnt=50" which now need to
> point to "http://www.mydomain.com/myPage.aspx?cnt=50".
>
> Is there any way to make myPage.cgi?cnt=50 redirect and preserve the
> querystring on a windows server?
>
<please don't top-post>
The script I provided should work regardless of what value of cnt is passed
to it. The error you note sounds like it's in the way that you have the .cgi
extension mapped. Do any .cgi scripts work on your server?
Matt
------------------------------
Date: Tue, 22 Jun 2004 18:57:38 +0000 (UTC)
From: J Krugman <jkrugman345@yahbitoo.com>
Subject: Idiom for partitioning array?
Message-Id: <cb9vf2$hp5$1@reader2.panix.com>
Is there a nice Perl idiom for partitioning an array of length N
into "subarrays of length n" (i.e. array refs pointing to arrays
of length n)? (If N is not a multiple of n, the last entry of the
partitioned array should be a subarray of length N mod n.) For
example, if n = 3, and the input array is
('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')
the partitioned array should be:
(['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h'])
TIA,
jill
--
To s&e^n]d me m~a}i]l r%e*m?o\v[e bit from my a|d)d:r{e:s]s.
------------------------------
Date: Tue, 22 Jun 2004 14:25:45 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Idiom for partitioning array?
Message-Id: <40d887c2$0$190$58c7af7e@news.kabelfoon.nl>
J Krugman wrote:
> Is there a nice Perl idiom for partitioning an array of length N
> into "subarrays of length n" (i.e. array refs pointing to arrays
> of length n)? (If N is not a multiple of n, the last entry of the
> partitioned array should be a subarray of length N mod n.) For
> example, if n = 3, and the input array is
>
> ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')
>
> the partitioned array should be:
>
> (['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h'])
>
while (my @seg = splice @array, 0, $length) { push @newarray, \@seg }
--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Tue, 22 Jun 2004 19:33:02 GMT
From: Kien Ha <kha@rogers.com>
Subject: Re: Idiom for partitioning array?
Message-Id: <OP%Bc.455229$Ar.228163@twister01.bloor.is.net.cable.rogers.com>
J Krugman wrote:
> Is there a nice Perl idiom for partitioning an array of length N
> into "subarrays of length n" (i.e. array refs pointing to arrays
> of length n)? (If N is not a multiple of n, the last entry of the
> partitioned array should be a subarray of length N mod n.) For
> example, if n = 3, and the input array is
>
> ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')
>
> the partitioned array should be:
>
> (['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h'])
>
push @subarrays, [splice @array, 0, $n] while @array;
------------------------------
Date: Tue, 22 Jun 2004 15:57:51 -0400
From: William Piper <wpiper@us.ibm.com>
Subject: Re: Idiom for partitioning array?
Message-Id: <40D88F3F.43381BE5@us.ibm.com>
J Krugman wrote:
>
> Is there a nice Perl idiom for partitioning an array of length N
> into "subarrays of length n" (i.e. array refs pointing to arrays
> of length n)? (If N is not a multiple of n, the last entry of the
> partitioned array should be a subarray of length N mod n.) For
> example, if n = 3, and the input array is
>
> ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')
>
> the partitioned array should be:
>
> (['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h'])
'splice' does a nice job, if you don't care about destroying
the original array.
#! perl
use warnings; use strict ;
my @array = ('a' .. 'h' ) ;
my $n = 3 ;
my @subarrays ;
while ( @array ) {
push @subarrays, [ splice( @array, 0, $n ) ] ;
}
use Data::Dumper ;
print Dumper( \@subarrays ) ;
__END__
-piper
------------------------------
Date: 22 Jun 2004 20:25:39 GMT
From: ctcgag@hotmail.com
Subject: Re: Idiom for partitioning array?
Message-Id: <20040622162539.749$mb@newsreader.com>
J Krugman <jkrugman345@yahbitoo.com> wrote:
> Is there a nice Perl idiom for partitioning an array of length N
> into "subarrays of length n" (i.e. array refs pointing to arrays
> of length n)? (If N is not a multiple of n, the last entry of the
> partitioned array should be a subarray of length N mod n.) For
> example, if n = 3, and the input array is
>
> ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')
If you don't mind destroying the original:
my @result;
push @result, [splice @x,0,3] while (@x);
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 22 Jun 2004 16:48:41 -0700
From: jl_post@hotmail.com (J. Romano)
Subject: Re: Idiom for partitioning array?
Message-Id: <b893f5d4.0406221548.4a842e75@posting.google.com>
J Krugman <jkrugman345@yahbitoo.com> wrote in message news:<cb9vf2$hp5$1@reader2.panix.com>...
>
> Is there a nice Perl idiom for partitioning an array of length N
> into "subarrays of length n" (i.e. array refs pointing to arrays
> of length n)? (If N is not a multiple of n, the last entry of the
> partitioned array should be a subarray of length N mod n.) For
> example, if n = 3, and the input array is
>
> ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')
>
> the partitioned array should be:
>
> (['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h'])
It might not be a nice Perl idiom "per se", but here is a simple
piece of code that gets the job done:
Say you have:
@a = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h');
$n = 3;
If you want to make @b an array of @a partitions, use a temporary
array in a loop, which I call @partition:
while ( @partition = splice(@a, 0, $n) )
{
push @b, [ @partition ];
}
Here is the same code as a one-liner:
while (@p = splice(@a, 0, $n)) { push @b, [ @p ] }
Now you can see your results with the Data::Dumper module:
use Data::Dumper;
print Dumper @b;
Which gives:
( ['a','b','c'], ['d','e','f'], ['g','h'] )
I hope this helps, Jill.
-- Jean-Luc
------------------------------
Date: Tue, 22 Jun 2004 20:06:05 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: if statement w/hash and subroutines
Message-Id: <Ni0Cc.76566$Hg2.15974@attbi_s04>
Mark Connell wrote:
> MICe(%Newsq);
> or
> MICe(%Seqac);
You'd be better off using
MICe(\%Newsq);
or
MICe(\%Seqac);
and change sub MICe to expect a reference to a hash.
-Joe
------------------------------
Date: Tue, 22 Jun 2004 20:16:49 +0200
From: Matija Papec <perl@my-header.org>
Subject: IO:Select and writing a client
Message-Id: <bstgd0tddk13mva9hh3qbe0j235t2s1nqr@4ax.com>
I want to use IO::Select::select in my client because this is requirement
and because it should be nice wrapper around plain select(), however I don't
know what to do with handles it returns (read => $rh, write => $wh,
exception => $xh) :!
I would appreciate some hints, as POD doesn't talk much about them.
==================
my $timeout = 5;
my $conn = IO::Socket::INET->new(
PeerAddr => 'localhost', PeerPort => 32080,
Proto => "tcp", Type => SOCK_STREAM,
) or fatal_error();
my $ctrl = IO::Select->new($conn);
while (1) {
select();
my ($rh, $wh, $xh) = IO::Select::select($ctrl, $ctrl, $ctrl, $timeout);
....
==================
--
Matija
------------------------------
Date: Tue, 22 Jun 2004 14:29:40 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: IO:Select and writing a client
Message-Id: <Pine.SGI.3.96.1040622142634.31697C-100000@vcmr-64.server.rpi.edu>
On Tue, 22 Jun 2004, Matija Papec wrote:
>I want to use IO::Select::select in my client because this is requirement
>and because it should be nice wrapper around plain select(), however I don't
>know what to do with handles it returns (read => $rh, write => $wh,
>exception => $xh) :!
> my $timeout = 5;
> my $conn = IO::Socket::INET->new(
> PeerAddr => 'localhost', PeerPort => 32080,
> Proto => "tcp", Type => SOCK_STREAM,
> ) or fatal_error();
>
> my $ctrl = IO::Select->new($conn);
>
> while (1) {
> select();
That line is useless.
> my ($rh, $wh, $xh) = IO::Select::select($ctrl, $ctrl, $ctrl, $timeout);
Here, $rh, $wh, and $xh are references to arrays, and each element in
those arrays are handles that can be read from (or written to, or have
exceptions).
Maybe you'd understand it better like this:
my $set = IO::Select->new($conn);
my @can_read = $set->can_read($timeout);
my @can_write = $set->can_write($timeout);
my @has_exception = $set->has_exception($timeout);
That does the same thing (albeit with three commands).
--
Jeff Pinyan RPI Acacia Brother #734 RPI Acacia Corp Secretary
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: Tue, 22 Jun 2004 22:43:12 +0200
From: Matija Papec <perl@my-header.org>
Subject: Re: IO:Select and writing a client
Message-Id: <se6hd0tsbspr2ej3ufvmnq9q4kp026fb7i@4ax.com>
X-Ftn-To: Jeff 'japhy' Pinyan
Jeff 'japhy' Pinyan <pinyaj@rpi.edu> wrote:
>> my $ctrl = IO::Select->new($conn);
>>
>> while (1) {
>> select();
>
>That line is useless.
Indeed; I added it hoping to introduce IO blocking since while loop eat all
cpu time.
>> my ($rh, $wh, $xh) = IO::Select::select($ctrl, $ctrl, $ctrl, $timeout);
>
>Here, $rh, $wh, and $xh are references to arrays, and each element in
>those arrays are handles that can be read from (or written to, or have
>exceptions).
That makes sense, so theoretically IO:Socket handle could be in @$rh and
@$wh at the same time?
>Maybe you'd understand it better like this:
>
> my $set = IO::Select->new($conn);
> my @can_read = $set->can_read($timeout);
> my @can_write = $set->can_write($timeout);
> my @has_exception = $set->has_exception($timeout);
>
>That does the same thing (albeit with three commands).
tnx!
--
Matija
------------------------------
Date: 22 Jun 2004 21:39:28 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: IRIX, freeware, ar, DynaLoader warning
Message-Id: <cba8ug$odg$1@canopus.cc.umanitoba.ca>
"Been there, got bit by that."
When building perl 5.8.4 under fully patched IRIX 6.5.17f, I was
receiving linker messages about DynaLoader.a not containing any global
symbols, and that boot_DynaLoader could not be found. I had not
had this problem with previous 5.8.* or 5.6.* .
'nm' and 'elfdump' appeared to show that the archive did indeed define
global symbols, and that it did indeed define the missing symbol.
When I extracted DynaLoader.o from the .a then I could link against
it with no problems -- the symbol showed up when I did that.
I tracked the problem down to the fact that it was the IRIX freeware
version of ar (/usr/freeware/bin/ar) being used to generate the
DynaLoader.a (because I had the freeware directory first in my path
while doing the ./Configure). When I editted config.sh and forced
the IRIX native ar and rebuilt, the problem disappeared.
I recall having read about a similar gnu ar versus IRIX problem before,
and it is possible that one of the various upgrades I happened to do
between the time of building 5.8.3 and 5.8.4 was responsible for the
new incompatible software versions. The problem might perhaps hit other
perl builds if one is fully patched with the latest IRIX freeware .
Anyhow, if IRIX people happen to see messages about non-existant
symbols that they are sure exist, then check to see which 'ar' was
used to build the archive.
--
Is "meme" descriptive or perscriptive? Does the knowledge that
memes exist not subtly encourage the creation of more memes?
-- A Child's Garden Of Memes
------------------------------
Date: Tue, 22 Jun 2004 20:13:28 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: join (@a, @b, @c)
Message-Id: <Ip0Cc.94176$Sw.63329@attbi_s51>
Ken Sington wrote:
> well, if I have an unknown number of arrays like @a...@z...@veryBig.
my @aoa = (\@a, \@b); # Use an array of arrays
push @aoa,$_ while $_ = read_array_from_file_and_return_reference();
print joinarrays(@aoa);
-Joe
------------------------------
Date: 22 Jun 2004 15:05:12 -0700
From: rev_maynard3@hotmail.com (Maynard)
Subject: Re: Perl DNS reverse lookups -- multiple IP addresses per line
Message-Id: <a4847dc.0406221405.e4d42d@posting.google.com>
Petri <Petri_member@newsguy.com> wrote...
> It may be useful at the OP's network.
> He might be running split-DNS, with an internal reverse zone for
> 0.0.168.192.in-addr.arpa.
> In that case he would catch names of internal systems, instead of their
> IP-addresses.
Which is true in my case. Those get translated to host names on my
network, which is always nice.
Thanks everyone for your responses and suggestions; I took some of
them and implemented a couple extras... like a hash file that "caches"
names/IPs, so that only new ones get looked up (saves tons of time
when there's a 2 second delay when a host doesn't have a DNS record),
and just for you John, I added a switch that skips non-routable IP
addrs, just in case you want to do that.
Full script below:
#/////////////////////////////////////////////
# NAME: IPtoName.pl
#
# CREATED: 6/18/04
#
# SYNTAX: perl IPtoName.pl -i <IN File> -o <OUT file> [-n]
#
# NOTES: Changes all IP addresses to DNS names in a text file
#/////////////////////////////////////////////
use Socket;
use Getopt::Std;
#/////////////////////////////////////////////
# Global Variables
#/////////////////////////////////////////////
my $SCRIPTVERSION = ".1";
my ($g_ip, $g_hostname);
my ($g_SourceFile, $g_DestFile);
my $g_divider;
use vars qw($opt_i $opt_o $opt_n);
getopts('i:o:n');
#/////////////////////////////////////////////
# Main
#/////////////////////////////////////////////
init_process();
check_vars();
process_log();
finish();
#/////////////////////////////////////////////
# Subroutines
#/////////////////////////////////////////////
# DISPLAY TITLE
sub init_process {
print "\n IP to Name conversation script, v$SCRIPTVERSION\n\n";
}
# PRINT ERROR MESSAGE AND EXIT
sub print_err {
print "@_[0]: $!\n\n";
die;
}
# CHECK VARIALBLES FOR CORRECT USAGE
sub check_vars {
if (!$opt_i || !$opt_o) {
show_usage();
print_err("ERROR: You must specify both input and output files");
}
}
# CALL TO OPEN, PARSE, & CLOSE LOG FILES
sub process_log {
open_logs();
convert_IPs_to_names();
close_logs();
}
# OPEN / CREATE LOG FILES
sub open_logs {
open(INPUTFILE, "<$opt_i") || print_err("ERROR: Cannot open $opt_i");
open(OUTPUTFILE, ">$opt_o") || print_err("ERROR: Cannot open
$opt_o");
binmode INPUTFILE;
binmode OUTPUTFILE;
}
# READ LOG FILE AND CONVERT IP ADDRESSES TO DNS NAMES
sub convert_IPs_to_names {
my %host_table = ();
while(my $line = <INPUTFILE>) {
while ($line =~ /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})[\: ]/g) {
if ($opt_n && ($1 =~ /^192.168./ || $1 =~ /^10./ || $1 =~
/^172.16./ || $1 =~ /^127./)) {
next;
}
$g_ip = $1;
if (exists($host_table{$g_ip})) {
$g_hostname = $host_table{$g_ip};
}
else {
$g_hostname = lc gethostbyaddr(inet_aton($g_ip),AF_INET);
$host_table{$g_ip} = $g_hostname;
}
$~ = OUTPUT_IP_ADDRESS;
if ($g_hostname ne "") {
$g_divider = ">";
$line =~ s/$g_ip/$g_hostname/g;
}
else {
$g_divider = " ";
}
write;
}
print OUTPUTFILE $line;
}
%host_table = ();
}
# CLOSE LOG FILES
sub close_logs {
close(INPUTFILE);
close(OUTPUTFILE);
}
# CLOSING STATEMENT
sub finish {
}
# SHOW USER THE PROPER USAGE / SYNTAX
sub show_usage {
print "\n\n";
print "USAGE: perl $0 -i <INPUT FILE> -o <OUTPUT FILE> [-n]";
print "\n\n";
print " -i File with IP addresses. This file will not be
modified.\n";
print " -o File with freshly converted names, instead of IP
addrs.\n";
print " -n Skip non-routable IP addresses (192.168.0.0,
172.16.0.0,\n";
print " 10.0.0.0, and 127.0.0.0).\n";
print "\n\n";
}
format OUTPUT_IP_ADDRESS=
@<<<<<<<<<<<<<< @
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$g_ip $g_divider $g_hostname
.
------------------------------
Date: Tue, 22 Jun 2004 14:38:05 -0700
From: "William Fields" <Bill_Fields@azb.uscourts.gov>
Subject: Perl editors and debuggers
Message-Id: <cba8rv$plc$1@apollo.nyed.circ2.dcn>
Hello,
Just looking for recommendations.
Thanks.
--
William Fields
MCSD - Microsoft Visual FoxPro
MCP - Win2k Pro
US Bankruptcy Court
Phoenix, AZ
"I love deadlines. I love the whooshing sound they make as they fly by."
- Douglas Adams (R.I.P.)
------------------------------
Date: Tue, 22 Jun 2004 21:52:25 GMT
From: "Jim Keenan" <no_spam_for_jkeen@verizon.net>
Subject: Re: Perl editors and debuggers
Message-Id: <tS1Cc.27691$U.7931@nwrdny02.gnilink.net>
"William Fields" <Bill_Fields@azb.uscourts.gov> wrote in message
news:cba8rv$plc$1@apollo.nyed.circ2.dcn...
> Hello,
>
> Just looking for recommendations.
>
This has been discussed to death on this list. Please Google 'Perl editor'.
------------------------------
Date: Wed, 23 Jun 2004 00:53:33 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Perl editors and debuggers
Message-Id: <40D8D477.6090008@rochester.rr.com>
William Fields wrote:
...
> Just looking for recommendations.
...
My recommendation is to read the FAQ:
perldoc -q editor
perldoc -q debug
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: 22 Jun 2004 15:58:53 -0700
From: wherrera@lynxview.com (Bill)
Subject: Re: Problems with Mail::Mailer
Message-Id: <239ce42f.0406221458.6acb6425@posting.google.com>
nodiseos@yahoo.com (nikko) wrote in message news:<f5912a4f.0406212158.29fcb7bf@posting.google.com>...
> Mail::Mailer and send using the smtp method (which involkes
> Net::SMTP). The sender info is included in the headers and most people
> they reverse lookup the senders domain and for this they do not use
> the header address but the SMTP MAIL FROM: address. Since this is not
> I'd rather not change the script too much and was wonderng if it is
> possible to make this work with Mail::Mailer.
>
> The code is:
> my $date = "$wday $mday $mon $year $hour:$min:$sec GMT";
> my $mailserver = "smtp.xyz.com";
> my $mailer = new Mail::Mailer('smtp', Server => $mailserver);
>
> my(%headers) = ('To' => "$company",
> 'Bcc' => "licenses\@amer.xyz.com",
> 'From' => "ts-systems\@xyz.com",
> 'Subject' => "Your Info",
> 'Date' => $date,
> );
> $mailer->open(\%headers);
>
> I added
> 'mail' => "ts-systems\@xyz.com",
> but this did not help.
> Any ideas?
Since the mail module is configured in your script to use Net::SMTP,
why not run a few Net::SMTP trials with different commands until you
have the one that works, then pass the arguments to the Mail::Mailer
constructor?
If you have access to them, a debug level logfile of the SMTP server
in question of both a successful mail send session and one ultimately
rejected would tell you the differences. I wonder about the Hello
name, for example.
--hth.
------------------------------
Date: Tue, 22 Jun 2004 22:05:16 GMT
From: vali <vticau@excite.com>
Subject: Re: uninit value puzzler
Message-Id: <40D8A44A.4030303@excite.com>
Walter Roberson wrote:
>I am trying to figure out the logical error in the following code snippit.
>
>Assume, please, that the code is 'use strict' and 'use warnings' clean.
>Also assume, please, that $nhit_href is a valid hash reference, and that
>it would be relatively common for $nhit_href->{$key} to not already
>exist.
>
>
> my $newcount = 1;
> $newcount = $nhit_href->{$key} + 1
> if exists $nhit_href->{$key} && defined $nhit_href->{$key};
>
>
>The problem: from time to time (but not at all often), I get the message:
>
>Use of uninitialized value in addition (+) at /usr/people/roberson/src/CacheUtils.pm line 242.
>
>where line 242 is the second statement.
>
>
>Have I perhaps missed something in operator precidences? Under what
>circumstances might I be trying to increment an uninitialized
>$nhit_href->{$key} considering that I -thought- the code is checking for
>existance and definedness before attempting the increment?
>
>
Just a guess; check if the $key is defined as well ;-)
$newcount = $nhit_href->{$key} + 1
if defined $key and exists $nhit_href->{$key} and defined
$nhit_href->{$key};
__Vali
------------------------------
Date: 22 Jun 2004 14:33:29 -0700
From: rev_maynard3@hotmail.com (Maynard)
Subject: Using Perl to create user accounts on Windows 2003
Message-Id: <a4847dc.0406221333.227bc2c7@posting.google.com>
Hello all,
I have Windows 2003 FTP servers that I store content on for external
users to pick up on a schedule. Unfortunately I have about 300 of
such users, and multiple servers. The time and energy to create these
user accounts is obviously a factor, especially if I have to rebuild a
box and have it up and running quickly.
So, I went looking for Perl scripts / modules that could do this, but
all I came up with was some old (for NT4) ones that used
Win32::Lanman. I'm not creating domain (Active Directory) accounts,
just local ones on the box. I have the users in a comma-delimited
file, and really just need a shove in the right direction.
Any suggestions would be most appreciated.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 6717
***************************************