Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • i usually write that as

    perl -le 'print chr(65+rand(26))'

    your version is prettier, though :)

    (sorry, i'm not a java person)
    --
    bgp is for those who can't keep it static long enough
    • That can come across as slightly more documented if you say:

      perl -le 'print chr(ord('A')+rand(26))'

      Then you don't have the potentially mystifying 65. (I fess up; I always have to look up the value of 'A' on an ASCII chart whenever I want to do anything like this.)

      Some languages will basically treat 'A' as an int and allow you to drop the ord(). Not Perl. Might work for Java, though.

      --
      J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
      • Some languages will basically treat ‘A’ as an int and allow you to drop the ord(). Not Perl.

        perl -le'$a="A";$a++for 1..rand 26;print$a'