Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

New String Concatenation In Perl 6?

by Cody Pendant (Prior)
on Dec 03, 2002 at 19:58 UTC ( #217325=perlquestion: print w/replies, xml ) Need Help??

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

I was just reading about topics in Perl 6, very interesting article, at perl.com and it mentions string concatenation being done with "_=" instead of ".=" -- what's that all about?

And in a teach-a-man-to-fish sort of way, where can I read about changes I'd need to know about right away if I were to use Perl 6, not the more abstract topics. Could I still use ".=" for instance?
--

($_='jjjuuusssttt annootthheer pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;

Replies are listed 'Best First'.
Re: New String Concatenation In Perl 6?
by Elian (Parson) on Dec 03, 2002 at 20:21 UTC
    The dot's going to be the method call character, replacing the arrow, so it can't be string concatenation. Underscore's the leading candidate for string concat, though there's been some waffling about that lately.

    You will be able to use .= still, but it'll not do string concatenation--it's the shorthand for method call and assign. So this:

    $foo .= bar;
    is the same as:
    $foo = $foo.bar;

    At the moment there's not really a 5->6 translation document, but I expect there'll be one built before perl 6 comes out.

Re: New String Concatenation In Perl 6?
by djantzen (Priest) on Dec 04, 2002 at 02:34 UTC

    Reminds me of this little gem :^P

Re: New String Concatenation In Perl 6?
by Bukowski (Deacon) on Dec 03, 2002 at 20:12 UTC
    From exegisis 3:

    "It may help to think of it as the old dot operator under extreme acceleration"

    Works for me! ;)

    Bukowski - aka Dan (dcs@black.hole-in-the.net)
    "Coffee for the mind, Pizza for the body, Sushi for the soul" -Userfriendly

Re: New String Concatenation In Perl 6?
by robot_tourist (Hermit) on Dec 03, 2002 at 21:02 UTC

    I'm looking forward to Perl6 possibly more than the next man, but it won't be out for quite a while. Anyway for me the _ operator makes more visual sense and will make java/C++ to Perl migration easier. Having read some of the Exegesises and Apocalypses, it seems there will be a very groovy Perl5 to Perl6 translation program.

    How can you feel when you're made of steel? I am made of steel. I am the Robot Tourist. Robot Tourist, by Ten Benson

Re: New String Concatenation In Perl 6?
by theorbtwo (Prior) on Dec 04, 2002 at 05:07 UTC

    I think this is the current list. String concatination is no longer . or _, it's ~. This doesn't mess up the smart-match (=~ or is that ~=?) operator, which is now ~~... or at least, it doesn't mess with it much.


    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

      ~ is the unary operator to force string context.
      - is the binary operator to concatenate strings.

      -- stefp

        ~ is both the unary string context forcing operator and the concatenate operator; - is still subtraction.


        Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2022-05-21 08:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (76 votes). Check out past polls.

    Notices?