Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

File Operation Functions not working in perl???

Discussion in 'General Discussion' started by CamronFry, Jan 14, 2005.

  1. CamronFry

    CamronFry BANNED

    Joined:
    Jan 1, 2005
    Messages:
    49
    Likes Received:
    0
    Trophy Points:
    156
    Why wont file operations work? Ex.
    open(DATA, "$datafile");
    @record = <DATA>;
    close(DATA);
    foreach(@record){
    print "$_\n\n";
    }

    jailshell-2.05b$ perl -w readdata.cgi
    Use of uninitialized value in string at readdata.cgi line 13.
    Content-type: text/html

    HEADER

    readline() on closed filehandle DATA at readdata.cgi line 19.
    FOOTER


    Why isnt the open function working?
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,460
    Likes Received:
    21
    Trophy Points:
    463
    Location:
    Go on, have a guess
    Without seeing the script, it's impossible to say and the snippet shown is terribly programmed to not show the problem.

    I would point out the very sloppy programming, which if cleaned up might show where you are going wrong with the code:

    open (DATA, "<$datafile") or die "Unable to open $datafile - $!";
    @record = <DATA>;
    close (DATA) or die "Unable to close $datafile - $!";
    chomp @record;
    foreach (@record) {print "$_\n\n"}

    As I said, though, without the script it's impossible to say.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice