06-23-2014
@RudiC: One possible catch might be that if a consecutive block does start with p1, but does not contain "118,1:", it will get printed as well.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Dear all,
I am using awk in a bash script to extract a list of x y z coordinates from a file such as:
%BEGIN 3D-SPACE COORDINATES
0.2085627338147950 0.2471306816410478 0.2085627338147950
0.1242549179185660 0.2755539793525220 0.4147884486606120
0.2030669560265720 ... (6 Replies)
Discussion started by: pauli
6 Replies
2. UNIX for Dummies Questions & Answers
I have two text files where the first three columns are exactly the same. I want to compare the fourth column of the text files and if the values are different, print that row into a new output file. How do I go about doing that?
File 1:
100 rs3794811 0.01 0.3434
100 rs8066551 0.01... (8 Replies)
Discussion started by: evelibertine
8 Replies
3. Programming
I have a C++ program. I read command line arguments, but if the value is not supplied, I default or make a calculation. Let's say I set it to a default value.
I can code this in several ways. Here I show three ways. What would be the best way for maintaining this code? The program will get very... (2 Replies)
Discussion started by: kristinu
2 Replies
4. Shell Programming and Scripting
I am trying to delete lines in archived Apache httpd logs
Each line has the pattern:
<ip-address> - - <date-time> <document-request-URL> <http-response> <size-of-req'd-doc> <referring-document-URL>
This pattern is shown in the example of 6 lines from the log in the code box below. These 6... (1 Reply)
Discussion started by: Proteomist
1 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I have two text files with matching first columns. Some of the values in the second column do not match. I want to write a script to print out the rows (only the first column) where the values in the second column do not match.
Example:
Input 1
A 1
B 2
C 3
D 4
Input 2
A 2
B 2... (6 Replies)
Discussion started by: evelibertine
6 Replies
6. Shell Programming and Scripting
how can I pass multiple values from command line arguments
example
script.sh -arg1 op1 -arg2 op1 op2 op3 (2 Replies)
Discussion started by: nsk
2 Replies
7. Shell Programming and Scripting
Hi All
I had requirement where I need to re-order columns in a file by using a control file.
here is the ctrl file
c1
c2
c3
source file
c3 | c1 | c2
a | b| c
I should create output file based on the ctrl file columns
o/p should look like this
c1 | c2 | c3
b| c|a
I wrote some... (9 Replies)
Discussion started by: gvkumar25
9 Replies
8. Shell Programming and Scripting
First I'd like to apologize if I opened a thread which is already open somewhere.
I did a bit of searching but could quite find what I was looking for, so I will try to explaing what I need.
I'm writing a script on our server, got to a point where I have two files with results. Example:
File1... (6 Replies)
Discussion started by: mitabrev83
6 Replies
9. Shell Programming and Scripting
Dears,
Need help to implement below requirement
A file (detail.txt)contain :
1st column: Stream
2nd column: PathAddress
3rd column: Counterlimit
4th column: TransactionDateColumn
5th column: DateType
6th column: SleepValue
7th column: Status
Need to write a... (1 Reply)
Discussion started by: sadique.manzar
1 Replies
10. Shell Programming and Scripting
My file (the output of an experiment) starts off looking like this,
_____________________________________________________________
Subjects incorporated to date: 001
Data file started on machine PKSHS260-05CP
**********************************************************************
Subject 1,... (9 Replies)
Discussion started by: samonl
9 Replies
LEARN ABOUT DEBIAN
trycatch
TryCatch(3pm) User Contributed Perl Documentation TryCatch(3pm)
NAME
TryCatch - first class try catch semantics for Perl, without source filters.
DESCRIPTION
This module aims to provide a nicer syntax and method to catch errors in Perl, similar to what is found in other languages (such as Java,
Python or C++). The standard method of using "eval {}; if ($@) {}" is often prone to subtle bugs, primarily that its far too easy to stomp
on the error in error handlers. And also eval/if isn't the nicest idiom.
SYNOPSIS
use TryCatch;
sub foo {
my ($self) = @_;
try {
die Some::Class->new(code => 404 ) if $self->not_found;
return "return value from foo";
}
catch (Some::Class $e where { $_->code > 100 } ) {
}
}
SYNTAX
This module aims to give first class exception handling to perl via 'try' and 'catch' keywords. The basic syntax this module provides is
"try { # block }" followed by zero or more catch blocks. Each catch block has an optional type constraint on it the resembles Perl6's
method signatures.
Also worth noting is that the error variable ($@) is localised to the try/catch blocks and will not leak outside the scope, or stomp on a
previous value of $@.
The simplest case of a catch block is just
catch { ... }
where upon the error is available in the standard $@ variable and no type checking is performed. The exception can instead be accessed via
a named lexical variable by providing a simple signature to the catch block as follows:
catch ($err) { ... }
Type checking of the exception can be performed by specifing a type constraint or where clauses in the signature as follows:
catch (TypeFoo $e) { ... }
catch (Dict[code => Int, message => Str] $err) { ... }
As shown in the above example, complex Moose types can be used, including MooseX::Types style of type constraints
In addition to type checking via Moose type constraints, you can also use where clauses to only match a certain sub-condition on an error.
For example, assuming that "HTTPError" is a suitably defined TC:
catch (HTTPError $e where { $_->code >= 400 && $_->code <= 499 } ) {
return "4XX error";
}
catch (HTTPError $e) {
return "other http code";
}
would return "4XX error" in the case of a 404 error, and "other http code" in the case of a 302.
In the case where multiple catch blocks are present, the first one that matches the type constraints (if any) will executed.
BENEFITS
return. You can put a return in a try block, and it would do the right thing - namely return a value from the subroutine you are in,
instead of just from the eval block.
Type Checking. This is nothing you couldn't do manually yourself, it does it for you using Moose type constraints.
TODO
o Decide on "finally" semantics w.r.t return values.
o Write some more documentation
o Split out the dependancy on Moose
SEE ALSO
MooseX::Types, Moose::Util::TypeConstraints, Parse::Method::Signatures.
AUTHOR
Ash Berlin <ash@cpan.org>
THANKS
Thanks to Matt S Trout and Florian Ragwitz for work on Devel::Declare and various B::Hooks modules
Vincent Pit for Scope::Upper that makes the return from block possible.
Zefram for providing support and XS guidance.
Xavier Bergade for the impetus to finally fix this module in 5.12.
LICENSE
Licensed under the same terms as Perl itself.
perl v5.14.2 2010-10-13 TryCatch(3pm)