473,395 Members | 1,456 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,395 software developers and data experts.

Problem using "open FILEPT, "zcat $filename|"" many times

1
Hi,
I'm new to this forum and to Perl language but I would like to ask for your help.
I'm working in Linux and the files I need to process are in the format “file.gz”.
I created a script which should decompress, open and then delete nearly 400 files. To do so I use "open FILEPT, "zcat $filename|"".
In the beginning the script works fine, but after about 300 files processed I get an error on Open function:

“proc: Could not open file /home/Logs/backup/file.1183204803”.

I changed my script so I could continuing processing but the solution I found is not acceptable. So at the moment , when I get the Open error message, if I open a new shell and do : “zcat file.1183204803.gz > file.1183204803” and then type GO in the shell running my perl script, my script will continue execution normally until it needs to zcat and open another file when it will behave exactly the same way.
If I keep doing that I will get the expected result, but is unacceptable do all this manual work for 100 files!!
Do anyone knows why this happens and how to correct it?
Any help would be appreciated.
Thanks in advanced.

Here's, what I think to be, the relevant part of my script:
(Note: Function trataErro is at the bottom since it is not very relevant. I submitted it anyway, in case you wish to look at it.)

Expand|Select|Wrap|Line Numbers
  1. use Cwd;
  2. my $path=cwd();
  3.  
  4. sub proc{
  5.     my ($file) = @_;
  6.  
  7.     # (...)
  8.  
  9.     $pathC = $path . "/$file";
  10.     open INPUT, "zcat $pathC|" or trataErro($cpath);
  11.         while($line = <INPUT> ){
  12.             eval($line);
  13.  
  14.             # (...)
  15.         }
  16.     close INPUT;
  17. }
  18.  
  19. sub init{
  20.  
  21.     (...) #Initializing @lista
  22.  
  23.     for my $fileName (@lista){
  24.         proc($fileName);
  25.     }
  26. }
  27.  
  28. init;
  29.  
  30. #------------------------------------------------------------------
  31. sub trataErro{
  32.     my ($path) = @_;
  33.     open(STDIN, "-"); #Opens standard INPUT
  34.     print "\n!!ATENTION:\n\ttrataFile: Could not open file $cpath\n";
  35.     print "Check the problem with the file and type GO to continue\n";
  36.     while($line = <STDIN>){
  37.  
  38.         if ($line =~ m/GO/){
  39.             open INPUT, "$cpath" or trataErro($path);
  40.             close STDIN;
  41.             last;
  42.         } else {
  43.             print "Check the problem with the file and type GO to continue\n";
  44.         }
  45.     }
  46. }
  47.  
Jul 23 '07 #1
0 2632

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

Similar topics

0
by: Andreas Suurkuusk | last post by:
Hi, I just noticed your post in the "C# memory problem: no end for our problem?" thread. In the post you implied that I do not how the garbage collector works and that I mislead people. Since...
1
by: Sameh Abdelatef | last post by:
Dear perl experts, I used to use to open and add new lines to $filename, but it didn't work any more. The perl version is 5.8.1. When I try it's work but the content of $filename is deletd....
1
by: Christopher Reeve | last post by:
Hi, I wonder if anyone could help me. I am moving accross from C to C++ and am writing a program that reads and writes data into a file. I am aware of the old C ways of doing it but am trying to...
2
by: ajames54 | last post by:
I have hundreds if not thousands of documents in various formats that I have been asked to organize in such a way as to make it easy for the people around here to search for them and to group them...
0
by: Bilo | last post by:
Hi, I only see the Icon of my app when i rightclick and select "open with" in explorer. How can I have the name of the app also seen?
4
by: James Pang | last post by:
-- Tech Servant James Pang.
8
by: Seth Darr | last post by:
I'm working on migrating an Classic ASP/VB6 COM application from an NT Server with IIS<6 to an virtual machine running Windows Server 2003 and IIS 6. I've worked through most of the obvious...
25
by: samjnaa | last post by:
Please check for sanity and approve for posting at python-dev. In Visual Basic there is the keyword "with" which allows an object- name to be declared as governing the following statements. For...
12
by: kimiraikkonen | last post by:
Hi, I have small project which opens text files via inside the project but i want to associate this app for every text file. To have a test, if i right click on a text file -then "open with" -my...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.