From grant at mclean.net.nz Sun Jul 9 17:04:18 2006 From: grant at mclean.net.nz (Grant McLean) Date: Mon, 10 Jul 2006 12:04:18 +1200 Subject: [Wellington-pm] Meeting tomorrow night Message-ID: <1152489858.22425.9.camel@putnam.wgtn.cat-it.co.nz> Hi Mongers This month's meeting of Wellington Perl Mongers is tomorrow evening, usual time and place: 6:00pm Tuesday 11 July 2006 Level 2, Eagle Technology House 150 Willis Street Wellington Our two speakers are * Sam Vilain: Moose, a new approach to building objects in Perl 5 * Finlay Thompson: DBIx::Class and Catalyst Sam has also volunteered to speak at next month's meeting and do a trial run of his other YAPC::EU talk. So that will leave us looking for one more speaker - come prepared to volunteer :-) See you there Grant From jarich at perltraining.com.au Mon Jul 10 19:11:07 2006 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Tue, 11 Jul 2006 12:11:07 +1000 Subject: [Wellington-pm] OSDC Paper Proposals due tomorrow! Message-ID: <44B308BB.4040609@perltraining.com.au> G'day everyone, This is a final reminder that OSDC papers are due tomorrow. Our conference is nothing without speakers, so I encourage you all to get your proposals in as soon as possible! http://www.osdc.com.au/papers/cfp06.html For those who've never submitted a proposal before, or spoken at at conference: fear not! A proposal is just a couple of paragraphs about what you think you might like to say. If your talk's direction changes somewhat when you start writing it, that's okay! Further, we encourage you to give your talk(s) to your local user groups (for example OSDClub) before the conference. This will give you some great practice time and give us the chance to give you some feedback. If you have any friends or family members who might also want to present, please feel free to pass this invitation on. Likewise if you know of any related user groups who haven't heard from us, please invite them to participate. Our goal is to make this conference truly representative of Australia's amazing Open Source development community! We look forward to seeing your paper submission. Jacinta PS: If you're interested in being part of the paper selection committee, please contact Richard, our Programme Chair: richard osdc.com.au -- ("`-''-/").___..--''"`-._ | Jacinta Richardson | `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia | (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 | _..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au | (il),-'' (li),' ((!.-' | www.perltraining.com.au | From grant at mclean.net.nz Tue Jul 11 18:05:58 2006 From: grant at mclean.net.nz (Grant McLean) Date: Wed, 12 Jul 2006 13:05:58 +1200 Subject: [Wellington-pm] Round-up of last night's meeting Message-ID: <1152666358.5374.5.camel@putnam.wgtn.cat-it.co.nz> Hi Mongers Thanks to our speakers, Sam and Finlay, for a couple of informative and entertaining talks. The slides are up on the Wellington.PM web site: http://wellington.pm.org/archive/ Thanks also to the (smaller than usual) crowd who turned up to be informed and entertained. Finally, thanks to Brenda for volunteering to speak (along with Sam) at next month's meeting: 6:00pm Tuesday 8 August 2006 Level 2, Eagle Technology House 150 Willis Street Wellington See you next month. Grant From philip at xinqu.net Fri Jul 14 16:44:07 2006 From: philip at xinqu.net (Philip Plane) Date: Sat, 15 Jul 2006 11:44:07 +1200 (NZST) Subject: [Wellington-pm] Select at random from a list Message-ID: Hi Guys, I have a little script I wrote to return a randomly selected mp3 from a playlist. It works, but doesn't seem to be as random as I hoped. Any comment on a better way of doing this? -- start script -- #! /bin/perl -w use CGI; $q = new CGI; open PLAYLIST, "/mp3/playlist.txt" or die "Couldn't open playlist: $!\n"; @playlist = ; close PLAYLIST; $mp3 = $playlist[int(rand(scalar(@playlist)))]; open MP3, $mp3 or die "Couldn't open $mp3: $!\n"; print $q->header(-type=>'audio/mpeg', -Content_length=>(stat MP3)[7]); print ; close MP3; -- end script -- -- Philip Plane _____ philip at xinqu.net | ---------------( )--------------- Glider pilots have no visible means of support From grant at mclean.net.nz Fri Jul 14 18:43:23 2006 From: grant at mclean.net.nz (Grant McLean) Date: Sat, 15 Jul 2006 13:43:23 +1200 Subject: [Wellington-pm] Select at random from a list In-Reply-To: References: Message-ID: <1152927804.7658.14.camel@localhost.localdomain> On Sat, 2006-07-15 at 11:44 +1200, Philip Plane wrote: > I have a little script I wrote to return a randomly selected mp3 from a > playlist. It works, but doesn't seem to be as random as I hoped. The code look reasonable as far as randomness goes. Of course each selection is completely independent of any previous selections so a track you've just heard is no less likely to be selected than one you haven't heard for a while. Perhaps it would work better if you maintained some state between selections. For example, you could start by copying the contents of playlist.txt to a temporary file (writable by the server process), then each request would: 1. slurp all the entries from the temporary file into an array 2. make a random selection and remove that one from the array 3. write all the remaining items back to the temporary file At step 1, if the temporary file was found to be empty then the input could be taken from the original playlist file. Cheers Grant From jarich at perltraining.com.au Fri Jul 14 19:27:41 2006 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Sat, 15 Jul 2006 12:27:41 +1000 Subject: [Wellington-pm] Select at random from a list In-Reply-To: References: Message-ID: <44B8529D.70905@perltraining.com.au> Philip Plane wrote: > Hi Guys, > > I have a little script I wrote to return a randomly selected mp3 from a > playlist. It works, but doesn't seem to be as random as I hoped. Any > comment on a better way of doing this? When you say it doesn't seem to be as random as you hoped, what are you using as your measurement for randomness? Normal random playlists aren't. They shuffle the playlist into a random order and then walk through that order. In your code, however, you're selecting a song from your playlist at random each time. Assuming that your machine has a decent source of randomness[1], you are just as likely to pick out the same song as the previous invocation as you are to pick out any other[2]. Although, as these are independent events, the actual odds of picking the same song two times in a row may be quite small. I have only two pieces of feedback on your code: $mp3 = $playlist[int(rand(scalar(@playlist)))]; can also be written as: $mp3 = $playlist[ rand(@playlist) ]; because both rand expects a scalar argument, and array lookups expect an integer; thus the transformations will be done for you if necessary. Further, you *really* ought to specify a mode whenever you open a file. I know that Perl defaults to reading if you don't specify anything, but if you do this in a script where the user has any control over the filename, then you open yourself up to all sorts of security problems: open PLAYLIST, "< /mp3/playlist.txt" or die ... (or alternately: 5.6+) open PLAYLIST, "<", "/mp3/playlist.txt" or die ... The rest looks good. J [1] Perl's rand isn't truly random for multiple calls. Like many random number generators it uses a truly random seed (as far as possible, and this is dependent on your operating system), and then a pseudo-random number generator for each subsequent call. Since you're only calling rand once during each invocation, this is irrelevant. [2] If you would prefer to shuffle your songs and then listen to then, then you may want to do something like the following. Code is untested. #!/usr/bin/perl -w use CGI; use List::Util qw/shuffle/; use strict; my $curr_playlist = "/tmp/curr_playlist.txt"; my $q = new CGI; my @playlist; # Get already shuffled playlist if we have one if( open CURRPLAYLIST, "<", $curr_playlist ) { @playlist = ; close CURRPLAYLIST; } # If we don't have one, or if it's empty, generate one unless(@playlist) { open SONGLIST, "<", "/mp3/playlist.txt" or die "Couldn't open playlist: $!\n"; @playlist = ; close SONGLIST; # shuffle song order @playlist = shuffle @playlist; } # Take a song off the front my $mp3 = shift @playlist; # Write current playlist back to file (over-writing existing) open NEWPLAYLIST, ">", $curr_playlist; print NEWPLAYLIST @playlist; close NEWPLAYLIST; # Generate song open MP3, "<", $mp3 or die "Couldn't open $mp3: $!\n"; print $q->header(-type=>'audio/mpeg', -Content_length=>(stat MP3)[7]); print ; close MP3; From michael at diaspora.gen.nz Fri Jul 14 21:49:34 2006 From: michael at diaspora.gen.nz (michael at diaspora.gen.nz) Date: Sat, 15 Jul 2006 16:49:34 +1200 Subject: [Wellington-pm] Select at random from a list In-Reply-To: Your message of "Sat, 15 Jul 2006 11:44:07 +1200." Message-ID: Philip Plane writes: >$mp3 = $playlist[int(rand(scalar(@playlist)))]; One feature I found when playing with Python recently that I really liked was a better method of choosing a random element from an array: >>> import random >>> random.choice([1,2,3,4]) 2 >>> random.sample([1,2,3,4], 2) [4, 2] >>> x = [1,2,3,4] >>> random.shuffle(x) >>> x [3, 1, 2, 4] A quick look on CPAN doesn't seem to reveal such a convenient module. Anyone seen one, or should I think about a port? -- michael. From philip at xinqu.net Sun Jul 16 16:59:20 2006 From: philip at xinqu.net (Philip Plane) Date: Mon, 17 Jul 2006 11:59:20 +1200 (NZST) Subject: [Wellington-pm] Select at random from a list In-Reply-To: <44B8529D.70905@perltraining.com.au> References: <44B8529D.70905@perltraining.com.au> Message-ID: On Sat, 15 Jul 2006, Jacinta Richardson wrote: > $mp3 = $playlist[int(rand(scalar(@playlist)))]; > > can also be written as: > > $mp3 = $playlist[ rand(@playlist) ]; Yes, I could do that. Turns out I can also do: $mp3 = $playlist[rand @playlist]; And even better I can correct for the off by one bug that I'd deliberately put in to see if you were all awake :) $mp3 = $playlist[rand @playlist +1]; -- Philip Plane _____ philip at xinqu.net | ---------------( )--------------- Glider pilots have no visible means of support From daniel at rimspace.net Sun Jul 16 17:33:02 2006 From: daniel at rimspace.net (Daniel Pittman) Date: Mon, 17 Jul 2006 10:33:02 +1000 Subject: [Wellington-pm] Select at random from a list In-Reply-To: (Philip Plane's message of "Mon, 17 Jul 2006 11:59:20 +1200 (NZST)") References: <44B8529D.70905@perltraining.com.au> Message-ID: <87sll1hxz5.fsf@rimspace.net> Philip Plane writes: > On Sat, 15 Jul 2006, Jacinta Richardson wrote: > >> $mp3 = $playlist[int(rand(scalar(@playlist)))]; >> >> can also be written as: >> >> $mp3 = $playlist[ rand(@playlist) ]; > > Yes, I could do that. Turns out I can also do: > > $mp3 = $playlist[rand @playlist]; As usual the brackets, on a built-in function, are optional in Perl. Syntax sugar, and the occasional conveniente. > And even better I can correct for the off by one bug that I'd > deliberately put in to see if you were all awake :) > > $mp3 = $playlist[rand @playlist +1]; Actually, you just /introduced/ an off-by-one bug into your code. There are two ways to get the number of elements in a Perl array: my @foo = (1, 2, 3); print "true\n" if $#foo == 2; print "true\n" if scalar @foo == 3; Both of those statements will print: $#array returns the index of the last element of the array -- the number of items less one. Evaluating an array is scalar context, on the other hand, gives the much nicer count of elements. 'rand' returns a number that is *less* than the value of the argument passed. Your amended code is incorrect because the value returned by random, plus one, is mismatched with the array reference values, which are zero based... Rather than correctly returning zero through N minus one, your code is now off by one -- too many. :) Regards, Daniel -- Digital Infrastructure Solutions -- making IT simple, stable and secure Phone: 0401 155 707 email: contact at digital-infrastructure.com.au http://digital-infrastructure.com.au/ From jarich at perltraining.com.au Sun Jul 16 18:03:40 2006 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Mon, 17 Jul 2006 11:03:40 +1000 Subject: [Wellington-pm] Select at random from a list In-Reply-To: References: <44B8529D.70905@perltraining.com.au> Message-ID: <44BAE1EC.9090804@perltraining.com.au> Philip Plane wrote: > Yes, I could do that. Turns out I can also do: > > $mp3 = $playlist[rand @playlist]; I just assumed you liked your parentheses. :) > And even better I can correct for the off by one bug that I'd deliberately > put in to see if you were all awake :) > > $mp3 = $playlist[rand @playlist +1]; Daniel has already pointed out why this doesn't do what you wanted it to. The other issue I'll raise here is one of precedence. Is the above syntactically the same as: $mp3 = $playlist[rand(@playlist) +1]; or $mp3 = $playlist[rand (@playlist+1)]; If you can't tell, just by looking, then you ought to put parentheses in. Be aware that these are not the same things. rand(x+1), gives you a number between 0 and x+1, whereas rand(x)+1 gives you a number between 1 and x+1. Predecence is something to always watch out for. Particularly for anyone else who has to maintain your code. J -- ("`-''-/").___..--''"`-._ | Jacinta Richardson | `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia | (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 | _..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au | (il),-'' (li),' ((!.-' | www.perltraining.com.au | From grant at mclean.net.nz Sun Jul 16 18:19:02 2006 From: grant at mclean.net.nz (Grant McLean) Date: Mon, 17 Jul 2006 13:19:02 +1200 Subject: [Wellington-pm] Select at random from a list In-Reply-To: References: Message-ID: <1153099142.603.6.camel@putnam.wgtn.cat-it.co.nz> On Sat, 2006-07-15 at 16:49 +1200, michael at diaspora.gen.nz wrote: > Philip Plane writes: > >$mp3 = $playlist[int(rand(scalar(@playlist)))]; > > One feature I found when playing with Python recently that I really > liked was a better method of choosing a random element from an array: > > >>> import random > >>> random.choice([1,2,3,4]) > 2 > >>> random.sample([1,2,3,4], 2) > [4, 2] > >>> x = [1,2,3,4] > >>> random.shuffle(x) > >>> x > [3, 1, 2, 4] > > A quick look on CPAN doesn't seem to reveal such a convenient module. > Anyone seen one, or should I think about a port? It does seem like the sort of thing that ought to be on CPAN, but I'm not aware of any implementation either. The TODO list for the List::MoreUtils module does include 'random_item' so you could submit a patch to the maintainer of that module. That approach would have the added advantage of not leaving you with the burden of maintaining the code :-) http://search.cpan.org/dist/List-MoreUtils/lib/List/MoreUtils.pm#TODO Cheers Grant From douglas at paradise.net.nz Mon Jul 17 05:26:11 2006 From: douglas at paradise.net.nz (Douglas Bagnall) Date: Tue, 18 Jul 2006 00:26:11 +1200 Subject: [Wellington-pm] Select at random from a list In-Reply-To: <1152927804.7658.14.camel@localhost.localdomain> References: <1152927804.7658.14.camel@localhost.localdomain> Message-ID: <44BB81E3.9050201@paradise.net.nz> Grant McLean wrote: > Perhaps it would work better if you maintained some state between > selections. For example, you could start by copying the contents of > playlist.txt to a temporary file (writable by the server process), then > each request would: > > 1. slurp all the entries from the temporary file into an array > 2. make a random selection and remove that one from the array > 3. write all the remaining items back to the temporary file > > At step 1, if the temporary file was found to be empty then the input > could be taken from the original playlist file. You could also do this with a closure. Although my perl is rusty and probably suspect, the following works: ------------------------------ use strict; use warnings; sub shuffle{ my @all = @_; my @left; return sub { while (1){ return splice(@left, rand(@left), 1) if @left; @left = @all; } } } my @playlist = qw{a b c d}; my $playlist = shuffle(@playlist); for (1..12){ print &$playlist()." "; } ------------------------------ It will print something like: a c d b d c b a d b a c The effect is semantically equivalent to Grant's solution, but saves state in the shuffle function rather than a temporary file. The subroutine returned by shuffle() is stuck in shuffle's namespace, so it sees @left and @all even when it is called from outside (just like a normal sub can see top-level variables). @all and @left are initialised to the input list, but each time the returned sub is called, @left is depleted by one item. It refills when empty, and the cycle continues. This is still imperfect, however, if you don't want back-to-back repeats. If the list is shuffled first as "a c b d", then as "d c a b", song d repeats. so perhaps something like this would be better: -------------------------------------- my $WAIT = 1; sub shuffle2{ my @mp3s = @_; return sub { my $next = splice(@mp3s, rand(@mp3s - $WAIT), 1); push (@mp3s, $next); return $next; } } my @playlist = qw{a b c d}; my $playlist = shuffle2(@playlist); my ($a, $b) = ('', ''); my %count; for (1..1000){ $a = &$playlist(); die "repeating!!" if ($a eq $b); #print $a; $b = $a; $count{$a}++; } while (my ($k, $v) = each %count) { print "$k: $v\n"; } --------------------------- $WAIT determines how many intervening songs are necessary before a repeat. Obviously it can't be less than 1 or greater than @mp3s - 1, and would probably be best determined dynamically. regards, douglas From grant at mclean.net.nz Mon Jul 17 14:55:46 2006 From: grant at mclean.net.nz (Grant McLean) Date: Tue, 18 Jul 2006 09:55:46 +1200 Subject: [Wellington-pm] [Fwd: Newsletter from the O'Reilly UG Program, July 11] Message-ID: <1153173346.10160.12.camel@putnam.wgtn.cat-it.co.nz> -------- Forwarded Message -------- > From: Marsee Henon > Subject: Newsletter from the O'Reilly UG Program, July 11 > Date: Tue, 11 Jul 2006 14:38:37 -0700 > ================================================================ > O'Reilly News for User Group Members > July 11, 2006 > ================================================================ > ---------------------------------------------------------------- > New Releases > ---------------------------------------------------------------- > -Agile Retrospective > -bash Quick Reference (PDF) > -BigNum Math > -The Book of JavaScript, Second Edition > -Build Your Own AJAX Web Applications > -Classic LEGO Mindstorms Projects and Software Tools > -Combating Spyware in the Enterprise > -Dictionary of Information Security > -Essential Computer Security > -Hacking the Cable Modem > -FileMaker 8.5: Integrating the Web (PDF) > -How to Cheat at Managing Information Security > -How to Cheat at Securing a Wireless Network > -How to Keep Your Boss from Sinking Your Project (PDF) > -The Internet: The Missing Manual > -Joe Grand's Best of Hardware, Wireless, and Game Console Hacking > -Learning PHP and MySQL > -LPI Linux Certification in a Nutshell, Second Edition > -PC Music--The Easy Guide > -Photoshop Workflow Setups > -Python in a Nutshell, Second Edition > -Rails Recipes > -SUSE Linux > -Syngress IT Security Project Management Handbook > -VB 2005 Black Book > -Wicked Cool PHP > -XQuery (Rough Cuts Version) > -Your Life in Web Apps (PDF) > ---------------------------------------------------------------- > Upcoming Events > ---------------------------------------------------------------- > -Phillip Torrone at HOPE Number Six, New York, NY--July 22 > -O'Reilly Authors at the Apple Store, San Francisco--August 9 > ---------------------------------------------------------------- > Conference News > ---------------------------------------------------------------- > -EuroOSCON Registration is Open > -Register for OSCON, July 24-28--Portland,OR > -OSCON Exhibit Hall Passes Still Available > -OSCamp 2006 at OSCON, July 24-28 > ---------------------------------------------------------------- > News > ---------------------------------------------------------------- > -What Is a Wiki? (and How to Use One for Your Projects) > -The Long View of Identity > -Nat Torkington Previews OSCON 2006 > -Rethinking Community Documentation > -The Adobe Lightroom/Photoshop Iceland Adventure > -Secrets of the Arpeggiator > -Parallels Desktop for the Mac > -Wireless Security on the Road Without a VPN > -How To Recover from Registry Corruption > -Inside Vista's New Diagnostic Tools > -Build Your Own Ajax Web Applications > -Five Keys to Improving Web Site Conversions > -How to Code HTML Email Newsletters > -What's New in Eclipse 3.2 Java Development Tools? > -Making the Most of JDBC with WebRowSet > -MAKE Podcast: Weekend Projects--Make a Workbench > -Building Tricorders > > --------------------------------------------------------------- > New Releases--Books, PDFs, and Rough Cuts > ---------------------------------------------------------------- > Get 30% off a single book or 35% off two or more books from O'Reilly, > No Starch, Paraglyph, PC Publishing, Pragmatic Bookshelf, SitePoint, > or Syngress books you purchase directly from O'Reilly. > Just use code DSUG when ordering online or by phone 800-998-9938. > > > Free ground shipping on orders $29.95 or more. > For more details, go to: > > > Did you know you can request a free book to review for your > group? Ask your group leader for more information. > > For book review writing tips and suggestions, go to: > > > ***Agile Retrospective > Publisher: Pragmatic Bookshelf > ISBN: 0977616649 > Project retrospectives help teams examine what went right or wrong on a > project. But traditionally, retrospectives (also known as > "post-mortems") are only held at the end of the project--too late to > help. You need agile retrospectives that are iterative and incremental. > You need to accurately find and fix problems to help the team today. > > > > ***bash Quick Reference (PDF) > Publisher: O'Reilly > ISBN: 0596527764 > In this quick reference, you'll find everything you need to know about > the bash shell. Whether you print it out or read it on the screen, this > PDF gives you answers to annoying questions that come up when you're > writing shell scripts: What characters do you need to quote? How do you > get variable substitution to do exactly what you want? How do you use > arrays? > > > > ***BigNum Math > Publisher: Syngress > ISBN: 1597491128 > "BigNum Math" takes the reader on a detailed and descriptive course of > the process of implementing bignum multiple precision math routines. The > text begins with a coverage of what "bignum math" means and heads into > the lower level functions. > > > > ***The Book of JavaScript, Second Edition > Publisher: No Starch Press > ISBN: 1593271069 > "The Book of JavaScript" teaches how to add interactivity, animation, > and other tricks to web sites with JavaScript. Rather than provide a > series of cut-and-paste scripts, that takes the reader through a series > of real world JavaScript code with an emphasis on understanding. Each > chapter focuses on a few important JavaScript features, shows how > professional web sites incorporate them, and gives you examples of how > to add those features to web sites. > > > > ***Build Your Own AJAX Web Applications > Publisher: SitePoint > ISBN: 0975841947 > This practical hands-on guide for first-time AJAX will walk you through > building multiple AJAX applications, with each application highlighting > a different strength and use of AJAX. Throughout the book, emphasis is > placed on modern, standards-compliant techniques, accessibility, and > cross-browser compatability. > > > > ***Classic LEGO Mindstorms Projects and Software Tools > Publisher: Syngress > ISBN: 159749089X > The perfect book/DVD for the Lego Mindstorms geek eager to extend the > life of their RIS 1.x and 2.x kits, RCX Bricks, motors, and programs by > building new projects. Includes forty projects, software tools such as > LDraw, MLCad, and POV-Ray, and complete RCX and NQC code files. All > projects are in PDF form on the DVD, ready for printing, copying, or > annotating. A perfect resource for clubs and classes as well. > > > > ***Combating Spyware in the Enterprise > Publisher: Syngress > ISBN: 1597490644 > "Combating Spyware in the Enterprise" is the first book published on > defending enterprise networks from increasingly sophisticated and > malicious spyware. System administrators and security professionals > responsible for administering and securing networks ranging in size from > SOHO networks up to the largest, enterprise networks will learn to use a > combination of free and commercial anti-spyware software, firewalls, > intrusion detection systems, intrusion prevention systems, and host > integrity monitoring applications to prevent the installation of > spyware, and to limit the damage caused by spyware that does in fact > infiltrate their networks. > > > > ***Dictionary of Information Security > Publisher: Syngress > ISBN: 1597491152 > The dictionary has the most up-to-date terms, including those related to > computer viruses, malware, and more recent technologies such as wireless > networking. > > > > ***Essential Computer Security > Publisher: Syngress > ISBN: 1597491144 > Do you want your computer to be absolutely, positively, 100% secure > against all vulnerabilities and exploits both known now and those yet to > be discovered? That's simple--leave your computer in the box it came > in. The only way to be 100% secure is never to turn the computer on. > Once you turn the computer on, you begin a tight-rope-balancing act > between functionality, convenience, and security. > > > > ***Hacking the Cable Modem > Publisher: No Starch Press > ISBN: 1593271018 > When freed from restrictions set by service providers, cable modems can > be tricked out to reach unbelievably fast speeds. "Hacking the Cable > Modem" shows readers how cable modems work, and how to bypass security, > install firmware updates, customize cable modems, increase upload and > download speeds, unlock hidden features and more. Detailed illustrations > and easily understandable terminology show how to modify actual devices. > > > > ***FileMaker 8.5: Integrating the Web (PDF) > Publisher: O'Reilly > ISBN: 059652823X > FileMaker Pro, famed for power and ease of use, has added a suite of new > features that can seriously boost your database productivity. This > tutorial helps you take full advantage of the fresh stuff. It focuses on > FileMaker's terrific new tool for integrating the Web with your > databases: the Web Viewer. Step-by-step instructions help you create a > Web Viewer from one of FileMaker's templates or a totally custom version > of your own. But the tutorial doesn't stop there. It goes on to cover > Object Naming, including FileMaker's rules for Object Names and how to > use them in scripts; new scripts; new functions; and Universal Binary > for the new Intel Macs. > > > > ***How to Cheat at Managing Information Security > Publisher: Syngress > ISBN: 1597491101 > This is the only book that covers all the topics that any budding > security manager needs to know! This book is written for managers > responsible for IT/Security departments from mall office environments up > to enterprise networks. These individuals do not need to know about > every last bit and byte, but they need to have a solid understanding of > all major IT security issues to effectively manage their departments. > > > > ***How to Cheat at Securing a Wireless Network > Publisher: Syngress > ISBN: 1597490873 > Wireless connectivity is now a reality in most businesses. Yet by its > nature, wireless networks are the most difficult to secure and are often > the favorite target of intruders. This book provides the busy network > administrator with best-practice solutions for securing the wireless > network. The book endorses the principle that the best strategy is to > deploy multiple layers of security, each reinforcing the other. Yet it > never strays from its emphasis on the practical; that any tool or > methodology that is deployed must work reliably, allow sufficient > access, and require a minimal amount of maintenance. > > > > ***How to Keep Your Boss from Sinking Your Project (PDF) > Publisher: O'Reilly > ISBN: 0596528027 > Like it or not, your project needs management. Yet few good software > projects can survive bad management. If you're a programmer on a > high-visibility project, this PDF offers five principle guidelines for > managing upward that will help you help your boss make the right > decisions about setting project expectations, working with users and > stakeholders, putting the project on the right track and keeping it > there. The PDF also covers what problems cause projects to fail and how > to fix them, and what you can do to keep your software project from > running into trouble. > > > > ***The Internet: The Missing Manual > Publisher: O'Reilly > ISBN: 059652742X > The Internet is synonymous with change--that's one of its charms, and > one of its headaches. You think you know the Internet, but are you > really up to speed on internet telephony, movie and TV downloading, > multiplayer games, online banking and dating, and photosharing? This > utterly current book covers getting online, searching/finding > information, downloading and sharing movies, music, and photos, and the > latest ways to keep in touch. > > > > ***Joe Grand's Best of Hardware, Wireless, and Game Console Hacking > Publisher: Syngress > ISBN: 1597491136 > This book is perfect for any devoted hardware hacker, homebrew gamer, or > geek compelled to void hardware warranties. Twenty projects from the > books "Hardware Hacking" and "Game Console Hacking" are compiled on a > single DVD, providing hi-res color for clear views of each step in the > hack along with the ability to print individual sheets. Hacks include > Xbox, PS2, Wireless 802.11, Macintosh, iPod, and most of the classic > consoles from Atari and Nintendo. The book includes chapters on hacking > tools and electrical engineering basics as well as the background on > each hardware device. > > > > ***Learning PHP and MySQL > Publisher: O'Reilly > ISBN: 0596101104 > Featuring basic concepts explained in plain English, "Learning PHP and > MySQL" is the ideal guide for newcomers attracted to the popular PHP and > MySQL combination. Learn in an easy-to-follow fashion how to generate > dynamic web content. Also covers error handling, security, HTTP > authentication, and more. > > > > ***LPI Linux Certification in a Nutshell, Second Edition > Publisher: O'Reilly > ISBN: 0596005288 > "LPI Linux Certification in a Nutshell, Second Edition" is an invaluable > resource for determining what you need to practice to pass the Linux > Professional Institute exams. This book will help you determine when > you're ready to take the exams, which are technically challenging and > designed to reflect the skills that administrators need in real working > environments. > > > > ***PC Music--The Easy Guide > Publisher: PC Publishing > ISBN: 1870775201 > Completely updated with new sections on the MP3 revolution, the PC as a > complete Media Center and the realization of your PC as a recording > studio, this new edition of "PC Music--The Easy Guide," will show you > what can be done, what it all means, and what you will need to start > creating and enjoying your own music on your PC. > > > > ***Photoshop Workflow Setups > Publisher: O'Reilly > ISBN: 0596101686 > Adobe Photoshop has so many different work areas and tools that it can > become confusing or even intimidating for digital photographers to use > in a production environment. This first book in our new series on > digital photography offers a step-by-step approach to Photoshop's vast > collection of menus, palettes, and tools, showing you not only how they > work, but how they should work for your specific needs in a visually > uncluttered workspace. > > > > ***Python in a Nutshell, Second Edition > Publisher: O'Reilly > ISBN: 0596100469 > "Python in a Nutshell" provides a solid, no-nonsense quick reference to > information that programmers rely on the most. This book will > immediately earn its place in any Python programmer's library. > > > > ***Rails Recipes > Publisher: Pragmatic Bookshelf > ISBN: 0977616606 > You've read the tutorials and watched the online videos. You have a > strong grasp of all of the ingredients that make up a successful Rails > application. But ingredients don't just turn themselves into a meal. > Chad Fowler's "Rails Recipes" is a collection of recipes that will take > you step by step through the most cutting edge, modern Rails techniques, > mixing the ingredients to create world-class web applications. Learn how > to do it, and how to do it right. > > > > ***Stephen Johnson on Digital Photography > Publisher: O'Reilly > ISBN: 059652370X > A master photographer and teacher since 1977, Stephen Johnson is widely > recognized as a pioneer of digital photography. His new book chronicles > his ride on the bleeding edge of this medium's evolution, and provides a > practical in-depth introduction to digital photography that includes the > latest techniques. Complete with beautiful color photographic examples > and illustrations, this book is a unique, passionate, holistic > examination for every student of photography. > > > > ***SUSE Linux > Publisher: O'Reilly > ISBN: 059610183X > Whether you use SUSE Linux from Novell, or the free openSUSE > distribution, this book has something for every level of user. The > modular, lab-based approach not only shows you how--but also explains > why--and gives you the answers you need to get up and running with SUSE > Linux. > > > > ***Syngress IT Security Project Management Handbook > Publisher: Syngress > ISBN: 1597490768 > As the late management guru Peter Drucker once said, "Plans are only > good intentions unless they immediately degenerate into hard work." The > intent of this book is not to lead you through long, arduous planning > processes while hackers are stealing your network out from under you. > The intent is to provide you with effective network security planning > tools so that you can "degenerate into hard work" as quickly as possible > to keep your network secure with the least amount of effort. > > > > ***VB 2005 Black Book > Publisher: Paraglyph Press > ISBN: 1933097086 > "Visual Basic 2005 Black Book" is one of the first comprehensive books > that covers the new version of Visual Basic and the development features > of Microsoft's .NET platform in depth. It explains the major changes to > VB and provides numerous tips and practical solutions for developing > applications and guides the programmer through all the new features of > VB 2005 with detailed coverage of the new controls, language > enhancements, and architecture features. > > > > ***Wicked Cool PHP > Publisher: No Starch Press > ISBN: 1593271026 > "Wicked Cool PHP" provides PHP scripts that can be implemented > immediately to make programmers' lives easier, including scripts for > processing credit cards, getting live shipping quotes, and accepting > PayPal payments online. Author William Steinmetz approaches the > limitations of PHP frankly and honestly, showing readers where security > holes might be created by novice programmers and suggesting workarounds > for when PHP fails. > > > > ***XQuery (Rough Cuts Version) > Publisher: O'Reilly > ISBN: 0596527888 > "XQuery" delivers a carefully-paced tutorial that teaches everything a > developer needs to start querying XML and databases. Learn how to join > multiple data sources or hugely disparate data sources and documents, > quickly sort the results or find query errors based on the data schema, > and query elements differently depending on their type. This book covers > the most useful functions of XQuery and explains how to query a variety > of relational and XML sources. It also includes specific sections on > learning XQuery for SQL and XSLT programmers. > > > > ***Your Life in Web Apps (PDF) > Publisher: O'Reilly > ISBN: 059652806X > Have you dreamed of a simpler life where web apps and a browser meet all > of your computing needs? All you need is a network connection. In this > PDF Giles Turnbull introduces you to a day of web apps-only, then he > surveys the best and most innovative web apps from the current crop > available right now. He also addresses practicality, security issues, > and backup strategies for living the web app life. Is it really > possible? This PDF will help you decide. > > > > ***MAKE Magazine Subscriptions > The annual subscription price for four issues is $34.95. When you > subscribe with this link, you'll get a free issue--the first one plus > four more for $34.95. So subscribe for yourself or friends with this > great offer for charter subscribers: five volumes for the cost of four. > Subscribe at: > > > ================================================ > Upcoming Events > ================================================ > ***For more events, please see: > http://events.oreilly.com/ > > > ***Phillip Torrone at HOPE Number Six, New York, NY--July 22 > Editor Phillip Torrone (Makezine.com) will be speaking on "Citizen > Engineer--Consumer Electronics Hacking and Open Source Hardware" at HOPE > (Hackers On Planet Earth) Number Six. > > > > ***O'Reilly Authors at the Apple Store, San Francisco--August 9 > Join authors Derrick Story ("Digital Photography Pocket Guide, 3rd > Ed." and "iPhoto 6: The Missing Manual"), Chuck Toporek ("Running Boot > Camp" and "Inside .Mac"), and Adam Goldstein ("AppleScript: The Missing > Manual" and "Switching to the Mac: The Missing Manual, Tiger Ed.") for > an evening at the Apple Store in San Francisco. > > > ================================================ > Conference News > ================================================ > ***EuroOSCON Registration is Open > The preliminary schedule for the 2nd annual EuroOSCON, O'Reilly's > European Open Source Convention, 18-21 September in Brussels, is now > available. Featured speakers include Jeff Waugh, Damian Conway, Greg > Stein, Rasmus Lerdorf, Marten Mickos, Tim O'Reilly, and many others. > > > User Group discounts are available, email marsee at oreilly.com for more > information. > > To register for the conference, go to: > > > > ***OSCON, July 24-28--Portland,OR > OSCON, the O'Reilly Open Source Convention, is still where open source > rubber meets the road. OSCON happens July 24-28, 2006 in open source > hotspot Portland, Oregon. Hundreds of sessions and tutorials will be > offered. Thousands of open source mavericks, brainiacs, hackers, > activists, scientists, and their admirers, some in business-casual > disguise will be there. Read all about it. > > > Use code "os06dsug" when you register, and receive 15% off > the early registration price. > > To register for the conference, go to: > > > > ***OSCON Exhibit Hall Passes Still Available > Don't have the budget or time for all of OSCON? You can register for > a free Expo Hall pass: > > > The Expo Hall pass includes the following: > -Entrance to the Exhibit Hall and all events held in the Exhibit Hall > including a reception on Wednesday, July 26 from 6:00pm-7:30pm. > -Admission to the Products & Services track > -Admission to Vendor Presentations held in the Exhibit Hall > -Access to BOFs , > evening events , > and community meetings > -Access to OSCAMP > > > ***OSCamp 2006 at OSCON, July 24-28 > OSCamp 2006, included with the free Expo Hall pass, is a grassroots > cooperative effort with O'Reilly. OSCamp seeks to organize the fringe of > activity that has grown up around OSCON during the last several years so > the event can rock even more! Come together to network, write code, have > fun and learn about the cool things that are afoot in the movement. > Bring your friends. > > OSCamp is an "open" space for meeting, learning, connecting, and writing > code...with no limits or agendas. The only charge is to come and learn > and contribute as much as you can. The agenda is created and modified > "on the fly" by the participants. You can add to the agenda any issue of > importance to you. It will be discussed and addressed to the greatest > extent possible. All of the key points and next steps will be captured > online at OSCamp.org so the entire Freedom/Libre/Open community can > benefit. > > Register for the exhibit hall pass and make sure you use the special > code os06oscamp. > > > > For OSCamp information, registration, and schedule, go to: > > > > ================================================ > News From O'Reilly & Beyond > ================================================ > --------------------- > General News > --------------------- > ***What Is a Wiki? (and How to Use One for Your Projects) > Wikis are becoming known as the tool of choice for large, > multiple-participant projects because jumping in and revising the pages > of a wiki is easy for anyone to do. This article covers how to > effectively use a wiki to keep notes and share ideas among a group of > people, and how to organize that wiki to avoid lost thoughts, and > encourage serendipity. Matt Webb and Tom Stafford co-authored this > article using a wiki, as they did to write their book, "Mind Hacks." > > > > ***The Long View of Identity > Who are you online? Your digital identity is a complex bundle of > information--not just what you say about yourself, but what other people > say about you and how trustworthy they are. O'Reilly editor Andy Oram > recently attended the Identity Mashup conference at Harvard Law's > Berkman Center and reports on one of the most vital issues of privacy > and usability on the Internet. > > > --------------------- > Open Source > --------------------- > ***Nat Torkington Previews OSCON 2006 > This year's Open Source conference runs July 24-28 in Portland, Oregon. > Nat Torkington talks about what you can expect at this year's show. He > explains that each technology has a great set of talks, but the strength > of OSCON is that so many different topics are covered in one conference. > It allows you to stretch and learn things from and share ideas with > people solving similar problems using different tools. (5 minute, 47 > seconds) > > > > ***Rethinking Community Documentation > Good documentation makes good software great. Poor documentation makes > great software less useful. What is good documentation though, and how > can communities produce it effectively? Andy Oram explores how free and > open source software projects can share knowledge with users and > how publishers and editors fit into the future of documentation. > > > --------------------- > Digital Media > --------------------- > ***The Adobe Lightroom/Photoshop Iceland Adventure > From Derrick Story: The team of Adventure photographers arrive in > Iceland on July 28. This is an Adventure both in the sense of location > photography and RAW workflow. Each shooter will be using Adobe Lightroom > on a laptop in the field to process and output the images. Here?s a > quick overview of who is going, where they will be, and the reports from > Iceland that will be coming your way. > > > > ***Secrets of the Arpeggiator > Arpeggiators are some of the handiest gadgets in computer music. With an > absolute minimum of dexterity, you can create driving rhythms and > superhuman tapestries of notes. Jim Aikin explains how arpeggiators > work, what features to look for, and how to use them to revitalize your > music. > > > --------------------- > Mac > --------------------- > ***Parallels Desktop for the Mac > The short version of this discussion about Parallels can be summed up in > a single word: amazing. Nothing is perfect, of course, and there is room > for improvement as Parallels moves this product beyond version 1.0. > However, if you have an Intel-based Mac and need or want to run > Microsoft Windows, some version of Linux, or some other supported > operating system, read on. Todd Ogasawara reports. > > > > ***Wireless Security on the Road Without a VPN > A Virtual Private Network (VPN) is a secure way to connect to web sites > and email while using wireless networks. Unfortunately, not everyone has > access to a VPN, so what do you do? In this article you'll learn how to > secure your online activities without a VPN. > > > --------------------- > Windows/.NET > --------------------- > ***How To Recover from Registry Corruption > What do you do if your system crashes and you've got a corrupt registry? > Mitch Tulloch comes to your rescue with advice on how to recover and > restore your registry. > > > > ***Inside Vista's New Diagnostic Tools > Vista comes with a great suite of diagnostic tools for helping your PC > run better and avoid crashes. Here's the rundown on what they are and > how to use them. > > > --------------------- > Web > --------------------- > ***Build Your Own Ajax Web Applications > Eager to dabble in remote scripting, but don't know where to start? Let > Ajax guru Matthew Eernisse be your pilot and guide you to the heights of > Web 2.0 success. > > > > ***Five Keys to Improving Web Site Conversions > Are your visitors not buying enough, subscribing to your newsletter, or > downloading samples? Ensure good and growing conversions with this > guide. > > > > ***How to Code HTML Email Newsletters > Find out the best way to make your HTML newsletters and ezines sizzle > with this handy how-to guide to the unique challenges in coding HTML for > email. > > > --------------------- > Java > --------------------- > ***What's New in Eclipse 3.2 Java Development Tools? > The popular Eclipse IDE's latest release, version 3.2, is the > cornerstone of an ambitious release of ten Eclipse-branded projects on > the same day. But what's in it for you? Ed Burnette takes a look at the > new features in Eclipse's Java Development Tools and shows you how > they'll make your development much easier. > > > > ***Making the Most of JDBC with WebRowSet > Database to XML and back again. If everyone's doing some or all of this, > then shouldn't we write it once, get it right, and standardize? JDBC > 3.0's WebRowSet offers a profound increase in power over the old > ResultSet. Sharad Acharya shows you what's possible. > > > --------------------- > Podcasts > --------------------- > ***MAKE Podcast: Weekend Projects--Make a Workbench > Every week, Bre Pettis will be bringing you a project that you can make > over the weekend. For this first podcast, you can learn how to make a > workbench for your garage, studio, or get your priorities straight and > put it in your livingroom! > > > > ***Building Tricorders > We're featuring four sessions from the first day of the Where 2.0 > conference. Josh Peterson tells you to live your life as if you're on > vacation; Mike Liebhold looks at a future in which the invisible > annotations on the world around you becomes visible; Schuler Erle demos > Gutenkarte, which reveals geographic information in the books you read; > and Lauren Gelman cautions us about the privacy issues in exposing our > data. (DTF 06-26-2006: 26 minutes, 15 seconds) > > > Until next time-- > > Marsee Henon > > > ================================================================ > O'Reilly > 1005 Gravenstein Highway North > Sebastopol, CA 95472 > http://ug.oreilly.com/ http://ug.oreilly.com/creativemedia/ > ================================================================ From ewen at naos.co.nz Wed Jul 19 19:19:47 2006 From: ewen at naos.co.nz (Ewen McNeill) Date: Thu, 20 Jul 2006 14:19:47 +1200 Subject: [Wellington-pm] Hash slices with missing keys Message-ID: <20060720021947.988FF8694B2@wat.la.naos.co.nz> Hi, If I have a hash with some fields in it, and I use slices to pick out and swap over some of the values in the hash, and some of the keys referenced in the slice do not exist, am I guarenteed to get undef for the keys that don't exist? Also is this warning/error free with "use strict". Experimentation says yes, but I'm wary that I'm relying on some undocumented implementation quirk. Eg, @KEYS_A = qw(A B C D); @KEYS_B = qw(E F G H); %hash = ( 'A' => 'aaaaaa', 'B' => 'bbbbbb', 'C' => 'cccccc', 'D' => 'dddddd', 'G' => 'gggggg', 'H' => 'hhhhhh' ); @hash{@KEYS_A, @KEYS_B} = @hash{@KEYS_B, @KEYS_A}; # swap values over Note how E and F are not present in %hash in the beginning. What I want to happen is that after the above code A and B are undef, and the other values swap over as indicated. And that appears to be the case, but I'm not clear if this is documented behaviour. Eg, perldata(1) doesn't seem to say anything either way. Failing this I'll need to copy over fields individually with some third variable to hold the values in transit. Ewen From philip at xinqu.net Wed Jul 19 19:24:43 2006 From: philip at xinqu.net (Philip Plane) Date: Thu, 20 Jul 2006 14:24:43 +1200 (NZST) Subject: [Wellington-pm] Select at random from a list In-Reply-To: <44B8529D.70905@perltraining.com.au> References: <44B8529D.70905@perltraining.com.au> Message-ID: Hi All, We haven't flogged my simple script to death yet. One more data point. On Sat, 15 Jul 2006, Jacinta Richardson wrote: > When you say it doesn't seem to be as random as you hoped, what are you > using as your measurement for randomness? I did a little test to see if random() produced significantly different results being run once per invocation as opposed to in a loop. This took a while because the loop was pretty fast compared to starting perl up 750,000 times :) Here's the output from the loop: Values 1228 Samples 740845 Average 603 Maximum 686 Minimum 524 Mean 603.293974 Variance 608.550021 Standard Dev: 24.668807 Here's the output from running the script 740,846 times. Values 1228 Samples 740846 Average 603 Maximum 687 Minimum 524 Mean 603.294788 Variance 636.770405 Standard Dev: 25.234310 So they're both pretty random, certainly random enough to select MP3s for me. -- Philip Plane _____ philip at xinqu.net | ---------------( )--------------- Glider pilots have no visible means of support From grant at mclean.net.nz Wed Jul 19 19:32:07 2006 From: grant at mclean.net.nz (Grant McLean) Date: Thu, 20 Jul 2006 14:32:07 +1200 Subject: [Wellington-pm] Hash slices with missing keys In-Reply-To: <20060720021947.988FF8694B2@wat.la.naos.co.nz> References: <20060720021947.988FF8694B2@wat.la.naos.co.nz> Message-ID: <1153362727.23524.17.camel@putnam.wgtn.cat-it.co.nz> On Thu, 2006-07-20 at 14:19 +1200, Ewen McNeill wrote: > Hi, > > If I have a hash with some fields in it, and I use slices to pick out > and swap over some of the values in the hash, and some of the keys > referenced in the slice do not exist, am I guarenteed to get undef for > the keys that don't exist? Also is this warning/error free with "use > strict". Experimentation says yes, but I'm wary that I'm relying on > some undocumented implementation quirk. > > Eg, > > @KEYS_A = qw(A B C D); > @KEYS_B = qw(E F G H); > > %hash = ( > 'A' => 'aaaaaa', > 'B' => 'bbbbbb', > 'C' => 'cccccc', > 'D' => 'dddddd', > 'G' => 'gggggg', > 'H' => 'hhhhhh' > ); > > @hash{@KEYS_A, @KEYS_B} = @hash{@KEYS_B, @KEYS_A}; # swap values over Yes, for every element in the union of @KEYS_A and @KEYS_B, the corresponding key in %hash will exist after the assignment, regardless of whether it existed before and regardless of whether it ends up with a value of undef. > Failing this I'll need to copy over fields individually with some third > variable to hold the values in transit. Nope, you're safe to rely on Perl doing the intermediate storage thing for you. Cheers Grant From ewen at naos.co.nz Wed Jul 19 19:36:55 2006 From: ewen at naos.co.nz (Ewen McNeill) Date: Thu, 20 Jul 2006 14:36:55 +1200 Subject: [Wellington-pm] Hash slices with missing keys In-Reply-To: Message from Grant McLean of "Thu, 20 Jul 2006 14:32:07 +1200." <1153362727.23524.17.camel@putnam.wgtn.cat-it.co.nz> Message-ID: <20060720023655.6DE768694B2@wat.la.naos.co.nz> In message <1153362727.23524.17.camel at putnam.wgtn.cat-it.co.nz>, Grant McLean wr ites: >On Thu, 2006-07-20 at 14:19 +1200, Ewen McNeill wrote: >> If I have a hash with some fields in it, and I use slices to pick out >> and swap over some of the values in the hash, and some of the keys >> referenced in the slice do not exist, am I guarenteed to get undef for >> the keys that don't exist? [....] >> @hash{@KEYS_A, @KEYS_B} = @hash{@KEYS_B, @KEYS_A}; # swap values over > >Yes, for every element in the union of @KEYS_A and @KEYS_B, the >corresponding key in %hash will exist after the assignment, regardless >of whether it existed before and regardless of whether it ends up with a >value of undef. Excellent, that's exactly what I want. Perl's such a handy language. Thanks for the prompt response. Ewen From grant at mclean.net.nz Thu Jul 20 19:01:00 2006 From: grant at mclean.net.nz (Grant McLean) Date: Fri, 21 Jul 2006 14:01:00 +1200 Subject: [Wellington-pm] goto saves the day! Message-ID: <1153447260.10883.27.camel@putnam.wgtn.cat-it.co.nz> Have you ever had a bunch of related scripts or modules that all start with ... use strict; use warnings; use SomeCommonModule; and wondered if you could shorten that down? I have. The problem is that 'use strict' and 'use warnings' only apply to the scope where they are called so putting them in SomeCommonModule.pm has no effect on whatever scope originally called 'use SomeCommonModule'. But, if you break it down: use strict; is equivalent to: require strict; strict::import(); (only with some added BEGIN style magic that we don't need to worry about right now). In strict.pm, there's a subroutine called 'import' that works out what scope it was called from and adjusts stricture flags back in the caller's scope. So it turns out the answer is very easy, all we have to do is make SomeCommonModule::import an alias for strict::import. Which can be done like this: package SomeCommonModule; *import = \&strict::import; 1; The same trick could be used to turn warnings on but of course SomeCommonModule::import can't be aliased to both strict::import and warnings::import at the same time :-( But we can enable warnings globally by setting $^W to 1. So we can combine the two techniques using goto: package SomeCommonModule; sub import { $^W = 1; goto &strict::import; } 1; In this case, goto calls strict::import after first removing SomeCommonModule::import from the call stack. So as far as strict.pm is concerned, it was called directly from whatever it was that said 'use SomeCommonModule'. I'd never used goto in a Perl program before, so I just had to share that. Cheers Grant From grant at mclean.net.nz Thu Jul 20 19:58:18 2006 From: grant at mclean.net.nz (Grant McLean) Date: Fri, 21 Jul 2006 14:58:18 +1200 Subject: [Wellington-pm] goto saves the day! In-Reply-To: <1153447260.10883.27.camel@putnam.wgtn.cat-it.co.nz> References: <1153447260.10883.27.camel@putnam.wgtn.cat-it.co.nz> Message-ID: <1153450698.10883.31.camel@putnam.wgtn.cat-it.co.nz> On Fri, 2006-07-21 at 14:01 +1200, Grant McLean wrote: > if you break it down: > > use strict; > > is equivalent to: > > require strict; > strict::import(); Of course what I really meant (and what you were all too polite to point out) was ... use strict; is equivalent to: require strict; strict->import(); 'use' calls import() as a class method not as a function. Cheers Grant From LRW at clear.net.nz Wed Jul 26 23:15:41 2006 From: LRW at clear.net.nz (Lesley Walker) Date: Thu, 27 Jul 2006 18:15:41 +1200 Subject: [Wellington-pm] Complex data structure Message-ID: <1153980941.23601.90.camel@localhost.localdomain> Is there a quick and simple way to reveal the contents of a complex data structure? Context: I'm doing some things with LDAP, using a site-specific module which is essentially a wrapper for Net::LDAP. When I call the thingy that looks up an LDAP entry, I get back a hash that will contain something like this.... "cn=NeWS,ou=Services,dc=rhubarb,dc=co,dc=nz" => where looks something like objectClass => ipService, cn => NeWS, cn => news ipServicePort => 144 [etc] except it's more complex that, because as you can see, "cn" appears twice, and in fact any attribute can appear multiple times, and there's another level of hashing that I don't quite understand. So a simple "foreach ( keys %foo) { print }" doesn't produce the desired result. So, rather than spending all day reverse-engineering the structure of this thing, is there some function or module that will just tell me what's in it? Lesley W (the under-educated one) From ewen at naos.co.nz Wed Jul 26 23:22:05 2006 From: ewen at naos.co.nz (Ewen McNeill) Date: Thu, 27 Jul 2006 18:22:05 +1200 Subject: [Wellington-pm] Complex data structure In-Reply-To: Message from Lesley Walker of "Thu, 27 Jul 2006 18:15:41 +1200." <1153980941.23601.90.camel@localhost.localdomain> Message-ID: <20060727062205.2FB488694B2@wat.la.naos.co.nz> In message <1153980941.23601.90.camel at localhost.localdomain>, Lesley Walker writ es: >Is there a quick and simple way to reveal the contents of a complex data >structure? Something like: -=- cut here -=- use Data::Dumper; print Dumper(\$myref), Dumper(\%myhash); -=- cut here -=- is probably what you're looking for. It's an invaluable tool for figuring out what's going on in your data structures. Ewen From LRW at clear.net.nz Wed Jul 26 23:28:57 2006 From: LRW at clear.net.nz (Lesley Walker) Date: Thu, 27 Jul 2006 18:28:57 +1200 Subject: [Wellington-pm] Complex data structure In-Reply-To: <20060727062205.2FB488694B2@wat.la.naos.co.nz> References: <20060727062205.2FB488694B2@wat.la.naos.co.nz> Message-ID: <1153981737.23601.93.camel@localhost.localdomain> Thanks, that looks exactly like the sort of thing I'm after. Why don't the books mention it? (rhetorical question) On Thu, 2006-07-27 at 18:22 +1200, Ewen McNeill wrote: > Something like: > > -=- cut here -=- > use Data::Dumper; > print Dumper(\$myref), Dumper(\%myhash); > -=- cut here -=- > > is probably what you're looking for. It's an invaluable tool for > figuring out what's going on in your data structures.