In fact, in my own code, I never put a semicolon after return

Interesting, and thanks all for comments. I do try to work through the source posted, and this might be my final version of highest_number for this thread. I finally worked out what the glitch was in getting the next number after 9. Abridged output, then source:

$ ./2.cw1.pl ... object created, back with caller word is 2.cw dir2 is perlmonks 2.cw1.html 2.cw2.html ... 2.cw9.html 2.cw10.html 2.cw11.html ... matching is 2.cw9.html matching is 2.cw10.html matching is 2.cw11.html old num is 11 Make rus captions(y/n)?: n ... Put file to server(y/n)?: y server dir is perlmonks ... return is 2.cw12.html
sub highest_number { use 5.011; my ( $aref, $filetype, $word ) = @_; my $number; my @matching; my $ext = "." . $filetype; push( @matching, 0 ); #min returned value for my $file ( @{$aref} ) { #print "file is $file\n"; if ( $file =~ /^$word(\d+)$ext$/ ) { print "matching is $file\n"; push( @matching, $1 ); } } @matching = sort { $a <=> $b } @matching; my $winner = pop @matching; return $winner }

I hadn't been sorting numerically. The existence of this page shows that the code works: resulting page.

What's funny is that I presented with an algorithm I was embarrassed to show, but with the mere addition of { $a <=> $b } and falling back to not having a semi-colon after the return, then I think this is pretty good, lexical perl.


In reply to Re^5: create clone script for utf8 encoding by Aldebaran
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.