in reply to Concatenation connected to find pipe behaves wierdly.

find is giving you a list of filenames terminated by newlines. So when you print qq($_), you're printing out a newline after your filename. So all your foo are belong to us... dammit... all of your foo end up just after a newline, aka the beginning of the next line.

The quick fix isfind | perl -lne "print qq($_) . q(foo)"

That will strip off the newline when reading each line in, and append a newline to the output of print.

Replies are listed 'Best First'.
Re^2: Concatenation connected to find pipe behaves wierdly.
by blazar (Canon) on Feb 01, 2006 at 10:47 UTC

    And while we're there we may also remind him not to unnecessarily quote all variables:

    perl -lne "print $_ . 'foo'"

    Alternatives:

    • interpolation, but not on a single variable: qq(${_}foo) - ugly, but qq($_foo) wouldn't work;
    • introducing -p:
      perl -lpe "$_.='foo'"
    • ...