in reply to Symbolic reference problem

for (</home/www/*/logs/weekly>);

You are trying to read from a file name. You cannot do this in Perl. You have to read from a filehandle. To create a filehandle you need tp open the file:

open( LOG, "</home/www/logs/weekly>") or die "cannot open the log: $!"; while( <LOG>) { ...

Of course this will not work in your case as you are trying to read from several files using /home/www/*/logs/weekly. So the best way if for you to call the script using process /home/www/*/logs/weekly and to just read fron STDIN:

while( <>) # reads from STDIN { ...

Replies are listed 'Best First'.
Re: Re: Symbolic reference problem
by Hofmator (Curate) on Aug 20, 2001 at 14:57 UTC
    • You are trying to read from a file name.
      No, I don't think so. This looks to me like the file globbing operator (same as glob). And this should work - once the syntax error after for is fixed. So rewriting a little bit:
      # added braces and changed variable name for my $filename (</home/www/*/logs/weekly>) { substr($filename,-7)=" "; print $filename; }

    • while(<>) # reads from STDIN
      and again no, this reads from the magic filehandle ARGV - which results in a read from STDIN when @ARGV is empty, otherwise it interprets the arguments in @ARGV as filenames and reads from them.
      while (<STDIN>) { # this reads from STDIN ... }
      and you are right that <> is the best solution if you are trying to read from multiple files

    -- Hofmator

      My goodness, you are right!

      I completely forgot about the file glob operator, which I rarely use, and I completely missed the goal of the code. I thought that the goal was to read from all the files, not just to get the file names.

      Apologies! Maybe I should go back to doing some XML stuff...