Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

As poj says. Heh... didn't know that there's a module for that. This is what I have in my toolbox

my %hash; my @chars = (0..9,'A'..'Z','a'..'z',map{chr$_}32..47,58..64,91..96 +); @hash{@chars} = 0..$#chars; sub encode_base { my ($base,$num) = @_; my ($rem,@ret); while ($num) { push @ret, $chars[($rem = $num % $base)]; $num -= $rem; $num /= $base; } return join '', reverse @ret; } sub decode_base { my ($base, $str) = @_; my $num; $num = $num * $base + $hash{$_} for $str =~ /./g; $num; }

which is basically the same, but lets you encode/decode with a base up to 91. So,

my $number = decode_base 36, 1009; say lc encode_base 36, $number++ for 0..36;

does what you want. Also, these subs can be used to convert from decimal to binary, octal, hex and reverse, using 2, 8 and 16 as base. But I'd use the perl builtins for that ;-)

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

In reply to Re: incrementing mixed letters and numbers by shmem
in thread incrementing mixed letters and numbers by Anonymous Monk

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    [Perl300]: Hi all
    [Perl300]: I need suggestion for a module that'll help me to send email from my perl code. I want it secure and as simple as possible.
    [Perl300]: I found from Super Search
    [Perl300]: I found from Super Search, Net::SMTPS or Net::SMTP, MIME::Lite, Email as options
    [1nickt]: Perl300 Try Email::Stuffer
    [1nickt]: Or for a little more control, Email::Sender:: Simple
    [Perl300]: any suggestion on which one might be secure and simplest. I am not doing anything complex, just check some conditions from DB tables and send email to myself (same domain) if conditions are met

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (10)
    As of 2017-10-17 15:51 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My fridge is mostly full of:

















      Results (233 votes). Check out past polls.

      Notices?