04-22-2014
Instead of print ZERO statement, put the last two lines of your code there and dont forget to close the file.
PS: Use code tags.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi I need help below is my textfile format look like
PO Nbr Ln Item Number Description Qty Order Order Date Due Date Status Reply ID Reply Date Reply Qty
P304802 1 K0220040 TSX-3225 C 16.367900 MHz 320379 07/01/2008 29/01/2008 REQ OP304802 02/02/2008 190000
P304802 2 K0220040 TSX-3225 C... (0 Replies)
Discussion started by: thila
0 Replies
2. Shell Programming and Scripting
help me pls.. :(
i want to read a mapping file.
Below is the content of my mapping file.
6221,189,SMSC1,OMC1,WAP1
6223,188,SMSC2,OMC2,WAP2
so when my program running
msisdn="622130302310"
while not EOF
if substring($msisdn,1,4) == "6221" -- > "6221" read from the file
then
echo... (0 Replies)
Discussion started by: voidmain
0 Replies
3. Shell Programming and Scripting
Hello ,
I have huge file with below content. I need to read the numeric values with in the paranthesis after = sign. Please help me with awk and sed script for it.
11.10.2009 04:02:47 Customer login not found: identifier=(0748502889) prefix=(TEL) serviceCode=().
11.10.2009 04:03:12... (13 Replies)
Discussion started by: rmv
13 Replies
4. Shell Programming and Scripting
i have one file
abhi.txt
its contents are
home8/mc09ats/UnixCw/backup/file1
home8/mc09ats/file2
i want to read this content of file using while loop..
in this i want to seperate the content as follows
path=home8/mc09ats/UnixCw/backup
file=file1
echo path
echo file
can you... (1 Reply)
Discussion started by: AbhijitIT
1 Replies
5. Shell Programming and Scripting
Hi -
I have a file containing data like :-
cn=tommy,cn=users,c=uk
passwordexpirydate=20100530130623z
cn=jane,cn=users,c=uk
passwordexpirydate=20100423140734z
cn=michael,cn=users,c=uk
passwordexpirydate=20100331020044z
I want to end up with a file that looks like:-... (6 Replies)
Discussion started by: sniper57
6 Replies
6. Shell Programming and Scripting
Hi,
I have written a cgi perl script to read a file and display its contents. But if i have to access file located on network (local network), then i am unable to do so. However if i run script through shell it works, but through cgi script it generates no result. I have mapped network drive... (0 Replies)
Discussion started by: sarbjit
0 Replies
7. Shell Programming and Scripting
The scope of the shell/perl script is to read the input text file. Validate the expiry date of each certificate and send the mail to the user. The user takes action to add the new certificate to the storage file and user owns the responsibility to update the input text file with the new certificate... (5 Replies)
Discussion started by: casmo
5 Replies
8. Shell Programming and Scripting
Hi,
I am working on one script..I am having files in the below format
file 1 (each line is separated with : delimeter)
SPLASH:SPLASH:SVN
CIB/MCH:MCH:SVN
Now I want from file 1 that most left part of the first line will store in... (6 Replies)
Discussion started by: rohit22hamirpur
6 Replies
9. UNIX and Linux Applications
Hi,
I want the Perl script with versions 5.8.2 and 5.8.5 starting with
#!/usr/bin/perl
The Perl program should read the excel file or text file line by line and taking into an array and search in the UNIX directories for reference file of .jsp or .js or .xsl with path .The Object names... (2 Replies)
Discussion started by: pasam
2 Replies
10. Shell Programming and Scripting
Hello Forum.
I have a file called abc.sed with the following commands;
s/1/one/g
s/2/two/g
...
I also have a second file called abc.dat and would like to substitute all occurrences of "1 with one", "2 with two", etc and create a new file called abc_new.dat
sed -f abc.sed abc.dat >... (10 Replies)
Discussion started by: pchang
10 Replies
LEARN ABOUT CENTOS
perl::critic::policy::inputoutput::requirebriefopen
Perl::Critic::Policy::InputOutput::RequireBriefOpen(3) User Contributed Perl Documentation Perl::Critic::Policy::InputOutput::RequireBriefOpen(3)
NAME
Perl::Critic::Policy::InputOutput::RequireBriefOpen - Close filehandles as soon as possible after opening them.
AFFILIATION
This Policy is part of the core Perl::Critic distribution.
DESCRIPTION
One way that production systems fail unexpectedly is by running out of filehandles. Filehandles are a finite resource on every operating
system that I'm aware of, and running out of them is virtually impossible to recover from. The solution is to not run out in the first
place. What causes programs to run out of filehandles? Usually, it's leaks: you open a filehandle and forget to close it, or just wait a
really long time before closing it.
This problem is rarely exposed by test systems, because the tests rarely run long enough or have enough load to hit the filehandle limit.
So, the best way to avoid the problem is 1) always close all filehandles that you open and 2) close them as soon as is practical.
This policy takes note of calls to "open()" where there is no matching "close()" call within "N" lines of code. If you really need to do a
lot of processing on an open filehandle, then you can move that processing to another method like this:
sub process_data_file {
my ($self, $filename) = @_;
open my $fh, '<', $filename
or croak 'Failed to read datafile ' . $filename . '; ' . $OS_ERROR;
$self->_parse_input_data($fh);
close $fh;
return;
}
sub _parse_input_data {
my ($self, $fh) = @_;
while (my $line = <$fh>) {
...
}
return;
}
As a special case, this policy also allows code to return the filehandle after the "open" instead of closing it. Just like the close,
however, that "return" has to be within the right number of lines. From there, you're on your own to figure out whether the code is
promptly closing the filehandle.
The STDIN, STDOUT, and STDERR handles are exempt from this policy.
CONFIGURATION
This policy allows "close()" invocations to be up to "N" lines after their corresponding "open()" calls, where "N" defaults to 9. You can
override this to set it to a different number with the "lines" setting. To do this, put entries in a .perlcriticrc file like this:
[InputOutput::RequireBriefOpen]
lines = 5
CAVEATS
"IO::File->new"
This policy only looks for explicit "open" calls. It does not detect calls to "CORE::open" or "IO::File->new" or the like.
Is it the right lexical?
We don't currently check for redeclared filehandles. So the following code is false negative, for example, because the outer scoped
filehandle is not closed:
open my $fh, '<', $file1 or croak;
if (open my $fh, '<', $file2) {
print <$fh>;
close $fh;
}
This is a contrived example, but it isn't uncommon for people to use $fh for the name of the filehandle every time. Perhaps it's time to
think of better variable names...
CREDITS
Initial development of this policy was supported by a grant from the Perl Foundation.
AUTHOR
Chris Dolan <cdolan@cpan.org>
COPYRIGHT
Copyright (c) 2007-2011 Chris Dolan. Many rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license
can be found in the LICENSE file included with this module
perl v5.16.3 2014-06-09 Perl::Critic::Policy::InputOutput::RequireBriefOpen(3)