[24644] in Perl-Users-Digest
Perl-Users Digest, Issue: 6808 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 3 13:11:47 2004
Date: Tue, 3 Aug 2004 10:10:56 -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, 3 Aug 2004 Volume: 10 Number: 6808
Today's topics:
histogram and perl (Andrea Spitaleri)
Re: histogram and perl (Anno Siegel)
Re: histogram and perl <1usa@llenroc.ude.invalid>
Re: histogram and perl <abigail@abigail.nl>
Re: histogram and perl (Andrea Spitaleri)
Re: histogram and perl (Andrea Spitaleri)
How can I perform search & proximity-replace over multi <jumper_bones@hotmail.com>
Re: How can I perform search & proximity-replace over m (Anno Siegel)
Re: How can I perform search & proximity-replace over m <usenet@vyznev.invalid>
How can I resolve this error Couldn't open encmap utf- (KoB)
Re: How can I resolve this error Couldn't open encmap <tore@aursand.no>
Re: How do I end processes that time out? <usenet@vyznev.invalid>
Re: How to compile Perl script to Win32 dll? <Joe.Smith@inwap.com>
Re: How to compile Perl script to Win32 dll? <bart.lateur@pandora.be>
Re: How to compile Perl script to Win32 dll? <1usa@llenroc.ude.invalid>
How to find directories (Bern)
Re: How to find directories <mritty@gmail.com>
Re: How to find directories <jurgenex@hotmail.com>
Re: How to find directories <gogala@sbcglobal.net>
How to know wheter a certain IP address belongs to give <artgh@hotmail.com>
Re: How to know wheter a certain IP address belongs to <matthew.garrish@sympatico.ca>
Re: How to know wheter a certain IP address belongs to <segraves_f13@mindspring.com>
How to print to more than one output (Bern)
Re: How to print to more than one output 510046470588-0001@t-online.de
Re: How to print to more than one output <jgibson@mail.arc.nasa.gov>
Re: How to print to more than one output (Anno Siegel)
Re: How to print to more than one output <nobull@mail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 30 Jul 2004 03:23:43 -0700
From: spiritelllo@interfree.it (Andrea Spitaleri)
Subject: histogram and perl
Message-Id: <4de1519a.0407300223.22a0bee4@posting.google.com>
Hi folks,
I am stuck with a problem. Here it is:
I have got an @array1 and I would like to calculate the frequency of
its element by a range. In few words, build an histogram.
this is my ex code:
#!/usr/bin/perl -w
@value = (48,49,50,46,47,47,35,38,40,42,45,47,48,44,43,46,45,42,43,47);
@sort = sort {$a<=>$b} @value;
$last=$sort[$#sort];
$range = $last - $sort[0];
$classes=5;
$interval = $range / $classes;
$count=0;
$tot=$sort[0];
while ($count<$classes){
# print "$tot\n";
$i=$tot;
$tot=$tot+$interval;
$hash{$i}=$tot;
# print "$tot\n";
# print "---\n";
++$count;
}
$j=1;
@new=$sort[0];
foreach $key (sort{$hash{$a}<=>$hash{$b}} keys %hash){
print "interval $j $key =>> $hash{$key}\n";
push @new,$hash{$key};
++$j;
}
# that's wrong..I know :) but it is just to explain what I am trying
to do
#in fact it gives weird results, as 35 > 40...
for ($im=0;$im<$#sort;++$im){
foreach $key (sort{$hash{$a}<=>$hash{$b}} keys %hash){
if (($sort[$im]>$key) && ($sort[$im]<$hash{$key})){
print "$sort[$im]>$key && $sort[$im]<$hash{$key}\n";
}
}
}
./hystogram.pl
interval 1 35 =>> 38
interval 2 38 =>> 41
interval 3 41 =>> 44
interval 4 44 =>> 47
interval 5 47 =>> 50
what I don't know how to do it is to calculate the frequency of my
@value element respect to the five intervals. I should get an output
like that, with an extra column, which represents the frequency:
interval 1 35 =>> 38 1
interval 2 38 =>> 41 2
interval 3 41 =>> 44 4
interval 4 44 =>> 47 5
interval 5 47 =>> 50 8
thanks for any help
regards
andrea
ps. BTW, I need to feed then gnuplot for making the graph.
------------------------------
Date: 30 Jul 2004 11:17:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: histogram and perl
Message-Id: <cedaoh$gvq$1@mamenchi.zrz.TU-Berlin.DE>
Andrea Spitaleri <spiritelllo@interfree.it> wrote in comp.lang.perl.misc:
> Hi folks,
> I am stuck with a problem. Here it is:
> I have got an @array1 and I would like to calculate the frequency of
> its element by a range. In few words, build an histogram.
> this is my ex code:
>
> #!/usr/bin/perl -w
No strict, no warnings.
> @value = (48,49,50,46,47,47,35,38,40,42,45,47,48,44,43,46,45,42,43,47);
>
> @sort = sort {$a<=>$b} @value;
>
> $last=$sort[$#sort];
>
> $range = $last - $sort[0];
There is no need to sort the array. All you need is the maximum and
the minimum. List::Util can give you those.
> $classes=5;
>
> $interval = $range / $classes;
>
> $count=0;
> $tot=$sort[0];
> while ($count<$classes){
> # print "$tot\n";
> $i=$tot;
> $tot=$tot+$interval;
> $hash{$i}=$tot;
> # print "$tot\n";
> # print "---\n";
> ++$count;
> }
> $j=1;
> @new=$sort[0];
> foreach $key (sort{$hash{$a}<=>$hash{$b}} keys %hash){
> print "interval $j $key =>> $hash{$key}\n";
> push @new,$hash{$key};
> ++$j;
> }
>
> # that's wrong..I know :) but it is just to explain what I am trying
> to do
Frankly, I'm not sure what you're up to with that code. The verbal
description was clearer :)
In any case, a hash is probably not the structure you want to use
for this problem.
[snip]
There must be lots of ways to do this. I'd define a function that
maps a value onto its class number, given the value, the range and
the number of classes.
sub range_number {
my ( $x, $a, $b, $n) = @_;
int ($x - $a)*$n/( $b - $a);
}
We'll also want a (kind of) inverse of that function: Given a class
number, return the range:
sub range {
my ( $i, $a, $b, $n) = @_;
my $from = $a + $i*($b - $a)/$n;
my $to = $from + ($b - $a)/$n;
( $from, $to);
}
Now build the histogram in an array:
use List::Utils qw( min max);
my @value = (48,49,50,46,47,47,35,38,40,42,45,47,48,44,43,46,45,42,43,47);
my $a = min( @value);
my $b = max( @value);
my $n = 5;
my @histo = ( 0) x $n;
$histo[ range_number( $_, $a, $b, $n)] ++ for @value;
...and show it:
for ( 0 .. $#histo ) {
my ( $from, $to) = range( $_, $a, $b, $n);
print "$_: [$from, $to] -> $histo[ $_]\n";
}
Anno
------------------------------
Date: 30 Jul 2004 13:03:35 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: histogram and perl
Message-Id: <Xns95365C29250Dasu1cornelledu@132.236.56.8>
spiritelllo@interfree.it (Andrea Spitaleri) wrote in
news:4de1519a.0407300223.22a0bee4@posting.google.com:
> Hi folks,
> I am stuck with a problem. Here it is:
...
> ps. BTW, I need to feed then gnuplot for making the graph.
I am assuming this not a learning exercise:
http://search.cpan.org/~colink/Statistics-Descriptive-2.6/Descriptive.pm
--
A. Sinan Unur
1usa@llenroc.ude.invalid
(remove '.invalid' and reverse each component for email address)
------------------------------
Date: 30 Jul 2004 23:06:24 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: histogram and perl
Message-Id: <slrncgll3f.6hs.abigail@alexandra.abigail.nl>
Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMMCMLXXXVI
September MCMXCIII in <URL:news:cedaoh$gvq$1@mamenchi.zrz.TU-Berlin.DE>:
-: Andrea Spitaleri <spiritelllo@interfree.it> wrote in comp.lang.perl.misc:
-: >
-: > #!/usr/bin/perl -w
-:
-: No strict, no warnings.
Hmmm. What does -w do in your version of Perl?
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
------------------------------
Date: 2 Aug 2004 04:07:51 -0700
From: spiritelllo@interfree.it (Andrea Spitaleri)
Subject: Re: histogram and perl
Message-Id: <4de1519a.0408020307.33e67c8b@posting.google.com>
> Now build the histogram in an array:
> use List::Utils qw( min max);
it works with List::Util (as you said earlier) :)
except that, it works perfectly.
thanks
andrea
------------------------------
Date: 2 Aug 2004 11:25:27 -0700
From: spiritelllo@interfree.it (Andrea Spitaleri)
Subject: Re: histogram and perl
Message-Id: <4de1519a.0408021025.153eaa10@posting.google.com>
> http://search.cpan.org/~colink/Statistics-Descriptive-2.6/Descriptive.pm
that's even gorgeous! :)
thanks a lot!
and
------------------------------
Date: Fri, 23 Jul 2004 10:33:06 -0500
From: Jumper Bones <jumper_bones@hotmail.com>
Subject: How can I perform search & proximity-replace over multiple lines in C source
Message-Id: <Xns952F7582A1558jumperboneshotmail@216.196.97.131>
Hello, I am new to Perl, and I have a need to search for a certain function
call in a C source code file, and then look ahead a given range of lines of
varying code following that function to see if a different function call
exists below it (within that range). If it finds that "different" function
below it, I need to edit its argument(s) with new arguments.
You see, I have so many of these edits to make over so many source code
files (thousands, actually) that I'd like to get some guidance on how to do
this more efficiently.
Also, if I'm better off using Vim to do this, that's fine too. Either
way, I just need someone to point me in a direction on what might be a
solid way of acheiving this..
Thanks in advance,
Jumper Bones
------------------------------
Date: 23 Jul 2004 17:44:42 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How can I perform search & proximity-replace over multiple lines in C source
Message-Id: <cdriqa$gsm$1@mamenchi.zrz.TU-Berlin.DE>
Jumper Bones <jumper_bones@hotmail.com> wrote in comp.lang.perl.misc:
> Hello, I am new to Perl, and I have a need to search for a certain function
> call in a C source code file, and then look ahead a given range of lines of
> varying code following that function to see if a different function call
> exists below it (within that range). If it finds that "different" function
> below it, I need to edit its argument(s) with new arguments.
>
> You see, I have so many of these edits to make over so many source code
> files (thousands, actually) that I'd like to get some guidance on how to do
> this more efficiently.
The answer is, as usual, it depends.
It depends mostly on the variability of the call patterns involved.
If these are guaranteed to be formatted in some reasonably easy-to-match
way, a simple Perl program involving pattern matching will do. If not,
nothing short of a full C parser will.
I think there is a C parser (or more) on CPAN, but I don't know how
well they work, nor how easy they are to apply.
If you can find a tool to identify all calls to a function, you could
use its output to guide a Perl program through the source. It could
fix the calls it recognizes and leave notes about the others to fix
manually. Any cross-referencing tool should be able to provide the
input.
This approach looks most promising to me, but it will involve some
substantial Perl programming. In particular, parsing the output
of another program often isn't trivial.
> Also, if I'm better off using Vim to do this, that's fine too. Either
> way, I just need someone to point me in a direction on what might be a
> solid way of acheiving this..
If you want to get fancy, you could output the info about manual fixes
in Vim's QuickFix format. Then you can jump from one place to the
next one, even across files. That could be fun, but it's probably not
worth while in a one-off project.
Anno
------------------------------
Date: Fri, 23 Jul 2004 22:44:17 +0300
From: Ilmari Karonen <usenet@vyznev.invalid>
Subject: Re: How can I perform search & proximity-replace over multiple lines in C source
Message-Id: <slrncg2qkh.vf.usenet@yhteiskone.vyznev.net>
On 2004-07-23, Jumper Bones <jumper_bones@hotmail.com> wrote:
> Hello, I am new to Perl, and I have a need to search for a certain function
> call in a C source code file, and then look ahead a given range of lines of
> varying code following that function to see if a different function call
> exists below it (within that range). If it finds that "different" function
> below it, I need to edit its argument(s) with new arguments.
Assuming you've already got regexps to match those functions:
use constant RANGE => 10;
my $line = - RANGE;
while (<>) {
/$certain_function/ and $line = $.;
s/$other_function/edit_args($&)/eg if $. < $line + RANGE;
print;
}
--
Ilmari Karonen
If replying by e-mail, please replace ".invalid" with ".net" in address.
------------------------------
Date: 29 Jul 2004 11:27:08 -0700
From: kobrien_ie@yahoo.ie (KoB)
Subject: How can I resolve this error Couldn't open encmap utf-16le.enc:
Message-Id: <3480b70d.0407291027.138bd9e9@posting.google.com>
I appear to be missing an encoding map. I need to convert a file with
utf16-le to utf8 and have not been able to locate any possible
solutions so far to help me do this. I suspect I need to create a
mapping file to resolve this. Appreciate any input.
Thansk
Ken
------------------------------
Date: Mon, 02 Aug 2004 01:44:13 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: How can I resolve this error Couldn't open encmap utf-16le.enc:
Message-Id: <pan.2004.08.01.23.44.13.826762@aursand.no>
On Thu, 29 Jul 2004 11:27:08 -0700, KoB wrote:
> I appear to be missing an encoding map. I need to convert a file with
> utf16-le to utf8 and have not been able to locate any possible solutions
> so far to help me do this. I suspect I need to create a mapping file to
> resolve this.
Have you looked at some of the modules on CPAN, especially the Encode
module?
--
Tore Aursand <tore@aursand.no>
"When you see a good idea look for a better one. You should never play
the first good move that comes into your head." (Bruce Pandolfine)
------------------------------
Date: Fri, 23 Jul 2004 15:40:36 +0300
From: Ilmari Karonen <usenet@vyznev.invalid>
Subject: Re: How do I end processes that time out?
Message-Id: <slrncg21q4.sq.usenet@yhteiskone.vyznev.net>
On 2004-07-23, J. Romano <jl_post@hotmail.com> wrote:
>
> Oddly enough, that doesn't work for me. When I use the line:
>
> my $pid = open(CHILD, '-|', 'perl', '-e', $tinyProgram);
>
> I get the following fatal error message at run-time:
>
> Can't use an undefined value as filehandle reference ...
That appears to be a bug in perl 5.6.x. For details, see:
http://groups.google.com/groups?threadm=rt-23366-62974.11.4579743331247%40rt.perl.org
Your open() || exec() workaround is just fine, though you might want
to check that $pid is false _but defined_ before calling exec().
--
Ilmari Karonen
If replying by e-mail, please replace ".invalid" with ".net" in address.
------------------------------
Date: Fri, 23 Jul 2004 08:43:34 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: How to compile Perl script to Win32 dll?
Message-Id: <Wc4Mc.148389$IQ4.67562@attbi_s02>
Koms Bomb wrote:
>>What is Apache Perl?
>
> http://www.cpan.org/ports/index.html#win32
> There are several package under Win32, I prefer the second one,
> "Apache/Perl (binaries for both Perl-5.6/Apache-1.0/mod_perl-1 and
> Perl-5.8/Apache-2/mod_perl-2) "
Following the links, I came to this documentation:
http://apache.bestwebcover.com/perl/win32-bin/perl-win32-bin.readme
This is a binary distribution for Win32 of Perl 5.6.1 and Apache 1.3.27,
together with mod_perl-1.27, mod_ssl / OpenSSL (0.9.7b),
and php-4.3.2, all built with VC++ 6.0 (SP5). Also included are some popular
non-core module packages such libnet, libwww-perl, Tk, and DBI.
Perl was built using the sources for build 635 provided by ActiveState.
http://apache.bestwebcover.com/perl/win32-bin/Perl-5.8-win32-bin.readme
This is a binary distribution for Win32 of Perl 5.8.4 and Apache 2.0.50,
together with mod_perl-1.99, mod_ssl / OpenSSL (0.9.7d),
and php-4.3.7, all built with VC++ 6.0 (SP5). Also included are some popular
non-core module packages such libnet, libwww-perl, Tk, and DBI.
Perl was built using the sources for build 810 provided by ActiveState.
> Which kind of Perl do you prefer under Win32? Only ActivePerl?
Your "Apache Perl" is really ActivePerl packaged differently.
If you're only using Perl for CGI programming, then there is no need
to compile it.
1) mod_perl already avoids the overhead of re-parsing the script.
2) web users cannot see your source code; it is hidden and only the
output from the script is visible.
-Joe
------------------------------
Date: Fri, 23 Jul 2004 14:14:14 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: How to compile Perl script to Win32 dll?
Message-Id: <q972g0hbdu2pnj6ld7js8r6ca8ea35mg1k@4ax.com>
A. Sinan Unur wrote:
>I have chosen to stay away from bundles. One of these days I am going to
>succeed in compiling Perl from sources using the free MSVC command line
>compiler. :)
Isn't that MSVC compiler a "bundle", too?
--
Bart.
------------------------------
Date: 23 Jul 2004 14:48:09 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: How to compile Perl script to Win32 dll?
Message-Id: <Xns952F6DE302A95asu1cornelledu@132.236.56.8>
Bart Lateur <bart.lateur@pandora.be> wrote in
news:q972g0hbdu2pnj6ld7js8r6ca8ea35mg1k@4ax.com:
> A. Sinan Unur wrote:
>
>>I have chosen to stay away from bundles. One of these days I am going to
>>succeed in compiling Perl from sources using the free MSVC command line
>>compiler. :)
>
> Isn't that MSVC compiler a "bundle", too?
There are bundles and then there are bundles ...
--
A. Sinan Unur
1usa@llenroc.ude.invalid
(remove '.invalid' and reverse each component for email address)
------------------------------
Date: 23 Jul 2004 10:16:15 -0700
From: bfay@deepcosmos.ca (Bern)
Subject: How to find directories
Message-Id: <836bef72.0407230916.7ded0a21@posting.google.com>
A newbie question:
I need to find all the subdirectories in a directory. I know how to
get the content of the directory but I don't know how I can identify
directories and for that matter any other kind of files under the same
directory.
I can I do that?
Thanks
Bern
------------------------------
Date: Fri, 23 Jul 2004 13:31:55 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: How to find directories
Message-Id: <20040723132951.C2467@barbara.cs.rpi.edu>
On Fri, 23 Jul 2004, Bern wrote:
> A newbie question:
>
> I need to find all the subdirectories in a directory. I know how to
> get the content of the directory but I don't know how I can identify
> directories and for that matter any other kind of files under the same
> directory.
>
> I can I do that?
To just determine whether a given directory entry is a file, directory,
link, etc, lookup:
perldoc -f -x
To recursively search directories, lookup:
perldoc File::Find
You'll want to use both of those to carry out your goal. Once you've read
them, if you have questions, let us know. Then make an attempt, and if it
doesn't work right, feel free to ask for help.
Paul Lalli
------------------------------
Date: Fri, 23 Jul 2004 22:19:21 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How to find directories
Message-Id: <J9gMc.685$qT3.102@nwrddc03.gnilink.net>
Bern wrote:
> I need to find all the subdirectories in a directory. I know how to
> get the content of the directory but I don't know how I can identify
> directories
perldoc -f -d
jue
------------------------------
Date: Fri, 23 Jul 2004 22:25:09 -0400
From: Mladen Gogala <gogala@sbcglobal.net>
Subject: Re: How to find directories
Message-Id: <pan.2004.07.24.02.25.09.966426@sbcglobal.net>
On Fri, 23 Jul 2004 10:16:15 -0700, Bern wrote:
> A newbie question:
>
> I need to find all the subdirectories in a directory. I know how to
> get the content of the directory but I don't know how I can identify
> directories and for that matter any other kind of files under the same
> directory.
>
> I can I do that?
You use a trick:
find2perl $HOME -type d -print
That will produce the subroutine that you can use.
--
A city is a large community where people are lonesome together.
------------------------------
Date: Thu, 29 Jul 2004 15:19:32 +0800
From: Facco Eloelo <artgh@hotmail.com>
Subject: How to know wheter a certain IP address belongs to given network segments?
Message-Id: <410c9fde.16854124@news.individual.net>
I have a network segment list in a text file called IPsegment.txt,it looks like
this:
IPsegment.txt
219.111.192.0/18
68.132.0.0/17
67.146.0.0/16
192.162.0.0/16
152.172.0.0/16
34.132.0.0/14
97.208.0.0/13
And I have some IP addresses in another text file called IPlist.txt.It looks
like this:
IPlist.txt
www.yahoo.com,66.94.230.51
www.baidu.com,202.108.250.249
www.sina.com.cn,61.135.152.77
www.sohu.com,61.135.150.75
...
Now,I want to know whether the IP addresses in the IPlist.txt belongs the
network segment writen in the IPsegment.txt.
The mathing IP list is output in a new text file called matchinglist.txt.
It looks like this:
matchinglist.txt
www.baidu.com,202.108.250.249
www.sina.com.cn,61.135.152.77
...
How can I do that? Thank you in advance.
------------------------------
Date: Thu, 29 Jul 2004 09:10:19 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: How to know wheter a certain IP address belongs to given network segments?
Message-Id: <_G6Oc.21141$BU4.1034310@news20.bellglobal.com>
"Facco Eloelo" <artgh@hotmail.com> wrote in message
news:410c9fde.16854124@news.individual.net...
> I have a network segment list in a text file called IPsegment.txt,it looks
like
> this:
>
[snip]
>
> And I have some IP addresses in another text file called IPlist.txt.It
looks
> like this:
>
[snip]
>
> Now,I want to know whether the IP addresses in the IPlist.txt belongs the
> network segment writen in the IPsegment.txt.
> The mathing IP list is output in a new text file called matchinglist.txt.
> It looks like this:
>
[snip]
>
> How can I do that? Thank you in advance.
By splitting the fqdn and IPs into key/value pairs in a hash and then
checking the existence of the address against the hash. In the future,
please make an effort to solve your own problems before postng, and then if
you run into a specific problem you can always ask here.
Matt
------------------------------
Date: Thu, 29 Jul 2004 15:21:11 GMT
From: "Bill Segraves" <segraves_f13@mindspring.com>
Subject: Re: How to know wheter a certain IP address belongs to given network segments?
Message-Id: <HB8Oc.1581$Jp6.1312@newsread3.news.atl.earthlink.net>
"Facco Eloelo" <artgh@hotmail.com> wrote in message
news:410c9fde.16854124@news.individual.net...
> I have a network segment list in a text file called IPsegment.txt,it looks
like
> this:
>
> IPsegment.txt
> 219.111.192.0/18
> 68.132.0.0/17
> 67.146.0.0/16
> 192.162.0.0/16
> 152.172.0.0/16
> 34.132.0.0/14
> 97.208.0.0/13
>
>
> And I have some IP addresses in another text file called IPlist.txt.It
looks
> like this:
>
> IPlist.txt
> www.yahoo.com,66.94.230.51
> www.baidu.com,202.108.250.249
> www.sina.com.cn,61.135.152.77
> www.sohu.com,61.135.150.75
> ...
>
> Now,I want to know whether the IP addresses in the IPlist.txt belongs the
> network segment writen in the IPsegment.txt.
> The mathing IP list is output in a new text file called matchinglist.txt.
> It looks like this:
>
> matchinglist.txt
> www.baidu.com,202.108.250.249
> www.sina.com.cn,61.135.152.77
> ...
>
>
> How can I do that? Thank you in advance.
This is not a Perl question.
That said, you can find several helpful tutorials with a Google search for
"ip addressing subnetting". Adding "Perl" to the search string shows at
least
one attempt at an IP address and subnet conversion calculator, done with
Perl.
One of the links that may be helpful to you is:
http://mipagina.cantv.net/lem/perl/iptut.htm
Search on the above page for "Matching against your address space" to see
how the module "NetAddr::IP" is used to solve a problem similar to (a part
of) your problem.
When you have a Perl problem, first read and comply with the Posting
Guidelines, then ask your Perl question.
Cheers.
--
Bill Segraves
------------------------------
Date: 26 Jul 2004 10:39:33 -0700
From: bfay@deepcosmos.ca (Bern)
Subject: How to print to more than one output
Message-Id: <836bef72.0407260939.1bcb86e3@posting.google.com>
Hello list,
Is it possible to print to two different output at once?
For example, I tried the following but it does not work. Nothing shows
up in the log file.
open(LOG, ">test.log") or die "Can't create log file: $!";
print { LOG && STDOUT } `ls -l`;
Thanks,
Bern
------------------------------
Date: 26 Jul 2004 22:09:13 +0200
From: 510046470588-0001@t-online.de
Subject: Re: How to print to more than one output
Message-Id: <87smbe1qfq.fsf@debian.i-did-not-set--mail-host-address--so-shoot-me>
bfay@deepcosmos.ca (Bern) writes:
> Is it possible to print to two different output at once?
one may exec the tee command and pipe into it.
Klaus Schilling
------------------------------
Date: Mon, 26 Jul 2004 13:54:57 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: How to print to more than one output
Message-Id: <260720041354570195%jgibson@mail.arc.nasa.gov>
In article <836bef72.0407260939.1bcb86e3@posting.google.com>, Bern
<bfay@deepcosmos.ca> wrote:
> Hello list,
>
> Is it possible to print to two different output at once?
Not in a single print statement, no. There isn't the Perl equivalent of
the Unix tee command.
>
> For example, I tried the following but it does not work. Nothing shows
> up in the log file.
>
> open(LOG, ">test.log") or die "Can't create log file: $!";
> print { LOG && STDOUT } `ls -l`;
This will print to STDOUT only, because the block returns the value of
the STDOUT file handle, following the rules of the logical and
operator. The LOG file handle is evaluated first, and, because it is
true, the STDOUT is evaluated next and returned as the value of the
expression.
You will have to write your own subroutine to output to two or file
handles.
------------------------------
Date: 26 Jul 2004 22:17:02 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to print to more than one output
Message-Id: <ce3vsu$k62$2@mamenchi.zrz.TU-Berlin.DE>
Jim Gibson <jgibson@mail.arc.nasa.gov> wrote in comp.lang.perl.misc:
> In article <836bef72.0407260939.1bcb86e3@posting.google.com>, Bern
> <bfay@deepcosmos.ca> wrote:
>
> > Hello list,
> >
> > Is it possible to print to two different output at once?
>
> Not in a single print statement, no. There isn't the Perl equivalent of
> the Unix tee command.
>
> >
> > For example, I tried the following but it does not work. Nothing shows
> > up in the log file.
> >
> > open(LOG, ">test.log") or die "Can't create log file: $!";
> > print { LOG && STDOUT } `ls -l`;
>
> This will print to STDOUT only, because the block returns the value of
> the STDOUT file handle, following the rules of the logical and
> operator. The LOG file handle is evaluated first, and, because it is
> true, the STDOUT is evaluated next and returned as the value of the
> expression.
>
> You will have to write your own subroutine to output to two or file
> handles.
The IO::Tee module on CPAN also handles this.
Anno
------------------------------
Date: 27 Jul 2004 07:54:29 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: How to print to more than one output
Message-Id: <u98yd5vo02.fsf@wcl-l.bham.ac.uk>
bfay@deepcosmos.ca (Bern) writes:
> Subject: Re: How to print to more than one output
>
> Is it possible to print to two different output at once?
This is FAQ: How do I print to more than one file at once?
Please consult the FAQ _before_ posting a question.
Note the there are two answers to this (the ones you've been given
already) and oddly older versions of the FAQ give one and newer
versions the other.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
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 6808
***************************************