in reply to Split returning one element

print +(split /\./, 'www.google.com', 2)[0];

Replies are listed 'Best First'.
Re^2: Split returning one element
by Anonymous Monk on Nov 05, 2009 at 18:28 UTC
    Perfect, thank you! Any other neat places where this is helpful?
Re^2: Split returning one element
by Anonymous Monk on Nov 05, 2009 at 18:35 UTC
    Can you elaborate on what is going on with the + sign?
      thing (...) parses a function call, leaving out the + would mean the whole statement is parsed as
      ( print(split ...) )[0]

      Which is not what you want.

      Perl 6 - links to (nearly) everything that is Perl 6.
      print +(split /\./, 'www.google.com', 2)[0];
      is a weird way of writing
      print( (split /\./, 'www.google.com', 2)[0] );