in reply to Re: return from external subroutine
in thread return from external subroutine

my bad. The code is below with the proper markings. Again, the problem seems to be with the return of Parse.pm. All Parse.pm does it take the file, go thru it, and put parts in a mysql db. This does work. Let me know if I should post more. Thanks again. Tried -w and strict - no help!

Main file:

use Parse; # my custom Parse.pm in /etc/perl/ <use Moving; # my custom Moving.pm in /etc/perl ..... foreach $file (@filelist) { Parse::parse_file($file); Moving::move_file($file); ... }

Parse.pm
package Parse; sub parse_file { $file = $_[0]; # put data in database, etc. this all works file } return 1;
Moving.pm
package Moving; sub move_file { $oldfile = $_[0]; # move a file, rename it, etc } return 1;

Replies are listed 'Best First'.
Re^3: return from external subroutine
by starX (Chaplain) on Aug 23, 2007 at 16:16 UTC
    You're really going to want to reformat the code in your original post to look like that. Also, where is the file list coming from? You've left the juicy bits of your code out of these snippits, and I'm afraid that I'm just not good enough to be able to make an intelligent guess without seeing what you're doing.

    If you are really confident that your internals are working just fine and can't post them here, might I suggest you look into using the debugger?

Re^3: return from external subroutine
by CountZero (Bishop) on Aug 23, 2007 at 20:33 UTC
    At the very least I should put return 1 within the subroutine declaration. It has no place or use here outside of the {...}

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      It's the end-of-package true value, so that use and require succeed.

        I understood that much but you don't need a return for it and I was just wondering if by adding the return you mess up some internal stacks or pointers and thereby have the main program fail mysteriously.

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James