[32053] in Perl-Users-Digest
Perl-Users Digest, Issue: 3317 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 12 14:09:22 2011
Date: Sat, 12 Mar 2011 11:09:06 -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 Sat, 12 Mar 2011 Volume: 11 Number: 3317
Today's topics:
Re: Hashes are good, but not good enough. <blgl@stacken.kth.se>
Re: Ok, simpler..... <tzz@lifelogs.com>
Re: Ok, simpler..... <nobody@nowhere.com>
Re: Ok, simpler..... <cartercc@gmail.com>
Re: Ok, simpler..... <nobody@nowhere.com>
Re: Ok, simpler..... <nobody@nowhere.com>
Re: Ok, simpler..... <thepoet_nospam@arcor.de>
Re: Ok, simpler..... <tadmc@seesig.invalid>
Re: What do you use with Perl for GUI programming and w <cartercc@gmail.com>
Re: What do you use with Perl for GUI programming and w <proximum@invalid.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 11 Mar 2011 22:28:07 +0100
From: Bo Lindbergh <blgl@stacken.kth.se>
Subject: Re: Hashes are good, but not good enough.
Message-Id: <ile454$6ur$1@speranza.aioe.org>
In article <ilcp16$2vn$1@news.ntua.gr>,
"George Mpouras" <nospam.gravitalsun@hotmail.com.nospam> wrote:
> > http://www.stacken.kth.se/~blgl/triedawgfoldtest/
> > The provided program should give you more than enough useful information
> > to compare the sizes of various trie variations. Plus, you can feed its
> > output to Graphviz to make pretty diagrams! (Bring lots of paper if you
> > want to visualise an entire English dictionary.)
>
> using the words
>
> agapi
> agapo
> ogapo
>
> the part "gap" should be common but it is not
No, it shouldn't. An infix will be shared only if every combination
of prefixes and suffixes occurs. You have to add "ogapi" to the set
to fulfill this condition.
/Bo Lindbergh
------------------------------
Date: Fri, 11 Mar 2011 08:51:41 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Ok, simpler.....
Message-Id: <87r5adhfr6.fsf@lifelogs.com>
On Thu, 10 Mar 2011 16:05:08 -0600 WhoDare <nobody@nowhere.com> wrote:
W> Jump in the pool holding your nose will make you swim quicker than
W> lessons. I agree.
That's a good analogy to "just jumping into programming," considering
many people who don't know how to swim would panic and drown. It's
probably not the analogy you were trying to make, though.
Ted
------------------------------
Date: Fri, 11 Mar 2011 10:25:56 -0600
From: WhoDare <nobody@nowhere.com>
Subject: Re: Ok, simpler.....
Message-Id: <IsKdnfWBremJ0OfQnZ2dnUVZ_jOdnZ2d@polarcomm.com>
Hey ccc31807,
Thanks for this script. I have a couple of questions now that I am
looking at it.
How are you pulling in <DATA>?
Where are you setting the variable k?
Maybe obvious questions, but I'm lacking the experience to really decode
this.
On Thu, 10 Mar 2011 13:51:08 -0800, ccc31807 wrote:
> HERE IS THE SCRIPT
> #! perl
> use strict;
> use warnings;
> my %session;
> #get data
> while(<DATA>)
> {
> next unless /\w/;
> chomp;
> my ($ses, $noc, $ser, $name, @rest) = split(/:/, $_); my $rest =
> join(':', @rest);
> $session{$noc}{$ser}{$name} = $rest;
> }
> #print data as XML
> print qq(<SESSION>\n);
> foreach my $k1 (sort keys %session)
> {
> print qq( <$k1>\n);
> foreach my $k2 (sort keys %{$session{$k1}}) {
> print qq( <$k2>\n);
> foreach my $k3 (sort keys %{$session{$k1}{$k2}}) {
> print qq( <$k3>\n);
> print qq( $session{$k1}{$k2}{$k3}\n); print qq(
> </$k3>\n);
> }
> print qq( </$k2>\n);
> }
> print qq( </$k1>\n);
> }
> print qq(</SESSION>\n);
> exit(0);
------------------------------
Date: Fri, 11 Mar 2011 09:59:08 -0800 (PST)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Ok, simpler.....
Message-Id: <5aa7af2a-5c2c-43b1-99a2-7261fd300036@e8g2000vbz.googlegroups.com>
On Mar 11, 11:25=A0am, WhoDare <nob...@nowhere.com> wrote:
> How are you pulling in <DATA>?
Read the help page for perldata - Perl data types
> Where are you setting the variable k?
Read the help page for perlfunc - Perl builtin functions
> Maybe obvious questions, but I'm lacking the experience to really decode
> this.
Not a problem. The first is an easy way to give a script access to
some data without created or opening an extraneous file, and the
second returns a list of the keys in a hash. Both are idiomatic Perl,
on the level of 'See Spot. See Spot run.'
Start reading the Perl documentation. If you can, print out the
documentation you are interested in and study it. Get in the habit of
making the documentation your first choice for answering questions you
have.
Perl might be a poor choice for general programming tasks, and a poor
choice for particular applications, but it's a great choice for a
specific set of problems. If you are faced with those kinds of
problems, you will want to pore over the documentation until you know
it like the back of your hand.
CC.
------------------------------
Date: Fri, 11 Mar 2011 13:15:44 -0600
From: WhoDare <nobody@nowhere.com>
Subject: Re: Ok, simpler.....
Message-Id: <IsKdnfSBrel96efQnZ2dnUVZ_jOdnZ2d@polarcomm.com>
hash of hashes of hashes
:-) Got it!
Thanks Again!
------------------------------
Date: Fri, 11 Mar 2011 13:16:24 -0600
From: WhoDare <nobody@nowhere.com>
Subject: Re: Ok, simpler.....
Message-Id: <IsKdnfeBremV6OfQnZ2dnUVZ_jOdnZ2d@polarcomm.com>
On Fri, 11 Mar 2011 13:15:44 -0600, WhoDare wrote:
> :-) Got it!
I mean I'll read up on it! Still don't have a working script, but
getting there.
------------------------------
Date: Fri, 11 Mar 2011 20:37:58 +0100
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: Ok, simpler.....
Message-Id: <4d7a7a18$0$6773$9b4e6d93@newsspool3.arcor-online.net>
Am 11.03.2011 03:06, schrieb Jürgen Exner:
> WhoDare<nobody@nowhere.com> wrote:
>> This is the part that I can't figure out:
>>
>> <andy>
>> (Netra t1 105 DNS server):192.168.18.104 # needed one more loop
>> </andy>
>>
>> <Rotuers>
>> Console:10008PKRV_R:192.168.17.68 # needed two more loops
>> </Rotuers>
>>
>> It's the variable length of the array elements that I can't wrap my head
>> around.
>
[...]
>
> I would probably rather go with a recursive approach, but that is just
> me.
Or build the hash structure for each line bottom up and merge hashes
afterwards. Quickly put together, using a bunch of modules that really
make life easier:
-------------------------------------------------------------------
#!perl
use strict;
use warnings;
use Text::CSV_XS;
use Hash::Merge qw(merge);
use XML::Simple;
# Storage for the parsed csv columns.
my @data;
# Create the csv parser
my $csv = Text::CSV_XS->new () or
die "".Text::CSV_XS->error_diag ();
# Read in the csv file
open my $input, "<", "putty.csv"
or die "Unable to open file putty.csv: $!";
while(<$input>) {
$csv->parse($_);
push @data, [$csv->fields()];
}
close $input;
# Master hashref that will hold the complete xml structure as
# a nested hash:
my $xmlhash = {};
for my $row( @data )
{
next if( scalar @data < 4 );
# Split first field on whitespace, maximum two parts.
my( $key, $keyname ) = split /\s/, $row->[0], 2;
# Split second field on backslash characters
my @subkeys = split /\\/, $row->[1];
# IP address is always in the fourth field
my $ip = $row->[3];
# Initialize our hashref with the key from the first field
# pointing to the ip address of this entry, preceded
# by the text in $keyname and a colon if $keyname is filled
my $cur = { $key => length($keyname) ? $keyname.":".$ip : $ip };
# Iterate reversely over our subkeys, always making the current
# hashref have the current key pointing to its old version, thus
# building up the nested hash structure bottom up
foreach( reverse @subkeys ) {
$cur = { $_ => $cur };
}
# Merge our newly created hash structure with the master
$xmlhash = merge( $xmlhash, $cur );
}
# Output the xml using XML::Simple
# NoAttr => 1 tells it that every hash key is a tag, not an
# attribute
print XMLout($xmlhash, NoAttr => 1);
-------------------------------------------------------------------
-Chris
------------------------------
Date: Fri, 11 Mar 2011 20:54:21 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Ok, simpler.....
Message-Id: <slrninlnpc.aor.tadmc@tadbox.sbcglobal.net>
WhoDare <nobody@nowhere.com> wrote:
> Subject: Ok, simpler.....
Please put the subject of your article in the Subject of your article.
Your article is not about "simpler".
> I need to produce a 'tree'
It appears to be about "trees", so:
Subject: trees
or some such.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Fri, 11 Mar 2011 06:34:52 -0800 (PST)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: What do you use with Perl for GUI programming and why?
Message-Id: <22b1dd3b-73e5-444a-bd0d-edf7106599b8@q40g2000prh.googlegroups.com>
On Mar 10, 9:25=A0pm, Robert <sigz...@gmail.com> wrote:
> Is there a push to one toolkit or the other?
I've done quite a number of graphical Perl scripte, but I always use
CGI. The two big wins are that (1) you produce HTML (and CSS and
JavaScript) which is just ASCII text, nothing fancy involved, and (2)
your user can use any web browser of their choice.
As a plus, you get internetwork capability with a web server (like
Apache) with a client/server architecture, so you have to worry about
maintaining code on the server, not on myriad user machines.
I've done a bit of graphical work in Java (2D) and just played with C/C
++, and I hope I NEVER have to write a graphical program using the
graphics libraries of those languages.
I've also done some graphical work with Microsoft Visual Studio, using
a variety of .NET languages, and for the result, I think that VS is an
appropriate tool for building GUI apps on Windows.
CC.
------------------------------
Date: Sat, 12 Mar 2011 22:45:00 +0600
From: Michael <proximum@invalid.com>
Subject: Re: What do you use with Perl for GUI programming and why?
Message-Id: <ilg7ud$foc$1@news.eternal-september.org>
For creating science graphs I'm using DISLIN (http://dislin.de), which
have also bindings for C and Fortran.
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 V11 Issue 3317
***************************************