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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Error opening a file
by Anonymous Monk on Dec 03, 2010 at 07:59 UTC
    Well, that line will not produce that error. We've been through this before, you need to post complete/runnable programs. How (Not) To Ask A Question
    $ perl -MO=Deparse,-p -e " my $perl_file = <$dir/scripts/*.pl> use File::Glob (); (my $perl_file = glob(($dir . '/scripts/*.pl'))); -e syntax OK
      This is just a crazy guess , but maybe the variable is not what you expect.
      -X-

      It's a very big program,I am trying my best not to confuse you guys by asking short questions. I have a "Datascript.exe",am running that script and saving it in "$Datafile" variable,after saving $Datafile has 100's of lines but now I want to parse each line using a while loop(any loop for that matter) and am running into the errors mentioned.What is the best way I can parse eachline in $Datafile?Please suggest

      $Datafile =`Datascript -p=$perl_file`; open $file, '<', $Datafile or die "could not open '$file' $!"; while ( my $match = <$file> ) { }
        A reply falls below the community's threshold of quality. You may see it by logging in.

        Run this:

        use strict; use warnings; my $perl_file = WHATEVER_VALUE_THIS_IS_SUPPOSED_TO_BE; my $Datafile = `Datascript -p=$perl_file`; print "Datafile = $Datafile\n";

        Is $Datafile what you expect? That is, is it the name of the file you expect to open?

        EDIT: Added $perl_file = line.

Re: Error opening a file
by cdarke (Prior) on Dec 03, 2010 at 08:38 UTC
    Like others I cannot reproduce that error message with that line of code. You can get that error message from an open statement however. Most likely you have read all or part of a filename ($dir?) from a file or <STDIN> and forgotten to remove the trailing "\n" using chomp.
Re: Error opening a file
by perl_lover (Chaplain) on Dec 03, 2010 at 08:16 UTC
    You have to give the complete program or subroutine to get proper response. This error message doesn't look like coming from the statement what you have given.
Re: Error opening a file
by locked_user sundialsvc4 (Abbot) on Dec 03, 2010 at 13:53 UTC

    Please approach PerlMonks in this way ...

    1. Do your “due diligence” research first.   Do a search to see if what you’re asking has been asked before ... it most certainly has.
    2. Be sure that you are actually posting a question that can be answered ... and that can be completely understood quickly by someone who knows the answer.
    3. It is of course very frustrating to whack your head against a problem... but maybe the first thing that you need to do, is to get away from the terminal computer for a little while you give yourself time to think, perchance to sleep.   If you decide that you truly are up against a problem where you do not know how to proceed, spend a little time “framing” your question.   Sometimes this very act suggests an answer, or at least a strategy for finding it.
    4. From the place from whence you take, also give back.