Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Comment on

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

I have a subroutine defined

sub sadk_flap_mx_ifd_laser { my $r = shift; my $sub = sub_name; return $r->error_handler('S', "$sub: MX-VC does not support laser +off/on") if (exists $r->{MX_VC_CHASSIS} && $r->{MX_VC_CHASSIS}); my $args = get_args(["FLAP", "IFD"],@_); return $r->error_handler('S',"$sub: FAIL. Missing mandatory argume +nt 'IFD' in API call") unless (defined $args->{IFD}); $args->{IFD} = [$args->{IFD}] unless (ref $args->{IFD} ne "ARRAY") +; return $r->error_handler('S', "$sub: Empty list in argument 'IFD'" +) if (@{$args->{IFD}} == 0); $args->{FLAP} = 1 unless (defined $args->{FLAP}); my ($i,$ifd, $fpc); foreach $ifd (@{$args->{IFD}}) { ($fpc) = $ifd =~ /\w+-(\d+)\/\d+\/\d+/; $r->mode_shell; put_log("\n\n"); $r->put_log("Turn off/on laser on interface $ifd $args->{FLAP} + times"); foreach $i (1..$args->{FLAP}) { $r->shell(cmd => "cprod -A fpc$fpc -c \"test ifdev $ifd la +ser off\""); sleep 20; $r->shell(cmd => "cprod -A fpc$fpc -c \"test ifdev $ifd la +ser on\""); sleep 20; } } put_log("\n\n"); $r->mode_cli; return 1; }

I am trying to call this subroutine from a different file

$t->sadk_flap_mx_ifd_laser(ifd=>@child_interfaces, flap=>$flaps);

While executing the code, I see there are errors. I doubt am not passing the correct value . @childinterfaces have the valures, et-14/1/1, et-5/1/ that till 10 interfaces.

Sep 13 06:27:05 ERROR JT::get_args: Argument "ET-5/1/0" is invalid JT::error_handler HARD at /volume/labtools/lib/ line 2739. JT::get_args('ARRAY(0x11ce6c00)', 'ifd', 'et-14/1/1', 'et-5/1/0', 'et-1/0/0', 'flap', 10) called at /volume/labtools/lib/Testsuites/PDT/lib/ line 1032 Testsuites::PDT::lib::SADK::sadk_flap_mx_ifd_laser('JT::Test=HASH(0xdde63d0)', 'ifd', 'et-14/1/1', 'et-5/1/0', 'et-1/0/0', 'flap', 10) called at line 267 UC705_FT_testcases::ae_child_link_flap_remote_lasers called at (eval 704) line 1

canu help here

In reply to Passing array to a subroutine by Anonymous Monk

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?

    What's my password?
    Create A New User
    and the daffodils sway...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (4)
    As of 2018-06-18 02:48 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (107 votes). Check out past polls.