Sponsored Content
Top Forums Programming Perl- How to catch the file in perl code? Post 302539609 by thegeek on Monday 18th of July 2011 08:27:10 AM
Old 07-18-2011
Use file globbing (<*.out>) while opening the file ( read more about glob in perl )

Code:
open OR,</home/sathiya/perl/Orders*.out>;

Not an excellent method to do so, but it works.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl -write values in a file to @array in perl

Hi can anyone suggest me how to write a file containing values,... say 19 20 21 22 .. 40 to an array @array = (19, 20, ... 40) -- Thanks (27 Replies)
Discussion started by: meghana
27 Replies

2. Shell Programming and Scripting

Passing date formats in Perl: i.e. Jul/10/2007 -> 20070710 (yyyymmdd) - Perl

Hi , This script working for fine if pass script-name.sh Jul/10/2007 ,I want to pass 20070710(yyyymmdd) .Please any help it should be appereciated. use Time::Local; my $d = $ARGV; my $t = $ARGV; my $m = ""; @d = split /\//, $d; @t = split /:/, $t; if ( $d eq "Jan" ) { $m = 0 }... (7 Replies)
Discussion started by: akil
7 Replies

3. Shell Programming and Scripting

Perl : Process a file in perl

I have a file with following data : Qspace: COLOR: Queue: doColor Qspace: COLOR: Queue order: fifo Qspace: COLOR: Out of order: none Qspace: COLOR: Retries: 5 Qspace: COLOR: Queue: setColor Qspace: COLOR: Queue order: fifo Qspace: COLOR: Out of order: none Qspace: COLOR: Retries: 5... (4 Replies)
Discussion started by: deo_kaustubh
4 Replies

4. Shell Programming and Scripting

Need help in comparing a file with log file: perl code

Dear Members, I need a perl code: 1. Which will open first file with two columns separated by tab: 37 Distribution and seasonal variation of trace metals 85 Seasonal variability of the mixed layer in the central Bay 99 Dynamics of transparent exopolymeric particles (TEP) 103 Bacterial... (0 Replies)
Discussion started by: srsahu75
0 Replies

5. Shell Programming and Scripting

perl file, one line code include "length, rindex, substr", slow

Hi Everyone, # cat a.txt a;b;c;64O a;b;c;d;ee;f # cat a.pl #!/usr/bin/perl use strict; use warnings; my $tmp3 = ",,a,,b,,c,,d,,e,,f,,"; open(my $FA, "a.txt") or die "$!"; while(<$FA>) { chomp; my @tmp=split(/\;/, $_); if ( ($tmp =~ m/^(64O)/i) || ($tmp... (3 Replies)
Discussion started by: jimmy_y
3 Replies

6. Shell Programming and Scripting

Perl :How to print the o/p of a Perl script on console and redirecting same in log file @ same time.

How can i print the output of a perl script on a unix console and redirect the same in a log file under same directory simultaneously ? Like in Shell script, we use tee, is there anything in Perl or any other option ? (2 Replies)
Discussion started by: butterfly20
2 Replies

7. Shell Programming and Scripting

perl: a way to see a sub code in debug mode: perl -de 0 ?

Is there a way to see or print a sub code? Sometime a sub could be already defined, but in the debug mode (so, interactively) it could be already out of screen. So, I would think about a way to check if the sub is defined (just 'defined' is not a problem) and how it is defined. Also, if... (4 Replies)
Discussion started by: alex_5161
4 Replies

8. Shell Programming and Scripting

PERL code to check if file exists

Hi Guy’s, I have this simple PERL code which checks whether the file exists . At the moment I am getting the following error This is the code I am using #!/usr/bin/perl Open (F, "home/work/PerlWork/dataFile") or die "Could not open the file:$!\"; Also how can I read the content of... (3 Replies)
Discussion started by: INHF
3 Replies

9. Shell Programming and Scripting

Perl Code to change file delimiter (passed as argument) to bar delimiter

