CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Testing filesize with -s

 



kencl
User

Jan 23, 2001, 2:43 AM

Post #1 of 3 (442 views)
Testing filesize with -s Can't Post

Is either of these the correct way to test the size of a file without actually opening it or reading it in?


Code
$LatestTable = "/fullpath/filename.extension"; 
if (-s $LatestTable > 51200) { # Max DB filesize of 50K

if (-s $LatestTable && $_ > 51200) { # Max DB filesize of 50K

What is the internal variable which holds the result of the -s test if it's not $_ (eg $[ or $* or something)?

Thank the Lord for a Beginner forum :)

>> If you can't control it, improve it, incorporate it or distribute it with PERL, it doesn't exist!


japhy
Enthusiast

Jan 23, 2001, 6:53 AM

Post #2 of 3 (436 views)
Re: Testing filesize with -s [In reply to] Can't Post

It's far faster to just test it on your own.


Code
print -s "path/to/some/file";

Jeff "japhy" Pinyan -- accomplished hacker, teacher, lecturer, and author


kencl
User

Jan 25, 2001, 2:13 AM

Post #3 of 3 (418 views)
Re: Testing filesize with -s [In reply to] Can't Post

For the benefit of others, the correct way was my first guess. IE

Code
if (-s $LatestTable < 51200) {  # LatestTable is smaller than 50K

>> If you can't control it, improve it, correlate it or disseminate it with PERL, it doesn't exist!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives