G'day Aldebaran,

"All of my scripts have a taxonomy of a positive integer followed by a period, followed by a word."

I'd probably aim for something like this in Perl:

$ perl -E 'my $x = "2.X"; my ($y, $z) = ($x =~ /^(\d+)(.*)$/); say $x; + say ++$y . $z' 2.X 3.X

This allows leading zeros in your filenames to be retained when incremented:

$ perl -E 'my $x = "02.X"; my ($y, $z) = ($x =~ /^(\d+)(.*)$/); say $x +; say ++$y . $z' 02.X 03.X

Which you may want to consider for a future filename convention to facilitate sorting. Compare these:

$ perl -E 'say for sort qw{1.X 9.X}' 1.X 9.X $ perl -E 'say for sort qw{1.X 9.X 10.X}' 1.X 10.X 9.X $ perl -E 'say for sort qw{01.X 09.X 10.X}' 01.X 09.X 10.X
"I'd like to write a perl equivalent that would give me freedom to choose the underlying encoding."

There's a variety of ways to do this. You don't say how the encoding is chosen: the following is just general information. See the open pragma and the open function; both contain links to additional information. See any perluni* links in http://perldoc.perl.org/perl.html.

"Does ascii have a representation for Ü?"

I see that AM has answered this. In Unicode, that character is:

U+00DC LATIN CAPITAL LETTER U WITH DIAERESIS

You might want to look at the Unicode Code Charts. That particular character is in (PDF link) "C1 Controls and Latin-1 Supplement". You may find it useful to familiarise yourself with the blocks of characters you deal with most often, perhaps even download a copy for quick reference; alternatively, if this is something you'll only want occasionally, individual internet searches will find the same information (searching for just "Unicode Ü" worked for me).

"I'd show previous attempts, but they look awful."

Showing what you've tried, even unsuccessful attempts, will often help us to better help you. We can see where your thought process (via code logic) was heading and perhaps steer you on a better course. A few minor tweaks may turn "awful" into "awesome". It can also help future readers who might be trying similar things.

— Ken


In reply to Re: create clone script for utf8 encoding by kcott
in thread create clone script for utf8 encoding by Aldebaran

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, details, 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, summary, 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.