05-12-2010
Just curious why, if you can achieve it in your known comfort zone, you would prefer to accomplish it in an area you're not so comfortable with...and possibly unable to support in the long-term?
Perl is no doubt powerful but it can be a bugbear to support if you leverage it using someone else's snippet, without a firm grasp of what it's doing for you. Additionally, it would make scaling that much more difficult. Are you sure you'd prefer this approach?
Silly me...homework, ha!
Last edited by curleb; 05-12-2010 at 05:40 PM..
Reason: duh...
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am trying to join/paste columns from two files for the rows with matching first field. Any help will be appreciated.
Files can not be sorted and may not have all rows in both files.
Thanks.
File1
aaa 111
bbb 222
ccc 333
File2
aaa sss mmmm
ccc kkkk llll
ddd xxx yyy
Want to... (1 Reply)
Discussion started by: sk_sd
1 Replies
2. Shell Programming and Scripting
Hi Folks,
I need to compare two very huge file ( i.e the files would contain a minimum of 70k records each) using awk or sed. The comparison needs to be done with respect to a 'key'. For example :
File1
**********
1234|TONY|Y75634|20/07/2008
1235|TINA|XCVB56|30/07/2009... (13 Replies)
Discussion started by: Ranjani
13 Replies
3. Shell Programming and Scripting
i have this file which has the following contents:
,-0.3000 ,-0.3000 ,-0.3000
,-0.9000 ,-0.9000 ,-0.9000
i would like to get this:
-0.3-0.9-0.3-0.9-0.3-0.9
so far i am trying:
awk '{for(i=1; i<=NF; i++) {printf("%f\n",$i)}}' test1 > test2
any help... (4 Replies)
Discussion started by: npatwardhan
4 Replies
4. Shell Programming and Scripting
HI
I'm having some troubles to compare and permut diffrent fields indexed with another filed like the following example `:
file1
1 1
2 2
3 3
file2
7 1
9 2
10 3
result------------------- (6 Replies)
Discussion started by: yassinegoth
6 Replies
5. Shell Programming and Scripting
Hi,
I need the most efficient way of comparing the following and arriving at the result
I have a file which has entries like,
File1:
1|2|5|7|8|2|3|6|3|1
File2:
1|2|3|1|2|7|9|2
I need to compare the entries in these two file with those of a general file,
1|2|3|5|2|5|6|9|3|1... (7 Replies)
Discussion started by: pradebban
7 Replies
6. Shell Programming and Scripting
Hi,
I have two text files, compare column one in both the files and if it matches then the output should contain the id in column one, the number and the description.
Both the files are sorted. Is there a one liner to get this done, kindly help. Thank you
File 1:
NC_000964 92.33 ... (2 Replies)
Discussion started by: pulikoti
2 Replies
7. UNIX for Dummies Questions & Answers
I am trying to compare two files (separted by a pipe) using 2 fields (field 1,3 from fileA and 1,2 from fileB) if the two files match i want the whole record of fileA adding the extra fields left from fileB.
1. A.txt
cat|floffy|12|anything|anythings
cat|kitty|15|lala|lalala... (6 Replies)
Discussion started by: sabercats
6 Replies
8. Shell Programming and Scripting
Hi,
I am trying to check two files based on certain string and field.
cat f1
source=\GREP\"
hi this \\
source=\SED\"
skdmsmd
dnksdns
source=\PERL\"
cat f2
source=\SED\"
source=\GREP\"
vlamskds
amdksk m
source=\AWK\"
awk \here\" (3 Replies)
Discussion started by: greet_sed
3 Replies
9. Shell Programming and Scripting
Hi all, I'm pretty much a newbie to UNIX. I would appreciate any help with UNIX coding on comparing two large csv files (greater than 10 GB in size), and output a file with matching columns.
I want to compare file1 and file2 by 'id' and 'chain' columns, then extract exact matching rows'... (5 Replies)
Discussion started by: bkane3
5 Replies
10. UNIX for Beginners Questions & Answers
Hi,
Below are the sample files. x.txt is from an Excel file that is a list of users from Windows and y.txt is a list of database account.
$ head -500 x.txt y.txt
==> x.txt <==
TEST01 APP_USER_PROFILE
USER03 APP_USER_PROFILE
TEST02 APP_USER_EXP_PROFILE
TEST04 APP_USER_PROFILE
USER01 ... (3 Replies)
Discussion started by: newbie_01
3 Replies
LEARN ABOUT OSX
sub::quote
Sub::Quote(3) User Contributed Perl Documentation Sub::Quote(3)
NAME
Sub::Quote - efficient generation of subroutines via string eval
SYNOPSIS
package Silly;
use Sub::Quote qw(quote_sub unquote_sub quoted_from_sub);
quote_sub 'Silly::kitty', q{ print "meow" };
quote_sub 'Silly::doggy', q{ print "woof" };
my $sound = 0;
quote_sub 'Silly::dagron',
q{ print ++$sound % 2 ? 'burninate' : 'roar' },
{ '$sound' => $sound };
And elsewhere:
Silly->kitty; # meow
Silly->doggy; # woof
Silly->dagron; # burninate
Silly->dagron; # roar
Silly->dagron; # burninate
DESCRIPTION
This package provides performant ways to generate subroutines from strings.
SUBROUTINES
quote_sub
my $coderef = quote_sub 'Foo::bar', q{ print $x++ . "
" }, { '$x' => };
Arguments: ?$name, $code, ?\%captures, ?\%options
$name is the subroutine where the coderef will be installed.
$code is a string that will be turned into code.
"\%captures" is a hashref of variables that will be made available to the code. See the "SYNOPSIS"'s "Silly::dagron" for an example using
captures.
options
o no_install
Boolean. Set this option to not install the generated coderef into the passed subroutine name on undefer.
unquote_sub
my $coderef = unquote_sub $sub;
Forcibly replace subroutine with actual code. Note that for performance reasons all quoted subs declared so far will be globally
unquoted/parsed in a single eval. This means that if you have a syntax error in one of your quoted subs you may find out when some other
sub is unquoted.
If $sub is not a quoted sub, this is a no-op.
quoted_from_sub
my $data = quoted_from_sub $sub;
my ($name, $code, $captures, $compiled_sub) = @$data;
Returns original arguments to quote_sub, plus the compiled version if this sub has already been unquoted.
Note that $sub can be either the original quoted version or the compiled version for convenience.
inlinify
my $prelude = capture_unroll {
'$x' => 1,
'$y' => 2,
};
my $inlined_code = inlinify q{
my ($x, $y) = @_;
print $x + $y . "
";
}, '$x, $y', $prelude;
Takes a string of code, a string of arguments, a string of code which acts as a "prelude", and a Boolean representing whether or not to
localize the arguments.
capture_unroll
my $prelude = capture_unroll {
'$x' => 1,
'$y' => 2,
};
Generates a snippet of code which is suitable to be used as a prelude for "inlinify". The keys are the names of the variables and the
values are (duh) the values. Note that references work as values.
CAVEATS
Much of this is just string-based code-generation, and as a result, a few caveats apply.
return
Calling "return" from a quote_sub'ed sub will not likely do what you intend. Instead of returning from the code you defined in
"quote_sub", it will return from the overall function it is composited into.
So when you pass in:
quote_sub q{ return 1 if $condition; $morecode }
It might turn up in the intended context as follows:
sub foo {
<important code a>
do {
return 1 if $condition;
$morecode
};
<important code b>
}
Which will obviously return from foo, when all you meant to do was return from the code context in quote_sub and proceed with running
important code b.
perl v5.16.2 2012-07-04 Sub::Quote(3)