[26670] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8777 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 19 14:06:29 2005

Date: Mon, 19 Dec 2005 11:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 19 Dec 2005     Volume: 10 Number: 8777

Today's topics:
    Re: How to align printed elements in array? <darkon.tdo@gmail.com>
    Re: Socket operation crashes under HPUX&Solaris, but OK <jgibson@mail.arc.nasa.gov>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 19 Dec 2005 15:05:29 -0000
From: "David K. Wall" <darkon.tdo@gmail.com>
Subject: Re: How to align printed elements in array?
Message-Id: <Xns973166BD131E6dkwwashere@216.168.3.30>

Fred <itfred@cdw.com> wrote:

> I'm pushing 3 variables into an array named 
> @sorted_countries:
> 
>    push(@invalid_countries, "$country_code\t$country\t$ip\n");
> 
> This is then sorted by country code:
> 
>    @sorted_countries = sort @invalid_countries;
> 
> Now when I print @sorted_countries the output is
> shifted, even though there is one tab between
> each entry.  I've tried increasing tabs, trimming
> whitespace, among other things, and the output
> is always shifted.  Currently I'm playing with
> the format/write commands.  Any ideas how to
> align the output?

Yeah, I have an idea.  Be (constructively) lazy and use Anno 
Siegel's excellent Text::Table module.  



use strict;
use warnings;
use Text::Table;

my @invalid_countries;
while (<DATA>) {
    chomp;
    push @invalid_countries, [ split /\s{2,}/, $_ ];
}
# see 'perldoc sort' if you're interested in more control over the
# sort algorithm used.
my @sorted_countries = sort { $a->[0] cmp $b->[0] } @invalid_countries;


my $table = Text::Table->new();

# if you want column headings use this next line instead
#my $table = Text::Table->new('Code', 'Country', 'IP');
$table->load( @sorted_countries );
print $table;


__DATA__
CN      China                   202.108.23.70
CN      China                   202.160.180.105
CN      China                   202.160.180.169
CN      China                   202.160.180.213
CN      China                   218.18.32.21
CN      China                   220.189.253.74
CY      Cyprus                  82.211.152.11
DE      Germany                 213.196.210.186
IL      Israel                  147.234.2.4
IL      Israel                  84.94.114.250
IN      India                   203.196.158.244
IN      India                   59.93.73.113
IT      Italy                   80.21.203.2
PH      Philippines                     58.69.216.245
RU      Russian Federation              81.19.66.8
RU      Russian Federation              82.179.108.6
SA      Saudi Arabia                    212.138.64.171
SA      Saudi Arabia                    212.138.64.172
SA      Saudi Arabia                    212.138.64.173
SA      Saudi Arabia                    212.138.64.174
SA      Saudi Arabia                    212.138.64.176
TW      Taiwan, Province of China       221.169.56.134


------------------------------

Date: Mon, 19 Dec 2005 10:20:16 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Socket operation crashes under HPUX&Solaris, but OK under Windows
Message-Id: <191220051020168944%jgibson@mail.arc.nasa.gov>

In article <43A665AA.F0EE192B@hotmail.com>, kalala <kalala@hotmail.com>
wrote:

> Socket operation crashes under HPUX&Solaris, but OK under Windows
> 
>     I am a perl newbie. Here's a problem annoying me!
>     I am writing a TCP server(under Solaris). Everything seems OK: I can
> telnet to it, and can see
> the text sent by the server;But if I quit the telnet window, the TCP
> server will crash silently,
> without any prompt. I tested it under HPUX & Windows2000 to find the
> reason, and find it worked under
> windows2000, but still failed under HPUX.
>     I put codes below:

[snipped]

You may need to handle or ignore the SIGPIPE signal in your server.

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


------------------------------

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 8777
***************************************


home help back first fref pref prev next nref lref last post