Professional Web Applications Themes

[The Subroutine] What is "Use of uninitialized JOIN" error? - PERL Beginners

I used ---print OUTFILE join(",",record), "\n";--- that you suggested and still got the error. sub data_collect {unless (open(OUTFILE,">$fourdayreport")) {die open(ERRORLOG, ">>$errorlog") && print ERRORLOG "Sorry file $dayreport couldn't be created\n"; return "Failed";} else{ while( record= $sth->fetchrow_array()) { print OUTFILE join(",",record), "\n"; OUTFILE "$recordlist\n } return "success"; } } gov wrote: sub data_collect {unless (open(OUTFILE,">$fourdayreport")) {die open(ERRORLOG, ">>$errorlog") && print ERRORLOG "Sorry file $dayreport couldn't be created\n"; return "Failed";} else{ while( record = $sth->fetchrow_array() ) { # no warnings; #::::::::::::INSERTED ::::::: #Since you are not doing anything with $recordlist, I will do one of the following: print OUTFILE join(",",record), "\n"; #OR: ...

  1. #1

    Default Re: [The Subroutine] What is "Use of uninitialized JOIN" error?

    I used ---print OUTFILE join(",",record), "\n";--- that you suggested and still got the error.


    sub data_collect {unless (open(OUTFILE,">$fourdayreport"))

    {die open(ERRORLOG, ">>$errorlog") &&


    print ERRORLOG "Sorry file $dayreport couldn't be created\n"; return "Failed";}


    else{
    while( record= $sth->fetchrow_array())

    {
    print OUTFILE join(",",record), "\n";

    OUTFILE "$recordlist\n }

    return "success"; }


    }



    gov wrote:




    sub data_collect {unless (open(OUTFILE,">$fourdayreport"))

    {die open(ERRORLOG, ">>$errorlog") &&

    print ERRORLOG "Sorry file $dayreport couldn't be created\n"; return
    "Failed";}

    else{

    while( record = $sth->fetchrow_array() )
    {
    # no warnings;

    #::::::::::::INSERTED :::::::
    #Since you are not doing anything with $recordlist, I will do one of the
    following:
    print OUTFILE join(",",record), "\n";

    #OR:
    for ( my $i = 0; $i < $#record; $i++) {
    ( $i < $#record ) ? print "$record[$i]," : print "$record[$i]\n";
    }

    #::::::::::::::::::INSTEAD OF :::::::::::::
    my $recordlist=join(",",record);

    print OUTFILE "$recordlist\n";

    }return "success";

    }
    }

    __________________

    William Ampeh (x3939)
    Federal Reserve Board


    --
    To unsubscribe, e-mail: org
    For additional commands, e-mail: org




    Jason Guest

  2. #2

    Default Re: [The Subroutine] What is "Use of uninitialized JOIN" error?





    sub data_collect {unless (open(OUTFILE,">$fourdayreport"))

    {die open(ERRORLOG, ">>$errorlog") &&

    print ERRORLOG "Sorry file $dayreport couldn't be created\n"; return
    "Failed";}

    else{

    while( record = $sth->fetchrow_array() )
    {
    # no warnings;

    #::::::::::::INSERTED :::::::
    #Since you are not doing anything with $recordlist, I will do one of the
    following:
    print OUTFILE join(",",record), "\n";

    #OR:
    for ( my $i = 0; $i < $#record; $i++) {
    ( $i < $#record ) ? print "$record[$i]," : print "$record[$i]\n";
    }

    #::::::::::::::::::INSTEAD OF :::::::::::::
    my $recordlist=join(",",record);

    print OUTFILE "$recordlist\n";

    }return "success";

    }
    }

    __________________

    William Ampeh (x3939)
    Federal Reserve Board

    William Guest

  3. #3

    Default Re: [The Subroutine] What is "Use of uninitialized JOIN" error?





    What about manually stepping through the array elements?

    That is:

    for ( my $i = 0; $i < $#record; $i++) {
    print "$record[$i],";
    }
    print "$record[$#record]\n";



    __________________

    William Ampeh (x3939)
    Federal Reserve Board

    William Guest

  4. #4

    Default Re: [The Subroutine] What is "Use of uninitialized JOIN" error?






    What about manually stepping through the array elements?

    That is:

    for ( my $i = 0; $i < $#record; $i++) {
    print "$record[$i],";
    }
    print "$record[$#record]\n";


    __________________

    William Ampeh (x3939)
    Federal Reserve Board

    William Guest

  5. #5

    Default Re: [The Subroutine...revisited] What is "Use of uninitialized JOIN" error?

    Here is what I am doing. I shortend the sub, using local variables, and simplifying the whole thing to just print to screen. I use your loop once I collect the records into the record variable and join them with ","...

    Still to no avail, that menacing warning stays.

    Thanks.


    my $sql=qq( select * from bill where rownum <100
    );

    my $sth=$dbh->prepare($sql);

    $sth->execute();

    my $recordlist;
    my $dayreport = "/cygdrive/c/cygwin/my_Perl/basic_script/testfile.txt";

    my record;



    while( record= $sth->fetchrow_array())

    {


    $recordlist=join(",",record); #This statement is causing the problem

    for ( my $i = 0; $i < $#record; $i++)
    {
    print "$record[$i],";
    }

    print "$record[$#record]\n";



    } exit;

    $dbh->disconnect;

    gov wrote:





    What about manually stepping through the array elements?

    That is:

    for ( my $i = 0; $i < $#record; $i++) {
    print "$record[$i],";
    }
    print "$record[$#record]\n";


    __________________

    William Ampeh (x3939)
    Federal Reserve Board


    Jason Guest

  6. #6

    Default Re: [The Subroutine] What is "Use of uninitialized JOIN" error?

    Use of uninitialized value in concatenation (.) or string at select_c.pl line 70
    and error
    Use of uninitialized value in join or string at select_c.pl line 65.

    are whats showing up
    gov wrote:




    What about manually stepping through the array elements?

    That is:

    for ( my $i = 0; $i < $#record; $i++) {
    print "$record[$i],";
    }
    print "$record[$#record]\n";



    __________________

    William Ampeh (x3939)
    Federal Reserve Board


    Jason Guest

Similar Threads

  1. Replies: 2
    Last Post: October 4th, 09:47 PM
  2. What is "Use of uninitialized JOIN" error?
    By Jason in forum PERL Beginners
    Replies: 4
    Last Post: July 13th, 06:00 PM
  3. Replies: 2
    Last Post: February 19th, 11:17 AM
  4. "Undefined subroutine" error (but it's defined, I think?)
    By valerian2@hotpop.com in forum PERL Miscellaneous
    Replies: 5
    Last Post: August 12th, 10:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139