Hi guys, I need your help. I have a line in my code, listed below, that gave me Possible unintended interpolation, my @servers array has a list of servers and to use ssh-copy-id I need pass user@hostname in my function I am using ("ssh-copy-id $user\@@servers"). Is it correct this? Thanks

open SERVERS, "./test_server" or die $!; while (my $line=<SERVERS>) { my @regex = ($line =~ /(\d+\.\d+\.\d+\.\d+|[a-z0-9\-]+)(?:\ +.[a-z\.]+)?/g); foreach (@regex){ push(@servers, $_); &test; &copyrsa($scp, $user, $pass, @servers); } } sub copyrsa() { my $scp_exp = new Expect; # Run the copy command. $scp_exp->spawn("ssh-copy-id $user\@@servers") or die "Cannot spawn + ssh-copy-id: $!\n"; $scp_exp->log_file("./autossh-copy-id.log"); $scp_exp->expect(5, [qr/\(yes\/no\)\?\s*$/ => sub { $scp_exp->send(" +yes\n"); exp_continue } ], [qr/assword:\s*$/ => sub { $scp_exp->send("$pass\ +n"); exp_continue; } ], );

In reply to Possible unintended interpolation by edualfaia

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.