From matt at sergeant.org Tue Mar 1 11:00:59 2011 From: matt at sergeant.org (Matt Sergeant) Date: Tue, 01 Mar 2011 14:00:59 -0500 Subject: [kw-pm] Hash Question In-Reply-To: <468197.14980.qm@web120509.mail.ne1.yahoo.com> References: <468197.14980.qm@web120509.mail.ne1.yahoo.com> Message-ID: <4D6D426B.4050106@sergeant.org> Robert Pike wrote: > I have a complex hash that I want to make a "copy" of before manipulating the original hash. > Here is what I have : > my %tmpData = %{$aDATA}; > If I make changes to %{%aDATA} the changes are reflected in %tmpData. How can I copy the hash without having to loop through each element and assigning to the backup copy? Thanks. > The perl FAQ is your friend: $ perldoc -q copy Found in /usr/share/perl/5.8/pod/perlfaq4.pod How do I print out or copy a recursive data structure? The Data::Dumper module on CPAN (or the 5.005 release of Perl) is great for printing out data structures. The Storable module on CPAN (or the 5.8 release of Perl), provides a function called "dclone" that recur- sively copies its argument. use Storable qw(dclone); $r2 = dclone($r1); Where $r1 can be a reference to any kind of data structure you'd like. It will be deeply copied. Because "dclone" takes and returns refer- ences, you'd have to add extra punctuation if you had a hash of arrays that you wanted to copy. %newhash = %{ dclone(\%oldhash) }; From roberthpike at yahoo.com Thu Mar 10 10:32:04 2011 From: roberthpike at yahoo.com (Robert Pike) Date: Thu, 10 Mar 2011 10:32:04 -0800 (PST) Subject: [kw-pm] Sorting Question Message-ID: <621504.5633.qm@web120518.mail.ne1.yahoo.com> What's the most efficient way to loop through a hash while sorting on it's values (as opposed to it's keys)? The values of the hash are (for arguments sake) "Person's name#Number assigned" (i.e. Tom Smith~101012). The names are variable length and I don't want anything including and after the tilde to be included in the sort (i.e. just the name strings). Any suggestions? Thanks. From matt at sergeant.org Thu Mar 10 11:07:40 2011 From: matt at sergeant.org (Matt Sergeant) Date: Thu, 10 Mar 2011 14:07:40 -0500 Subject: [kw-pm] Sorting Question In-Reply-To: <621504.5633.qm@web120518.mail.ne1.yahoo.com> References: <621504.5633.qm@web120518.mail.ne1.yahoo.com> Message-ID: <4D79217C.2000102@sergeant.org> Robert Pike wrote: > What's the most efficient way to loop through a hash while sorting on it's values (as opposed to it's keys)? The values of the hash are (for arguments sake) "Person's name#Number assigned" (i.e. Tom Smith~101012). The names are variable length and I don't want anything including and after the tilde to be included in the sort (i.e. just the name strings). Any suggestions? Thanks. Depends on the size of the hash, but if it's likely to be large then you probably want a schwarzian transform. Basically that would be: # given %hash for my $key ( map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { (my $val_no_tilde = $hash{$_}) =~ s/~.*//; [$_, $val_no_tilde] } keys %hash ) { # do something with $key } Breaking that down, how it works (read it right to left) is it creates a list of arrayrefs containing [ key, value-without-tilde-stuff ], then sorts on that, then pulls out just the key at the end. (I didn't test the code - may have typo'd) Matt. From daniel at coder.com Mon Mar 14 08:30:42 2011 From: daniel at coder.com (Daniel R. Allen) Date: Mon, 14 Mar 2011 11:30:42 -0400 (EDT) Subject: [kw-pm] March Talk this Thursday: Catalyst Web Framework Message-ID: Happy Pi Day! The March KW Perl Mongers talk, this Thursday, is on the super-powerful Catalyst web framework (http://www.catalystframework.org/), presented by dnm. Hope you can make it! If you're not sure you need to learn about yet another web framework, here are some user comments I nabbed from the catalyst site: --- First let me say how cool Catalyst is. I've only just started playing with it, but I like what I see so far! Great job, guys. Big respect to everyone involved. -- Andy Wardley Catalyst brings some serious web development mojo to Perl. For a long time I stuck with Perl because of CPAN but thought other languages provided better frameworks and were leaving Perl behind. No more with Catalyst. -- John Wang --- As usual, pizza and pop/water are provided, sponsored by $anonymous, and various details can be found on our webpage at http://kw.pm.org/ We are meeting in our usual location, DC 3323, at 7pm. Any questions, give a shout; either on this list, or irc.perl.org, channel #uc -Daniel From kw-pm at datademons.com Mon Mar 14 09:55:43 2011 From: kw-pm at datademons.com (Justin Wheeler) Date: Mon, 14 Mar 2011 12:55:43 -0400 Subject: [kw-pm] March Talk this Thursday: Catalyst Web Framework In-Reply-To: References: Message-ID: <4D7E488F.3060108@datademons.com> Catalyst really isn't just another web frame work. It's huge. The contributors list is massive, its development is ongoing, its feature list is massive, and it is easily the largest perl based framework in existence today in terms of number of installs, number of shops actively using it in development, and interest. I'd say it's even a part of a resurgence in perl5 land I'm witnessing lately. There are real (massive) websites out there running on Catalyst, and it's pretty awesome. Justin On 14/03/11 11:30 AM, Daniel R. Allen wrote: > Happy Pi Day! > > The March KW Perl Mongers talk, this Thursday, is on the super-powerful > Catalyst web framework (http://www.catalystframework.org/), presented by > dnm. Hope you can make it! > > If you're not sure you need to learn about yet another web framework, here > are some user comments I nabbed from the catalyst site: > > --- > First let me say how cool Catalyst is. I've only just started playing with > it, but I like what I see so far! Great job, guys. Big respect to everyone > involved. > -- Andy Wardley > > Catalyst brings some serious web development mojo to Perl. For a long time > I stuck with Perl because of CPAN but thought other languages provided > better frameworks and were leaving Perl behind. No more with Catalyst. > -- John Wang > --- > > As usual, pizza and pop/water are provided, sponsored by $anonymous, > and various details can be found on our webpage at http://kw.pm.org/ > > We are meeting in our usual location, DC 3323, at 7pm. > > Any questions, give a shout; either on this list, or irc.perl.org, > channel #uc > > -Daniel > > _______________________________________________ > kw-pm mailing list > kw-pm at pm.org > http://mail.pm.org/mailman/listinfo/kw-pm From ejritz at genema.org Mon Mar 14 16:38:04 2011 From: ejritz at genema.org (Erich J. Ritzmann) Date: Mon, 14 Mar 2011 19:38:04 -0400 Subject: [kw-pm] March Talk this Thursday: Catalyst Web Framework In-Reply-To: <4D7E488F.3060108@datademons.com> References: <4D7E488F.3060108@datademons.com> Message-ID: I've just started playing with DBI, which I am finding the coolest thing I've done in a while. Catalyst could overwhelm based on the run-up. On 2011-03-14, at 12:55 PM, Justin Wheeler wrote: > Catalyst really isn't just another web frame work. It's huge. The contributors list is massive, its development is ongoing, its feature list is massive, and it is easily the largest perl based framework in existence today in terms of number of installs, number of shops actively using it in development, and interest. > > I'd say it's even a part of a resurgence in perl5 land I'm witnessing lately. There are real (massive) websites out there running on Catalyst, and it's pretty awesome. > > Justin > > On 14/03/11 11:30 AM, Daniel R. Allen wrote: >> Happy Pi Day! >> >> The March KW Perl Mongers talk, this Thursday, is on the super-powerful >> Catalyst web framework (http://www.catalystframework.org/), presented by >> dnm. Hope you can make it! >> >> If you're not sure you need to learn about yet another web framework, here >> are some user comments I nabbed from the catalyst site: >> >> --- >> First let me say how cool Catalyst is. I've only just started playing with >> it, but I like what I see so far! Great job, guys. Big respect to everyone >> involved. >> -- Andy Wardley >> >> Catalyst brings some serious web development mojo to Perl. For a long time >> I stuck with Perl because of CPAN but thought other languages provided >> better frameworks and were leaving Perl behind. No more with Catalyst. >> -- John Wang >> --- >> >> As usual, pizza and pop/water are provided, sponsored by $anonymous, >> and various details can be found on our webpage at http://kw.pm.org/ >> >> We are meeting in our usual location, DC 3323, at 7pm. >> >> Any questions, give a shout; either on this list, or irc.perl.org, >> channel #uc >> >> -Daniel >> >> _______________________________________________ >> kw-pm mailing list >> kw-pm at pm.org >> http://mail.pm.org/mailman/listinfo/kw-pm > _______________________________________________ > kw-pm mailing list > kw-pm at pm.org > http://mail.pm.org/mailman/listinfo/kw-pm From rpjday at crashcourse.ca Wed Mar 16 03:41:38 2011 From: rpjday at crashcourse.ca (Robert P. J. Day) Date: Wed, 16 Mar 2011 06:41:38 -0400 (EDT) Subject: [kw-pm] trying to diff two files which contain '$' in their names Message-ID: a colleague presents me with the following (simple?) perl problem. first, here's a variation of the program that works: #!/usr/bin/perl $f1 = 'file1'; $f2 = 'file2'; $res = `diff $f1 $f2`; print $res, "\n"; piece of cake -- there are two variables that contain the names of perfectly respectable files, those files are diff'ed and the result of the diff is saved and printed. the problem is that the filenames sometimes contain a literal dollar sign as part of the name (don't ask). so a simplified demo of the problem would be: #!/usr/bin/perl $f1 = '$file1'; $f2 = '$file2'; $res = `diff $f1 $f2`; print $res, "\n"; which gives me: diff: missing operand after `diff' diff: Try `diff --help' for more information. i've tried to backslash escape various things but no success. what bit of magic am i missing? rday From rpjday at crashcourse.ca Wed Mar 16 04:29:49 2011 From: rpjday at crashcourse.ca (Robert P. J. Day) Date: Wed, 16 Mar 2011 07:29:49 -0400 (EDT) Subject: [kw-pm] trying to diff two files which contain '$' in their names In-Reply-To: References: Message-ID: as a followup to my earlier post, here's what appears to be a solution to what i was after: $pre1 = '$file'; $post1 = ' 1'; $pre2 = '$file'; $post2 = ' 2'; $res = `diff \'${pre1}\'@@\'${post1}\' \'${pre2}\'@@\'${post2}\'`; print $res, "\n"; it was clarified for me that the two files to be diff'ed had names of the format: 1) some arbitrary string 2) two literal '@' characters 3) another arbitrary string and all of those strings could conceivably have embedded whitespace or literal dollar signs. argh. who the $%#^&^&% thought that was a sane idea? in any event, you can see how i whipped up a test program that simulated that, and protected everything inside the backticks with escaped single quotes, which appears to work. thoughts? rday -- ======================================================================== Robert P. J. Day Waterloo, Ontario, CANADA http://crashcourse.ca Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ======================================================================== From daniel at coder.com Wed Mar 16 14:36:04 2011 From: daniel at coder.com (Daniel R. Allen) Date: Wed, 16 Mar 2011 17:36:04 -0400 (EDT) Subject: [kw-pm] March Talk this Thursday: Catalyst Web Framework In-Reply-To: Message-ID: Aaand this is your monthly reminder to add yourself to the pizza-list by tomorrow, 5pm, for headcount purposes. http://kw.pm.org/wiki/index.cgi?PizzaList Thanks! -Daniel On Mon, 14 Mar 2011, Daniel R. Allen wrote: > Happy Pi Day! > > The March KW Perl Mongers talk, this Thursday, is on the super-powerful > Catalyst web framework (http://www.catalystframework.org/), presented by > dnm. Hope you can make it! > > If you're not sure you need to learn about yet another web framework, here > are some user comments I nabbed from the catalyst site: > > --- > First let me say how cool Catalyst is. I've only just started playing with > it, but I like what I see so far! Great job, guys. Big respect to everyone > involved. > -- Andy Wardley > > Catalyst brings some serious web development mojo to Perl. For a long time > I stuck with Perl because of CPAN but thought other languages provided > better frameworks and were leaving Perl behind. No more with Catalyst. > -- John Wang > --- > > As usual, pizza and pop/water are provided, sponsored by $anonymous, > and various details can be found on our webpage at http://kw.pm.org/ > > We are meeting in our usual location, DC 3323, at 7pm. > > Any questions, give a shout; either on this list, or irc.perl.org, > channel #uc > > -Daniel > > _______________________________________________ > kw-pm mailing list > kw-pm at pm.org > http://mail.pm.org/mailman/listinfo/kw-pm > From nick.dumas at gmail.com Wed Mar 16 16:02:33 2011 From: nick.dumas at gmail.com (Nick Dumas) Date: Wed, 16 Mar 2011 19:02:33 -0400 Subject: [kw-pm] Diffing files with '$' in the name Message-ID: When I do: ----- #!/usr/bin/perl use strict; use warnings; my $f1 = '$file@@foo'; my $f2 = '$file@@bar'; my $res = `diff $f1 $f2`; print $res, "\n"; ----- I get a perfectly normal result from diff. I'm running under WinXP however. Does your shell require you to escape those characters? If so you'll also have to escape the escapes when putting them into the string literals. - Nick > Message: 1 > Date: Wed, 16 Mar 2011 06:41:38 -0400 (EDT) > From: "Robert P. J. Day" > To: KW Perl list > Subject: [kw-pm] trying to diff two files which contain '$' in their > ? ? ? ?names > Message-ID: > ? ? ? ? > Content-Type: TEXT/PLAIN; charset=US-ASCII > > > ?a colleague presents me with the following (simple?) perl problem. > first, here's a variation of the program that works: > > #!/usr/bin/perl > > $f1 = 'file1'; > $f2 = 'file2'; > > $res = `diff $f1 $f2`; > print $res, "\n"; > > ?piece of cake -- there are two variables that contain the names of > perfectly respectable files, those files are diff'ed and the result of > the diff is saved and printed. > > ?the problem is that the filenames sometimes contain a literal dollar > sign as part of the name (don't ask). ?so a simplified demo of the > problem would be: > > #!/usr/bin/perl > > $f1 = '$file1'; > $f2 = '$file2'; > > $res = `diff $f1 $f2`; > print $res, "\n"; > > which gives me: > > diff: missing operand after `diff' > diff: Try `diff --help' for more information. > > ?i've tried to backslash escape various things but no success. ?what > bit of magic am i missing? > > rday > > > ------------------------------ > > Message: 2 > Date: Wed, 16 Mar 2011 07:29:49 -0400 (EDT) > From: "Robert P. J. Day" > To: KW Perl list > Subject: Re: [kw-pm] trying to diff two files which contain '$' in > ? ? ? ?their names > Message-ID: > ? ? ? ? > Content-Type: TEXT/PLAIN; charset=US-ASCII > > > ?as a followup to my earlier post, here's what appears to be a > solution to what i was after: > > $pre1 = '$file'; > $post1 = ' 1'; > $pre2 = '$file'; > $post2 = ' 2'; > > $res = `diff \'${pre1}\'@@\'${post1}\' \'${pre2}\'@@\'${post2}\'`; > print $res, "\n"; > > ?it was clarified for me that the two files to be diff'ed had names > of the format: > > ?1) some arbitrary string > ?2) two literal '@' characters > ?3) another arbitrary string > > and all of those strings could conceivably have embedded whitespace or > literal dollar signs. ?argh. ?who the $%#^&^&% thought that was a sane > idea? > > ?in any event, you can see how i whipped up a test program that > simulated that, and protected everything inside the backticks with > escaped single quotes, which appears to work. > > ?thoughts? > > rday > > -- > > ======================================================================== > Robert P. J. Day ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Waterloo, Ontario, CANADA > ? ? ? ? ? ? ? ? ? ? ? ?http://crashcourse.ca > > Twitter: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? http://twitter.com/rpjday > LinkedIn: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? http://ca.linkedin.com/in/rpjday > ======================================================================== > > > ------------------------------ > > _______________________________________________ > kw-pm mailing list > kw-pm at pm.org > http://mail.pm.org/mailman/listinfo/kw-pm > > End of kw-pm Digest, Vol 92, Issue 5 > ************************************ > From ceeshek at gmail.com Wed Mar 16 19:35:39 2011 From: ceeshek at gmail.com (Cees Hek) Date: Thu, 17 Mar 2011 13:35:39 +1100 Subject: [kw-pm] trying to diff two files which contain '$' in their names In-Reply-To: References: Message-ID: On Wed, Mar 16, 2011 at 9:41 PM, Robert P. J. Day wrote: > [snip] > > ?the problem is that the filenames sometimes contain a literal dollar > sign as part of the name (don't ask). ?so a simplified demo of the > problem would be: > [snip] > > ?i've tried to backslash escape various things but no success. ?what > bit of magic am i missing? The problem is that the shell is expanding your command and hence you need to make sure everything is escaped properly. The safer way to handle this is to not involve the shell at all. In order to do that you need to be able to pass the options one at a time in a list, and backticks don't allow that. perldoc perlsec gives a safe way of doing this with fork and exec: Here's a way to do backticks reasonably safely. Notice how the "exec" is not called with a string that the shell could expand. This is by far the best way to call something that might be subjected to shell escapes: just never call the shell at all. use English '-no_match_vars'; die "Can't fork: $!" unless defined($pid = open(KID, "-|")); if ($pid) { # parent while () { # do something } close KID; } else { my @temp = ($EUID, $EGID); my $orig_uid = $UID; my $orig_gid = $GID; $EUID = $UID; $EGID = $GID; # Drop privileges $UID = $orig_uid; $GID = $orig_gid; # Make sure privs are really gone ($EUID, $EGID) = @temp; die "Can't drop privileges" unless $UID == $EUID && $GID eq $EGID; $ENV{PATH} = "/bin:/usr/bin"; # Minimal PATH. # Consider sanitizing the environment even more. exec 'myprog', 'arg1', 'arg2' or die "can't exec myprog: $!"; } This important thing to notice here is that in the 'exec' call all arguements (inlcuding the command name and switches) are passed individually as a list, instead of as one big long string. If that is too ugly/messy for you, then look at a module to make things easier, like IPC::Run. Cheers, Cees From youcanreachmehere at hotmail.com Sun Mar 20 13:44:28 2011 From: youcanreachmehere at hotmail.com (Joe Wennechuk) Date: Sun, 20 Mar 2011 16:44:28 -0400 Subject: [kw-pm] cpan Message-ID: I am trying to install a cpan module and it wont work.. I've installed YAML and maybe some other modules and they show up when I $perldoc perllocal but when I try to install WWW::Search::Ebay::BySellerIDor eBay::API I get this error.. this ne is specifically from the first link Files=11, Tests=1006, 278 wallclock secs ( 0.89 usr 0.10 sys + 84.62 cusr 2.20 csys = 87.81 CPU) Result: FAIL Failed 1/11 test programs. 2/1006 subtests failed. make: *** [test_dynamic] Error 255 MTHURN/WWW-Search-Ebay-3.021.tar.gz /usr/bin/make test -- NOT OK //hint// to see the cpan-testers results for installing this module, try: reports MTHURN/WWW-Search-Ebay-3.021.tar.gz Running make install make test had returned bad status, won't install without force Failed during this command: MTHURN/WWW-Search-Ebay-3.021.tar.gz : make_test NO I cant see it in $perldoc perllocal ??? I'm quite new to perl, and am not sure what I'm doing Joseph Wennechuk ________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From jkeen at verizon.net Mon Mar 21 15:33:34 2011 From: jkeen at verizon.net (James E Keenan) Date: Mon, 21 Mar 2011 18:33:34 -0400 Subject: [kw-pm] cpan In-Reply-To: References: Message-ID: <27506922-98EF-4A08-89C6-379E08E219A0@verizon.net> On Mar 21, 2011, at 3:00 PM, kw-pm-request at pm.org wrote: > Message: 1 > Date: Sun, 20 Mar 2011 16:44:28 -0400 > From: Joe Wennechuk > To: > Subject: [kw-pm] cpan > > Files=11, Tests=1006, 278 wallclock secs ( 0.89 usr 0.10 sys + > 84.62 cusr 2.20 csys = 87.81 CPU) > Result: FAIL > Failed 1/11 test programs. 2/1006 subtests failed. > make: *** [test_dynamic] Error 255 > MTHURN/WWW-Search-Ebay-3.021.tar.gz > /usr/bin/make test -- NOT OK > //hint// to see the cpan-testers results for installing this > module, try: > reports MTHURN/WWW-Search-Ebay-3.021.tar.gz > Running make install > make test had returned bad status, won't install without force > Failed during this command: > MTHURN/WWW-Search-Ebay-3.021.tar.gz : make_test NO > Well, it looks like it's not you. This page suggests it's failing on many platforms. http://www.cpantesters.org/distro/W/WWW-Search-Ebay.html#WWW-Search- Ebay-3.021 From elbie at trig.net Wed Mar 30 12:34:50 2011 From: elbie at trig.net (Christopher Calzonetti) Date: Wed, 30 Mar 2011 15:34:50 -0400 Subject: [kw-pm] CAcert talk, May 19th Message-ID: <20110330193450.GJ14093@trig.net> ABOUT CACERT ------------ tl;dr version: Free ssl server certificates! CAcert is an alternative to the commercial certificate authorities, allowing users to create free SSL certificates signed by a trusted CA. >From the CAcert Assurance Handbook: * CAcert separates assurance (confirmation of identity) from the issuing of the certificates. Thereby the identity only has to be confirmed once to make as many certificates as needed and whenever wanted. * CAcert is a "non-profit" community of volunteers. It is independent from commercial CA's. * Some CAs issue free certs, and some use a WoT, but they tend to only issue low-level client certificates, but no server certificates or strongly verified certs. These free certs are intended to drive you to their CA so they can sell you higher value products. There is nothing wrong with that (your supermarket does the same thing) but it might not be appropriate to your needs. (http://wiki.cacert.org/AssuranceHandbook2#Some_more_information_on_CAcert) It's important to get a good network of trust built up. The more people you have who have assured your identity the better. The Kitchener Waterloo Perlmongers is hoping to have an Assurance event at our May kw.pm meeting, Thursday the 19th of May. Come out, learn about CAcert, and we'll have some assurers present to get you started. KW.PM NEEDS ASSURERS -------------------- There aren't a lot of assurers in the area. If you're feeling ambitious, kw.pm would very much appreciate if you could contact assurers in your area and start earning assurance points ahead of time. If you can get up to 100 assurance points, then please come to our meeting and help assure others.