Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

email address as username

by nateh (Initiate)
on Oct 17, 2018 at 16:18 UTC ( #1224172=perlquestion: print w/replies, xml ) Need Help??

nateh has asked for the wisdom of the Perl Monks concerning the following question:

I'm having trouble with my perl script as the username in my script is an email address with the @ symbol and it is throwing an error. For instance:

$user = '';

I'm unable to change the username to be something other than an email and therefore remove the @ symbol. Is there a way to keep such a username and get it to work in perl? Thanks

Replies are listed 'Best First'.
Re: email address as username
by LanX (Sage) on Oct 17, 2018 at 16:23 UTC
    > it is throwing an error.

    which error?

    > $user = '';

    that's fine. You most likely did use double quotes instead

    $user = "";

    which will try to interpolate the array @somewhere.

    But this is just a guess since you didn't give us details

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice



      If I use single quotes, I get the error "Can't call method "login" on an undefined value at line x." Here's the relevant portion of the code:
      use Net::FTP; my ($ftp, $host, $user, $pass, $dir, $fpath); $host = ''; $user = ''; $pass = 'mypass'; $dir = '/my/file_path/onftp'; $fpath = ''; $ftp = Net::FTP->new($host, Debug => 0); $ftp->login($user, $pass) || die $ftp->message; ##this is line x## $ftp->cwd($dir); $ftp->put($fpath) || die $ftp->message; $ftp->quit;
        From the Net::FTP docs:
        $ftp = Net::FTP->new("", Debug => 0) or die "Cannot connect to $@";
        Check for errors as shown in the docs. What does that say?

        You are missing a semi-colon from the end of this line.

        use Net::FTP

        You are getting the error on your first use of the $ftp object.

        That means the construction of it in the line above failed, where you specified $ftp = Net::FTP->new($host, Debug => 0);

        I can't see from here why it failed, you will have to debug if you can reach $host using some other method to ftp for instance.

        Cheers, Sören

        Créateur des bugs mobiles - let loose once, run everywhere.
        (hooked on the Perl Programming language)

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1224172]
Approved by stevieb
Front-paged by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2022-05-19 03:25 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (71 votes). Check out past polls.