07-20-2010
rdcwayx is absolutely correct. Good catch!
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi
I am new to shell scripting.I want to create a batch file which creates a desired number of files with a specific size say 1MB each to consume space.How can i go about it using for loop /any other loop condition using shell script?
Thanks (3 Replies)
Discussion started by: swatideswal
3 Replies
2. Shell Programming and Scripting
Hello,
I really would appreciate some help with a bash script for some string manipulation on an SQL dump:
I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump.
This is quite easy with sed:
sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies
3. Shell Programming and Scripting
using sed to replace a specific string on a specific line number using variables
this is where i am at
grep -v WARNING output | grep -v spawn | grep -v Passphrase | grep -v Authentication | grep -v '/sbin/tfadmin netguard -C'| grep -v 'NETWORK>' >> output.clean
grep -n Destination... (2 Replies)
Discussion started by: todd.cutting
2 Replies
4. UNIX for Dummies Questions & Answers
Hi,
i'm trying to find a way to replace some numbers in a file, but with no luck sofar.
Let's say i have file with three columns,
i would like to find specific line, and replace third column with different number.
search_string="oa11 /home/testfile1.log"
new_number=600
test file... (4 Replies)
Discussion started by: dusoo
4 Replies
5. UNIX for Dummies Questions & Answers
Hi. I need to delete a large number of files listed in a txt file. There are over 90000 files in the list. Some of the directory names and some of the file names do have spaces in them.
In the file, each line is a full path to a file:
/path/to/the files/file1
/path/to/some other/files/file 2... (4 Replies)
Discussion started by: inakajin
4 Replies
6. Shell Programming and Scripting
perl -pi -e 's/\x00/\x0d\x0a/g' `grep -l $'GS' filelist`
This isn't working :confused:, it's not pulling the files that contain the regex. Please help me rewrite this :wall:.
Ideally for this to work on 9K of 20K files in the directory, I've tried this but I don't know enough about awk... (7 Replies)
Discussion started by: verge
7 Replies
7. Shell Programming and Scripting
Want to sftp large number of files ... approx 150 files will come to server every minute. (AIX box)
Also need make sure file has been sftped successfully...
Please let me know :
1. What is the best / faster way to transfer files?
2. should I use batch option -b so that connectivity will be... (3 Replies)
Discussion started by: vegasluxor
3 Replies
8. Shell Programming and Scripting
Hello Friends,
I have the below scenario in my current project. Suggest me which tool ( perl,python etc) is best to this scenario. Or should I go for Programming language ( C/Java )..
(1) I will be having a very big file ( information about 200million subscribers will be stored in it ). This... (5 Replies)
Discussion started by: panyam
5 Replies
9. Shell Programming and Scripting
I have one big file of size 9GB (big_file.txt). This big file has sentences and paragraphs like any usual English document. I have another file consisting of replacement strings for sed to use. The file name is replace.sed and each entry in one line looks like this:
s/\<shout\>/shout/g
s/\<b is... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies
10. Shell Programming and Scripting
Hi,
I have a file with hundreds of lines. I want to search for particular lines starting with 4000, search and replace the 137-139 position characters; which will be '000', with '036'. Can all of this be done without opening a temp file and then moving that temp file to the original file name.
... (7 Replies)
Discussion started by: dsid
7 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)