On 11/27/07, lerameur <[EMAIL PROTECTED]> wrote: > works good now: > my $file_to_print = ( `ls -1c /test/*log | tail -1 `); > > print "file_to_print: $file_to_print";
Since you didn't chomp() it, and since you didn't need to add a newline when you printed it, it seems that $file_to_print still has a trailing newline character. That's normal for commands run with backticks, but it's not what shell programmers are used to. That's why, if $file_to_print is supposed to be a filename, I'd probably re-write that last line more like this: print "file_to_print: '$file_to_print'\n"; > open (FILE, "< /test/$file_to_print") or die "Could not open > file_to_print $: $!"; > > although the third line is not opening the file. It prints out good > but but I get an error while opening the file.. You probably didn't mean to use Perl's special $: variable in your error message. But why don't you tell us what the error message was? I'm guessing it was something like "file not found", since you don't have a file whose filename ends in a newline character. Hope this helps! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/