Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1099891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:48:07+00:00 2026-05-17T00:48:07+00:00

While learning Perl I am also learning Linux (Ubuntu), so it is kinda fire-hose

  • 0

While learning Perl I am also learning Linux (Ubuntu), so it is kinda fire-hose sipping time around here.

What is the difference between:

find . -type f | perl -nle '... #aka yada yada'

and

perl -nle '... # same yada yada' `find . -type f`

The first passes the file NAMES to Perl and the second passes the file CONTENTS it seems. Is this always true under Unix or a special property of Perl?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:48:08+00:00Added an answer on May 17, 2026 at 12:48 am

    The first one generates the list of files and “pipes” it to perl. perl then reads the list by reading from standard input:

     while( <> ) { ... }
    

    This is a common thing to do in unix shells, so you don’t have to use perl at all:

     $ ifconfig | grep en0
    

    The second one generates the list of file names and turns them into command-line arguments, which then show up in your program in @ARGV:

     foreach( @ARGV ) { ... }
    

    This is a feature is not particular to Perl either. The shell provides the bits after the command in some sort of data structure that the program can access. Other languages have similar constructs even if they don’t look the same.

    However, the diamond operator, <> will automatically go through the filenames you specify on the command line, so that while loop still works. This is a feature particular to Perl.

    The problem with the second approach tends to show up when you have a long list of arguments. Some shells limit the number of things that can show up on the command line. I don’t like the second version as much just for that reason.

    However, instead of using find(1) (the shell version), you can turn it into a self-contained Perl program:

    $ find2perl . -type f
    

    The output is a Perl program that doesn’t have to rely on any external commands.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I found some similarities between arrays and set notation while learning about sets
While learning .net (by c#) i found 5 ways for checking equality between objects.
While learning Scalaz 6 , I'm trying to write type-safe readers returning validations. Here
While reading Learning Perl , I came across a problem about regular expressions. In
while learning android fragments on developer.android.com it is specified that direct communication between two
While learning Rails, I found this example in the Sam Ruby's book: app/controllers/line_items_controller.rb def
While learning an example from learn-you-a-haskell which right triangle that has integers for all
I am developing a small app while learning Android. The app is basically making
i just got some more questions while learning PHP, does php implement any built
MOV is probably the first instruction everyone learns while learning ASM. Just now I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.