in reply to Oddity...losing filename from stdin - very wierd

I think maybe the difference is using the diamond (<>) operator vs. globbing.

If you want to print out the contents of a file use the diamond operator.

% perl -e 'print while (<>);' yourfilenamehere

If you want to print out a list of files, use the glob operator and specify which file names to print. For example, print the names of all the perl files in the dir

% perl -e 'print while (<*.pl>);'

Rich36
There's more than one way to screw it up...

Replies are listed 'Best First'.
Re: Re: Oddity...losing filename from stdin - very wierd
by snafu (Chaplain) on Apr 09, 2002 at 16:56 UTC
    Right. You are getting into the other ways to do the task and if you are saying that there is no other way to do what we want then I suppose I can go with that but reluctantly. I definitely see something wrong here. What I am trying to do should be possible to do and it probably is but I am doing something wrong.

    Your first example is not what I trying to do. I am not trying to get the contents of the file but am actually trying to pipe the filename itself to the perl script. Again, note, that the reason we are doing it this way is for a more grand scheme so this is only pseudocode (if you will) but it is a good mimic of what we want to do in the end.

    Your second example, while a good thought, is still steering away from how we want to work the idea. You are using Perl to glob the files. What we want to do is simply send a single filename to perl via ls. :)

    _ _ _ _ _ _ _ _ _ _
    - Jim
    Insert clever comment here...