08-04-2008
Have a look at the perlrun man page, specifically the -n option. This would allow you to write the above script as a shorter one-liner since perl looks after the while (<>) part for you. Probably not relevant since you intend to write a more complex script anyway, but useful to know.
For the second part, I would load the first file into a hash indexed by the comparison field, then read through the second file, and for any record where the fourth field exists in your previously populated hash, output the wanted fields.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
How can i use sed command to modify a part of a variable containing "/" by another containing "/" like describe below:
VAR="/app/share/eai"
VAR1="/app/share"
VAR2="/data/test"
echo $VAR | sed 's/... ??? # using sed to replace $VAR1 in $VAR by $VAR2 ? (4 Replies)
Discussion started by: jo_aze
4 Replies
2. Shell Programming and Scripting
I know that I want to entirely replace line 3 in my file filename.txt. I have tried all sorts of variations of
sed 3,3,c\replacement stuff\ filename.txt with no success.
about the only thing that causes any reaction is
sed 3,3c\\ filename.txt
but it just prints out the whole file.
... (13 Replies)
Discussion started by: SusanDAC
13 Replies
3. Shell Programming and Scripting
Im new at scripting and im trying to write a script using perl that will make sure there are 2 command line integer arguments and then check if the 2nd argument is greater than the first. i believe im close but still receive my error message even when i have 2 arguments and the second part gives me... (6 Replies)
Discussion started by: livewire06
6 Replies
4. UNIX for Dummies Questions & Answers
Hello,
here is what I've got :
FILE='/OPERATIONNEL/SATURNE/CHAMPS/MASTER/ANA/SATURNE_1DAV_20080805_20080806_S3D_T_R20080806.NC ';;... (4 Replies)
Discussion started by: Aswex
4 Replies
5. Shell Programming and Scripting
<tr><td width=10% style='width:5%;background:#F7F0D9;padding:0in 0in 0in 0in 0in'><center><b>Package</b></td><td width=10% valign=center style='width:5%;background:#F7F0D9;padding:0in 0in 0in 0in 0in'><center><b>JTs</b></td>
This is got to be simple. I run this on the above .html file:
sed... (8 Replies)
Discussion started by: dba_frog
8 Replies
6. Shell Programming and Scripting
I'm a newbie to perl scripting. Can someone please explain the syntax below. Specifically what does -> and => do?
$tz->site( => $site); (10 Replies)
Discussion started by: scj2012
10 Replies
7. UNIX for Dummies Questions & Answers
Query with perl syntax
Aim: is to change a perl script to use a new file
I was required to replace
- entries \"$entries\"
with
-lib <full_path_to_filename>
So in the code detector.pm
sub rundetector
{
my $class = shift;
mkdir($resultDirectory);
my... (3 Replies)
Discussion started by: sa@@
3 Replies
8. Shell Programming and Scripting
Greetings!
I've run into this before; and am having a spot of trouble trying to figure out the way that Perl would prefer the following example syntax to be formed:#!/usr/bin/perl
use strict;
use warnings;
use diagnostics;
`sed -i 's/Hi Mom!\|Hi Dad!/Bye Everyone!/I' ./test.txt`;Perl... (5 Replies)
Discussion started by: LinQ
5 Replies
9. Shell Programming and Scripting
I am having trouble re-writing this sed code
sed -nr 's/.*del(+)ins(+).*NC_0{4}(+).*g\.(+)_(+).*/\3\t\4\t\5\t\1\t\2/p' C:/Users/cmccabe/Desktop/Python27/out_position.txt > C:/Users/cmccabe/Desktop/Python27/out_parse.txt in perl Basically, what the code does is parse text from two fields... (12 Replies)
Discussion started by: cmccabe
12 Replies
10. Shell Programming and Scripting
Hi,
Anyone can help using SED searches a character string for a specified delimiter character, and returns a leading or trailing space/blank.
Text file :
"1"|"ExternalClassDEA519CF5"|"Art1"
"2"|"ExternalClass563EA516C"|"Art3"
"3"|"ExternalClass305ED16B8"|"Art9"
...
...
... (2 Replies)
Discussion started by: fspalero
2 Replies
LEARN ABOUT DEBIAN
plucene::index::fieldinfos
Plucene::Index::FieldInfos(3pm) User Contributed Perl Documentation Plucene::Index::FieldInfos(3pm)
NAME
Plucene::Index::FieldInfos - a collection of FieldInfo objects
SYNOPSIS
my $fis = Plucene::Index::FieldInfos->new($dir_name);
my $fis = Plucene::Index::FieldInfos->new($dir_name, $file);
$fis->add(Plucene::Document $doc, $indexed);
$fis->add(Plucene::Index::FieldInfos $other_fis, $indexed);
$fis->add($name, $indexed);
$fis->write($path);
my @fields = $fis->fields;
my $field_number = $fis->field_number($name);
my $field_info = $fis->field_info($name);
my $field_name = $fis->field_name($number);
my $num_fields = $fis->size;
DESCRIPTION
This is a collection of field info objects, which happen to live in the field infos file.
METHODS
new
my $fis = Plucene::Index::FieldInfos->new($dir_name);
my $fis = Plucene::Index::FieldInfos->new($dir_name, $file);
This will create a new Plucene::Index::FieldInfos object with the passed directory and optional filename.
add
$fis->add(Plucene::Document $doc, $indexed);
$fis->add(Plucene::Index::FieldInfos $other_fis, $indexed);
$fis->add($name, $indexed);
This will add the fields from a Plucene::Document or a Plucene::Index::FieldsInfos to the field infos file.
It is also possible to pass the name of a field and have it added to the file.
field_number
my $field_number = $fis->field_number($name);
This will return the field number of the field with $name. If there is no match, then -1 is returned.
fields
my @fields = $fis->fields;
This will return all the fields.
field_info
my $field_info = $fis->field_info($name);
This will return the field info for the field called $name.
field_name
my $field_name = $fis->field_name($number);
This will return the field name for the field whose number is $number.
size
my $num_fields = $fis->size;
This returns the number of field info objects.
write
$fis->write($path);
This will write the field info objects to $path.
perl v5.12.4 2011-08-14 Plucene::Index::FieldInfos(3pm)