754 snippets from 1516 members, and growing!
|
login
|
join
about
bytebin
members
tags
snippets
join
Snippets
Submit a Snippet
Search Snippets
New Snippets
Top Snippets
Top Tags
PHP
(135)
JavaScript
(123)
Java
(65)
VBSCRIPT
(58)
String
(44)
CSS
(31)
CSharp
(28)
File
(28)
HTML
(27)
C
(24)
mysql
(24)
VB.NET
(24)
CPlusPlus
(23)
groovy
(23)
Random
(20)
New Snippets
Removing doubles ...
IE Explorer Proxy...
calculating md5 i...
tabless form usin...
find if array con...
Rapleaf Address B...
Javascript port o...
hash sha1
URL Regular Expre...
Email address val...
Venture Capital Jobs
New Members
Kelmi
ysg
dannymo2
chorny
wallie
Hackdemian
impomatic
cyberhitesh
omarabid
richard123
Top Members
dannyboy
sundaramkumar
mattrmiller
Pio
i_kenneth
ASmith
ctiggerf
bertheymans
SCoon
wiz1705
Home
/
Snippets
/
Get a FileSize
Get a FileSize
Snippet Menu
Revisions
Comments
Related Snippets
Add to Favorites
Email Snippet
Download Snippet
Print Snippet
Blog Snippet
snippet
|
revisions
|
comments
|
related
|
Add to Favorites
|
email
download
|
print
|
blog it
7
Mon. Nov. 14th, 2005 7:05 PM
1 of 1
ses5909
File
|
Perl
|
Size
1 comments
Get a FileSize
#to get the filesize, simply do the following:
$filesize
= -
s
(
"/home/www/yourpath/yourfile.txt"
)
;
Sara Smith
www.ilovecode.com
Sara
ilovecode
Comments
New Comment
Another Method
Mon. Oct. 16th, 2006 11:55 AM
snevine
Another method would be to dereference a stat call.
Or even a direct call to stat if you need more information on the file. (No reason to call it twice!)
# NOTE: Taken straight from perldoc
# dereference
my
$size
=
(
stat
(
$fileName
)
)
[
7
]
;
# direct
my
(
$dev
,
$ino
,
$mode
,
$nlink
,
$uid
,
$gid
,
$rdev
,
$size
,
$atime
,
$mtime
,
$ctime
,
$blksize
,
$blocks
)
=
stat
(
$filename
)
;
Reply
New Comment
Voting
Votes Up
ASmith
ctiggerf
dannyboy
i_kenneth
Pio
snevine
sundaramkumar
wiz1705
Votes Down
lolfejs
Or even a direct call to stat if you need more information on the file. (No reason to call it twice!)
# NOTE: Taken straight from perldoc
# dereference
my $size = (stat($fileName))[7];
# direct
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat($filename);