I am having trouble returing a variable from a sub?...below is my effort to
do this...is there some fundamental place where i am going wrong and can you
help me?!...thanks

[$  sub get_date $]
[-      
        $var = shift;
        $path = ("/home/genoccaj/public_html/lookup/");
        use File::stat;
        $inode = stat($path.$var) or die "Couldn't stat file : $!";
        $mtime = $inode->mtime;
        $size = $inode->size;   

        use Time::localtime;
        $tm = localtime($mtime);
        $year = $tm->year+1900;
        $month = $tm->mon;
        $mday = $tm->mday;
        @months =
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
        $mth = $months[$month];
        $date = ($mday."-".$mth."-".$year);
        return[$date];
-]
[+ $date +]<BR>
[+ $var +]<BR>
[$ endsub $]

[-
        use DirHandle;
        $path = ("/home/genoccaj/public_html/lookup/");
        %files = ();
        %filedates = ();

        opendir(TXT, $path);
        while (defined($file = readdir TXT )) {
                if ($file =~ /states/ && $file !~ /zip/ ) {
                        $filedates{states} = get_date($file)
                }
                if ($file =~ /nacs/ && $file !~ /zip/ ) {
                        $filedates{nacs} = get_date($file)
                }
        }               
        closedir(TXT);

-]
[+ $filedates{states} +]<BR>
[+ $filedates{nacs} +]<BR>

Reply via email to