Gossamer Forum
Home : General : Perl Programming :

stat() not working right?

Quote Reply
stat() not working right?
Hi,

I'm having a problem using the stat() function :/ I currently have;

Code:
my $bytes = (stat("d:/inetpub/wwwroot/mydomain.com/submit/docs/$startid/".$filename))[7] || 0;

.. which *shoul* be reading "d:/inetpub/wwwroot/mydomain.com/submit/docs/4/17th December 2004.doc", and passing back the size.

My debug info seems to be ok; (except the byte size)

Quote:
Getting stats for: d:/inetpub/wwwroot/mydomain.com/submit/docs/4/17th December 2004.doc
Bytes Grabbed: 0

Am I missing something really stupid? :/

TIA

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] stat() not working right? In reply to
I'd use File::stat -- it's more flexible across platforms.

Also, your filenames has spaces in it which is going to cause problems. Either get rid of the spaces or put quotation marks around the entire filename (and path) when you stat.

- wil
Quote Reply
Re: [Wil] stat() not working right? In reply to
LMAO.. now that was a simple fix!

my $bytes = (stat("d:/inetpub/wwwroot/mydomain.com/submit/docs/$startid/$filename"))[7] || 0;

Thanks for the pointer =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] stat() not working right? In reply to
Or use

my $size = -s $filename;

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] stat() not working right? In reply to
LOL.. I saw that in GT::SQL::File, but thought it must be for someonthing else (-s $file just looked too easy =)).

Thanks again.

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!