You have good advice from others regarding the use of modules. I won't harp there.

Sometimes we write code because we don't know about modules; sometimes we write code because we have trouble using modules; sometimes we write code because we want to understand how something works. The questions arising from the do-it-yourself approach are, in my humble but arrogant opinion, still valid.

That said, to answer your specific questions, three things are needed:

  1. What is the input (in this case a DIRor similar would suffice);
  2. What is the output you received, and then merely highlight how that is different than what you expected, and;
  3. Working code.

Here's what I get when I run your code:

C:\Steve\Dev\PerlMonks\P-2013-10-17@1130-FileSize>testfsize.pl Global symbol "$directoryUNC" requires explicit package name at C:\Ste +ve\Dev\PerlMonks\P-2013-10-17@1130-FileSize\testfsize.pl line 9. Global symbol "$len" requires explicit package name at C:\Steve\Dev\Pe +rlMonks\P-2013-10-17@1130-FileSize\testfsize.pl line 10. Global symbol "$directoryUNC" requires explicit package name at C:\Ste +ve\Dev\PerlMonks\P-2013-10-17@1130-FileSize\testfsize.pl line 10. Global symbol "$directoryshort" requires explicit package name at C:\S +teve\Dev\PerlMonks\P-2013-10-17@1130-FileSize\testfsize.pl line 11. Global symbol "$directoryUNC" requires explicit package name at C:\Ste +ve\Dev\PerlMonks\P-2013-10-17@1130-FileSize\testfsize.pl line 11. Global symbol "$directoryshort" requires explicit package name at C:\S +teve\Dev\PerlMonks\P-2013-10-17@1130-FileSize\testfsize.pl line 12. Global symbol "$directoryshort" requires explicit package name at C:\S +teve\Dev\PerlMonks\P-2013-10-17@1130-FileSize\testfsize.pl line 13. Global symbol "$directoryshort" requires explicit package name at C:\S +teve\Dev\PerlMonks\P-2013-10-17@1130-FileSize\testfsize.pl line 13. Global symbol "$FolderName" requires explicit package name at C:\Steve +\Dev\PerlMonks\P-2013-10-17@1130-FileSize\testfsize.pl line 14. Global symbol "$FolderName" requires explicit package name at C:\Steve +\Dev\PerlMonks\P-2013-10-17@1130-FileSize\testfsize.pl line 15. Global symbol "$fileSize" requires explicit package name at C:\Steve\D +ev\PerlMonks\P-2013-10-17@1130-FileSize\testfsize.pl line 17. Global symbol "$fileSize" requires explicit package name at C:\Steve\D +ev\PerlMonks\P-2013-10-17@1130-FileSize\testfsize.pl line 18. Execution of C:\Steve\Dev\PerlMonks\P-2013-10-17@1130-FileSize\testfsi +ze.pl aborted due to compilation errors.

If your problem is you don't know how to fix these errors, then that should be the question you are asking.

Until these are fixed, there's no point in trying to see if maybe your code has a logic error -- it's not even storing the data correctly.

Let's get the code to a state where it runs without complaints from the perl compiler, and then we can pursue any remaining malfunctions.

Hint:

Every Perl script should have start like this (or variations on the theme):
#!/usr/bin/perl use strict; use warnings;

Get perl to quit barking at you first. Then ask the humans (or the Monks :-)) for help.


In reply to Re: size and exist doesnot work with UNC folders/dir by marinersk
in thread size and exist doesnot work with UNC folders/dir by mukes

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.