473,386 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Checking file size

hi,

please help as how i can do the following using perl.

there is a text file which contains the log details. once the textfile size crosses its maximum capacity, automatically it should create a next text file with the same name and starts using this new file.

Thanks,
banuruby
Oct 5 '06 #1
2 2993
hi,

please help as how i can do the following using perl.

there is a text file which contains the log details. once the textfile size crosses its maximum capacity, automatically it should create a next text file with the same name and starts using this new file.

Thanks,
banuruby
####################
hi,

use the stat function on the given file.
for example
@array = stat("file.txt");

this will return the various attributes of the file like read,write permission,file size in the @array

the 8 th element of the array is filesize.

then you can use the if-else loop to keep checking the file size and opening the next file for writting when the size exceeds the expected limit

let me know whether above solution solved your problem
Oct 5 '06 #2
miller
1,089 Expert 1GB
deep022in's solution will work, but a simpler bit of code would be to use the -s operator.

my $size = -s "file.txt";

The documentation is available here:
perldoc -f "-s"
Oct 16 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Deepak Sarda | last post by:
Hello everyone. I have run into something which I believe is a bug or a shortcoming of the threading.Thread module. My program spawns 15 threads. For this I've creating a new class with...
14
by: Marlene Stebbins | last post by:
At one point in my program I have about a dozen calls to malloc. I want to check for malloc failure, but I don't want to write: if((buffer_x = malloc(BUFSIZE * sizeof(*buffer_x))) == NULL) {...
21
by: jacob navia | last post by:
Many compilers check printf for errors, lcc-win32 too. But there are other functions that would be worth to check, specially memset. Memset is used mainly to clear a memory zone, receiving a...
1
by: gryffin | last post by:
im trying to do file extension checking but its not working :( i have the following in the head <script language="JavaScript"> extArray = new Array(".jpg", ".png", ".bmp"); function...
19
by: jeremyz | last post by:
Hi all, I am not a developer, but I work with several and am posting this for them. We are trying to determine whether it is possible to check the size of a file before a user uploads it. ...
1
by: brett | last post by:
If I participate in a forum that doesn't have any way to watch threads or any type of RSS, I could get the filesize of the thread I want to watch. When the filesize changes, I know there is a new...
4
by: Michael Yanowitz | last post by:
Hello: If I have a long string (such as a Python file). I search for a sub-string in that string and find it. Is there a way to determine if that found sub-string is inside single-quotes or...
2
sun1programmer
by: sun1programmer | last post by:
Hi All, I have an HTML File upload control and I want to check the size of uploaded file by the user at the time of uploading. If size exceeds 25MB, then it shows the confirmation message that...
11
by: Bryan Crouse | last post by:
I am looking a way to do error checking on a string at compile time, and if the string isn't the correct length have then have the compiler throw an error. I am working an embedded software that...
1
by: sruthini | last post by:
Hi, I am trying to checking the size of a file using javascript, I am using the following code <html> <head> <script language="JavaScript"> function A() { var oas = new...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.