in reply to Re: reading files from a directory
in thread reading files from a directory

I got it thanks! This will help with something called Indivo. http://wiki.chip.org/indivo/index.php/Schemas
while (defined($_ = glob(' IN '))) { print "Hello $_"; } while (<IN>){ print "Bye " . $_ ; }
I need to read about glob because I don't understand that line. Which print statement has better style? Should I use the . (join) in a print? Thanks, Kevin

Replies are listed 'Best First'.
Re^3: reading files from a directory
by kcott (Archbishop) on Oct 28, 2010 at 06:34 UTC

    There's no need to concatenate arguments to print as that function takes a list. In fact, you're actually requesting additional processing: do the concatenation and then do the print. Even worse, if you concatenate multiple arguments you're performing multiple operations; in sort of pseudocode: print A.B.C.D performs A.B, then AB.C, then ABC.D, then print ABCD, while print A,B,C,D is one operation.

    As far as style is concerned, I'd say do whatever is easiest to read and maintain. print "X ", $_, "\n"; and print "X $_\n"; are equally valid but, as mentioned above, avoid print "X " . $_ . "\n";.

    I note there's a few places where you haven't included a newline (\n) at the end of your print statement. In case you didn't know, print doesn't automatically add one for you; say, on the other hand, does.

    -- Ken