Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That sounds like one of those super useful features that's easy to shoot yourself in the foot with. Perl has a few of those (cribbed from AWK, I believe):

$, : The output field separator

  $ perl -E 'my @data = (11,22,33); say 11,22,33; say "@data"; say @data; $,="|"; say 11,22,33; say "@data"; say @data;'
  112233
  11 22 33
  112233
  11|22|33
  11 22 33
  11|22|33

 $" : Interpolated list separator

  $ perl -E 'my @data = (11,22,33); say 11,22,33; say "@data"; say @data; $"="|"; say 11,22,33; say "@data"; say @data;'
  112233
  11 22 33
  112233
  112233
  11|22|33
  112233
And a bunch more, including input line/record separators (so you can slurp a whole file into a buffer at once instead of line by line), etc.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: