Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Disable Interpolation while assigning a value to a variable

by Anonymous Monk
on Jun 26, 2024 at 13:08 UTC ( [id://11160218]=note: print w/replies, xml ) Need Help??


in reply to Disable Interpolation while assigning a value to a variable

I believe the OP is asking about the split(), which needs to be coded my ( $u, $d ) = split /\@/, $email;

Replies are listed 'Best First'.
Re^2: Disable Interpolation while assigning a value to a variable
by pryrt (Abbot) on Jun 26, 2024 at 13:20 UTC
    That backslash is not required.

    #!perl use strict; use warnings; my $email = 'peter@gmail.com'; my ($u,$d) = split (/@/,$email); print "$email => $u,$d\n";

    outputs:

    peter@gmail.com => peter,gmail.com

    In other words, if $email properly contains the email address, the split command that the original poster showed works as they wanted it to -- without your unneeded backslash (though your backslash doesn't change the results, in this case). Hence, the earlier monks were properly digging into the actual contents of $email to try to debug the problem.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11160218]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-09-09 23:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.