Not sure if I get everything right, but here's the story. Usually, under use strict you are not allowed to use barewords like ARPFILE. A bareword is something perl "can't make sense of," thus it treats it as a quoted string 'ARPFILE' if there isn't any stricture. That's why you get the error.

Unusually, there are some internal functions, like your open example, where barewords are okay, even under use strict, because they are meant as handles. opendir, sysopen and a few others seem to fall into this category. That's why your last example open FIN,"</etc/passwd" or die $!; works fine, even if FIN is a bareword.

Your call to File::Remote::open $rp->open (ARPFILE,...) on the other hand is nothing but a plain method call, hence the error.

It wouldn't be Perl if there weren't a few ways to solve this. Here's how I would do it. I prefer lexicals, so I'd create an anonymous glob with gensym using Symbol. Then one can usually use $arpfile like any other handle. Note that the following is untested.

#!/usr/bin/perl use strict; use warnings; use File::Remote; use Symbol; my $rp = new File::Remote( rsh=>"/usr/bin/ssh", rcp=>'/usr/bin/scp'); my $arpfile = gensym; $rp->open ($arpfile,"xeng-mon01:/usr/local/router-walk/data/arp.csv") or die $!; my $line=<$arpfile>; print $line;

Let me know if this is working for you.


In reply to Re: File::Remote wierdness. (problems using strict?) by rblasch
in thread File::Remote wierdness. (problems using strict?) by blue_cowdawg

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.