Search code examples
perlglob

Perl glob one liner


Im working in a perl one liner to invert the contents of my file contents or perform operations, I was able to generate the script and one liner, but this one liner only works by entering file by file.

perl -i -ne '$a=reverse $_;print "$a\n"' <filename>

I want to change my one liner to get input from a range of files but when i do:

perl -i -ne '$a=reverse $_;print "$a\n"' | ls -al

I just get screen output of ls -al Not sure how to proceed.

Thanks


Solution

  • You can use xargs(1):

    ls | xargs perl -i -ne '$a=reverse $_;print "$a\n"'