morissette has asked for the wisdom of the Perl Monks concerning the following question:

I assume I am doing something stupid here. But I just cant figure out what is going on. The first line from reading bash output is missing see here:

# Read in output my $content; while( my $line = <> ) { print $line; }
Then example:
root@dev [/projects/stdin]# head /var/log/messages | ./test Oct 7 01:30:02 dev modprobe: FATAL: Module ip_tables not found. Oct 7 02:00:01 dev last message repeated 3 times Oct 7 02:30:01 dev last message repeated 6 times Oct 7 03:00:01 dev last message repeated 3 times Oct 7 03:30:01 dev last message repeated 3 times Oct 7 04:00:02 dev last message repeated 3 times Oct 7 04:30:02 dev last message repeated 6 times Oct 7 05:00:01 dev last message repeated 3 times Oct 7 05:30:01 dev last message repeated 3 times

So yeah.... head by default shows 10 lines, however when piped I am only getting 9.

Update: oohhhhh nvm, i had a -n in the shebang, thanks!

Replies are listed 'Best First'.
Re: STDIN missing first line
by chacham (Prior) on Oct 14, 2012 at 00:41 UTC
    Excellent! Nevermind this reply either! :)