Hello, I am trying to wrap my head around alphanumeric sorting and I have tried many of the things mentioned in past threads but I am still not having any luck. I want to eject tapes in order, they are labeled as such: B0001R B1001R B4356R etc. I have some code that I use to eject them now but they are not sorted and I want to sort them pre-eject so they come out in order. Below is the code:

$ejected_tapes=0 ; #my @tapes_to_eject=sort @_ ; #Below works fine but tapes are not sorted my @tapes_to_eject=@_ ; #my @tapes_to_eject=sort { substr($a, 1) <=> substr($b, 1)} @_ +; # Test #print "@_"; if ( $ejected_tapes == $maxslots ) { print "The export door in robot $robot_num only holds +$maxslots tape(s), \n"; print "and we have now ejected that many tapes. Please + go and empty the\n"; print "import/export doors and press <RETURN> when you +'re finished"; $ready=<STDIN>; $ejected_tapes=0; } `/usr/openv/volmgr/bin/vmchange -res -multi_eject -w - +rn $robot_num -rt tld -rh $robot_host -ml $\@_[0]:$\@_[1]:$\@_[2]:$\@ +_[3]:$\@_[4]:$\@_[5]:$\@_[6]:$\@_[7]:$\@_[8]:$\@_[9]:$\@_[10]:$\@_[11 +]:$\@_[12]:$\@_[13]:$\@_[14]:$\@_[15]:$\@_[16]:$\@_[17]:$\@_[18]:$\@_ +[19]:$\@_[20]:$\@_[21]:$\@_[22]:$\@_[23]:$\@_[24]:$\@_[25]:$\@_[26]:$ +\@_[27]:$\@_[28]:$\@_[29]:$\@_[30]:$\@_[31]:$\@_[32]:$\@_[33]:$\@_[34 +]:$\@_[35]:$\@_[36]:$\@_[37]:$\@_[38]:$\@_[39]:$\@_[40]:$\@_[41]:$\@_ +[42]:$\@_[43]:$\@_[44]:$\@_[45]:$\@_[46]:$\@_[47]:$\@_[48]:$\@_[49]:$ +\@_[50]:$\@_[51]` ; }

Thanks for looking and sorry if this is noob sauce.


In reply to Alphnumeric Matching by mrbbq

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.