473,544 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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 2646

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

Similar topics

0
2035
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 the thread is over a month old, I decided to start a new one with my response. Please see my comments inline.
1
1504
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. Any help will be appreciated.
1
3995
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 use the C++ functions which don't seem to be working propperly. I need to open the file for reading and writing because I want to search for a...
2
2142
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 based on their own criteria.. it seems like a pretty straightforward project. I would like to embed links to the various objects in the database...
0
1077
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
6543
by: James Pang | last post by:
-- Tech Servant James Pang.
8
2476
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 problems resulting from IIS 6 prohibiting ASP and SSI etc, but I've hit a peculiar wall. One ASP page uses a VB6 COM object that basically reads from an...
25
2548
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 example: with quitCommandButton .enabled = true .default = true end with
12
1402
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 application... but my app's text area(textbox,where the text data is loaded into. ) is opened blank, nothing is displayed except a general view of my...
0
7437
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7373
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7625
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7389
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5306
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4930
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1848
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.