Hi, Extremely new to Perl scripting, but need a quick fix without using TEXT::CSV I need to read in a file, pass any delimiter as an argument, and convert it to bar delimited on the output. In addition, enclose fields within double quotes in case of any embedded delimiters. Any help would... (2 Replies)
Discussion started by: JPB1977
2 Replies

10. Programming

PERL: In a perl-scripttTrying to execute another perl-script that SETS SOME VARIABLES !

I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open()) I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies
catch(n)						       Tcl Built-In Commands							  catch(n)

__________________________________________________________________________________________________________________________________________________

NAME
       catch - Evaluate script and trap exceptional returns

SYNOPSIS
       catch script ?resultVarName? ?optionsVarName?
_________________________________________________________________

DESCRIPTION
       The  catch  command may be used to prevent errors from aborting command interpretation.	The catch command calls the Tcl interpreter recur-
       sively to execute script, and always returns without raising an error, regardless of any errors that might occur while executing script.

       If script raises an error, catch will return a non-zero integer value corresponding to the exceptional return code returned  by	evaluation
       of  script.  Tcl defines the normal return code from script evaluation to be zero (0), or TCL_OK.  Tcl also defines four exceptional return
       codes: 1 (TCL_ERROR), 2 (TCL_RETURN), 3 (TCL_BREAK), and 4 (TCL_CONTINUE).  Errors during evaluation of a script are indicated by a  return
       code of TCL_ERROR.  The other exceptional return codes are returned by the return, break, and continue commands and in other special situa-
       tions as documented.  Tcl packages can define new commands that return other integer values as return codes as well, and scripts that  make
       use of the return -code command can also have return codes other than the five defined by Tcl.

       If  the	resultVarName  argument  is given, then the variable it names is set to the result of the script evaluation.  When the return code
       from the script is 1 (TCL_ERROR), the value stored in resultVarName is an error message.  When  the  return  code  from	the  script  is  0
       (TCL_OK), the value stored in resultVarName is the value returned from script.

       If  the	optionsVarName	argument  is  given, then the variable it names is set to a dictionary of return options returned by evaluation of |
       script.	Tcl specifies two entries that are always defined in the dictionary: -code and -level.	When the return code  from  evaluation	of |
       script  is  not	TCL_RETURN, the value of the -level entry will be 0, and the value of the -code entry will be the same as the return code. |
       Only when the return code is TCL_RETURN will the values of the -level and -code entries be something else, as further described in the doc- |
       umentation for the return command.													   |

       When  the  return  code	from  evaluation  of script is TCL_ERROR, three additional entries are defined in the dictionary of return options |
       stored in optionsVarName: -errorinfo, -errorcode, and -errorline.  The value of the -errorinfo entry is a formatted stack trace	containing |
       more  information  about the context in which the error happened.  The formatted stack trace is meant to be read by a person.  The value of |
       the -errorcode entry is additional information about the error stored as a list.  The -errorcode value is meant to be further processed	by |
       programs,  and may not be particularly readable by people.  The value of the -errorline entry is an integer indicating which line of script |
       was being evaluated when the error occurred.  The values of the -errorinfo and -errorcode entries of the most recent error are also  avail- |
       able as values of the global variables ::errorInfo and ::errorCode respectively. 							   |

       Tcl packages may provide commands that set other entries in the dictionary of return options, and the return command may be used by scripts |
       to set return options in addition to those defined above.

EXAMPLES
       The catch command may be used in an if to branch based on the success of a script.
	      if { [catch {open $someFile w} fid] } {
		  puts stderr "Could not open $someFile for writing
$fid"
		  exit 1
	      }

       There are more complex examples of catch usage in the documentation for the return command.

SEE ALSO
       break(n), continue(n), dict(n), error(n), return(n), tclvars(n)

KEYWORDS
       catch, error

Tcl									8.5								  catch(n)
All times are GMT -4. The time now is 10:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy