On Tuesday 16 Mar 2010 23:31:23 Harry Putnam wrote: > I've finally gone on around the bend, I guess... I'm not seeing why the > script below <./t2> doesn't show the value of $mode when fed by > the ls cmd shown: > > (first, to shows whats here) > > ls -l *[eo2] > -rw-r--r--+ 1 reader reader 5 Mar 16 15:26 one > -rwxr-xr-x+ 1 reader reader 141 Mar 16 16:19 t2 > -rw-r--r--+ 1 reader reader 5 Mar 16 15:26 three > -rw-r--r--+ 1 reader reader 5 Mar 16 15:26 two > > > ls *[eo2] | ./t2 > reader > ls *[eo2] | ./t2 > > (wrapped for mail) > > ,---- > > | Use of uninitialized value $mode in concatenation (.) or > | string at ./t2 line 9, <> line 1. one: > | > | [...] snipped same output for each file. > > `---- > > Script content > cat t2 > #!/usr//bin/perl > use strict; > use warnings; > my $mode; > while(<>){ > chomp; > $mode = (lstat( $_))[2]; > print "$_: " . $mode . "\n"; > }
This script: <<<< #!/usr//bin/perl use strict; use warnings; my $mode; while(<>){ chomp; $mode = (lstat( $_))[2]; print "$_: " . $mode . "\n"; } >>>> Works for me: <<< shlomi:~/progs/perl/snippets$ ls | perl ~/lstat.pl | head a-b: 16877 a-b-regex.t: 33188 analyse.pl: 33188 apps-as-modules: 16877 attributes: 16877 Closure-as-Method: 16877 color-patterns.pl: 33188 config-general-1.t: 33188 DBIx-Class-Hebrew: 16877 delegate: 16877 >>> Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Funny Anti-Terrorism Story - http://shlom.in/enemy Deletionists delete Wikipedia articles that they consider lame. Chuck Norris deletes deletionists whom he considers lame. Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/