In all the code that you posted (both commented-out and uncommented), you populate @tapes_to_eject, but never *use* @tapes_to_eject. In your vmchange command, you use @_ directly (although obtusely).

You must either:

  1. Update @_ with a sorted copy of the tape list, or
  2. Use @tapes_to_eject instead of @_ in the vmchange command.

Here is how I would approach the problem:

#!perl use strict; use warnings; # Global vars: my $robot_num = 42; # Faked my $robot_host = 'localhost'; # Faked my $max_slots = 52; # Derived from original post. my $live_eject = 0; # for testing eject_tapes( qw( B4356R B0001R B1001R ) ); sub sort_tapes { my @tapes = @_; return sort { substr($a, 0, 1) cmp substr($b, 0, 1) or substr($a, 1, 4) <=> substr($b, 1, 4) or substr($a, 5, 1) cmp substr($b, 5, 1) } @tapes; } # This simpler version might be sufficient. #sub sort_tapes { return sort @_; } sub eject_tapes { warn "No tapes passed to eject_tapes()" and return if not @_; my @tapes_to_eject = sort_tapes(@_); while (@tapes_to_eject) { # splice() removes $max_slots tapes from # the front of @tapes_to_eject. my @batch_of_tapes = splice @tapes_to_eject, 0, $max_slots; my $tapes_joined_list = join ':', @batch_of_tapes; my @command = ( qw( /usr/openv/volmgr/bin/vmchange -res -multi_eject -w ), -rn => $robot_num, -rt => 'tld', -rh => $robot_host, -ml => $tapes_joined_list, ); if ($live_eject) { `@command`; } else { print "@command\n"; } # If any tapes remain for another batch of ejections, # then alert the operator and wait. if (@tapes_to_eject) { print <<"END_OF_MESSAGE"; The export door in robot $robot_num only holds $max_slots tape(s), and we have now ejected that many tapes. Please go and empty the import/export doors and press <RETURN> when you are finished. END_OF_MESSAGE <STDIN>; # Waits for <RETURN> } } }


In reply to Re: Alphnumeric Matching by Util
in thread 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.