Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
He's going to fight to the last against doing something 'childish', even though I assure him that when I'm coding professionally I'm doing little test scripts more than I'm working on the 'real' program.

Right on, jepri! I just had a quick scan on 4 different accounts here at work, that reveals some 400+ little test scripts. On each machine I have a ~/perl directory where I try out snippets to check how things work. For instance, the other day I had hesitations about how splice works, because I use it so rarely. So I whipped up "muncharr" which looks like:

#! /usr/bin/perl -w use strict; my @arr = ('a'..'z'); my $nr = shift || 6; local $, = ' '; while( scalar @arr ) { my @block = splice( @arr, 0, $nr ); print "@block\n"; }

With that, I was able to see straight away that my understanding of how splice worked was in line with reality. It took me about 2 minutes for take the time out to perldoc -f splice and test this out. I was then able to fold the principle back into my main code and safe in the knowledge that at least that part of the code was likely to be bug-free :)

And I suppose it is useful to stress that even little snippets are deserving of strict and -w. Also note how I wrote the script to use default value(s) that can be overriden from the command line.

print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'

In reply to Re: Adult learning problem by grinder
in thread Adult learning problem by jepri

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2022-01-21 23:43 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (59 votes). Check out past polls.