Sponsored Content
Top Forums Shell Programming and Scripting using awk in perl with split command Post 302586651 by vineet.dhingra on Tuesday 3rd of January 2012 01:27:25 AM
Old 01-03-2012
I think i am using an older version. it gives this error. any other way?
"Can't locate Tie/IxHash.pm "
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk command to split in to 2 files

Hi, I have a problem in grepping a file for 2 strings and writing them to 2 appropriate files. I need to use the awk command and read the file only once and write to the appropriate file. My file is very huge in size and it is taking a long time using cat command and grep command. Can anyone... (3 Replies)
Discussion started by: m_subra_mani
3 Replies

2. Shell Programming and Scripting

Perl Split Command usage

Hi, I am trying to use the split commad to seperate string reading from file. but it dosent give me a correct result. can some body tell me what is the wrong in following scritp. #!/usr/bin/perl -w #use CGI qw(:standard); ... (2 Replies)
Discussion started by: maheshsri
2 Replies

3. UNIX for Advanced & Expert Users

Split Command in Perl

Hi, I have to split a line of the form 1232423#asdf#124324#54534#dcfg#wert#rrftt#4567 into an array in perl. I am using @fields; @fields=split('#',$line); if($fields eq "1") But this is not working. By using the syntax, the statements in "if" are never executed. Please help.... (9 Replies)
Discussion started by: rochitsharma
9 Replies

4. Shell Programming and Scripting

Split a file based on pattern in awk, grep, sed or perl

Hi All, Can someone please help me write a script for the following requirement in awk, grep, sed or perl. Buuuu xxx bbb Kmmmm rrr ssss uuuu Kwwww zzzz ccc Roooowwww eeee Bxxxx jjjj dddd Kuuuu eeeee nnnn Rpppp cccc vvvv cccc Rhhhhhhyyyy tttt Lhhhh rrrrrssssss Bffff mmmm iiiii Ktttt... (5 Replies)
Discussion started by: kumarn
5 Replies

5. Shell Programming and Scripting

Awk command to split file name

Hi I have few files with format access.2Nov-12:15AM. These files will be generated daily . I need to write a script so that if today's date is less than 10 then it has to zip the file and rename it to acess.02Nov-12:15AM.gz .please help me in this . Also please help me in splitting the file... (10 Replies)
Discussion started by: mskalyani9
10 Replies

6. Shell Programming and Scripting

Split a file using awk command.

awk 'FNR == 1 { c = 1 } { print > (f c) } !FNR%n { close(f c); ++c }' n=$files_per_stream f=$input_path/filename_ $input_file $input_file with some records are splitted into files named filename_1,filename_2...etc according to $files_per_stream. Plz help me know how and if anyone has... (7 Replies)
Discussion started by: guptam
7 Replies

7. Shell Programming and Scripting

Want to split awk command

Hi, There is an awk command in script and it is running successfully. I want to split that command in 2 lines. I have tried using '\' but its not working.. Please suggest me the solution. (11 Replies)
Discussion started by: Sanket Dalvi
11 Replies

8. Shell Programming and Scripting

awk split command to get the desired result

Dear all, I am using the awk 'split' command to get the particular value. FILE=InputFile_009_0.txt Temp=$(echo $FILE | awk '{split($FILE, a, "e_"); print a}') I would like to have the Temp take the value as : _009_0 ... (4 Replies)
Discussion started by: emily
4 Replies

9. Shell Programming and Scripting

awk split and awk calculation in the same command

I am trying to run the awk below. My question is when I split the input, then run anotherawk to perform a calculation using that splitas the input there are no issues. When I try to combine them the output is not correct, is the split not working or did I do it wrong? Thank you :). input ... (8 Replies)
Discussion started by: cmccabe
8 Replies

10. UNIX for Beginners Questions & Answers

awk command to split pipe delimited file

Hello, I need to split a pipe de-limited file based on the COLUMN 7 value . If the column value changes I need to split the file Source File Payment|ID|DATE|TIME|CONTROLNUMBER|NUMBER|NAME|INDICATOR 42156974|1137937|10/1/2018|104440|4232|2054391|CARE|1... (9 Replies)
Discussion started by: rosebud123
9 Replies
Tie::IxHash(3)						User Contributed Perl Documentation					    Tie::IxHash(3)

NAME
Tie::IxHash - ordered associative arrays for Perl SYNOPSIS
# simple usage use Tie::IxHash; tie HASHVARIABLE, Tie::IxHash [, LIST]; # OO interface with more powerful features use Tie::IxHash; TIEOBJECT = Tie::IxHash->new( [LIST] ); TIEOBJECT->Splice( OFFSET [, LENGTH [, LIST]] ); TIEOBJECT->Push( LIST ); TIEOBJECT->Pop; TIEOBJECT->Shift; TIEOBJECT->Unshift( LIST ); TIEOBJECT->Keys( [LIST] ); TIEOBJECT->Values( [LIST] ); TIEOBJECT->Indices( LIST ); TIEOBJECT->Delete( [LIST] ); TIEOBJECT->Replace( OFFSET, VALUE, [KEY] ); TIEOBJECT->Reorder( LIST ); TIEOBJECT->SortByKey; TIEOBJECT->SortByValue; TIEOBJECT->Length; DESCRIPTION
This Perl module implements Perl hashes that preserve the order in which the hash elements were added. The order is not affected when values corresponding to existing keys in the IxHash are changed. The elements can also be set to any arbitrary supplied order. The familiar perl array operations can also be performed on the IxHash. Standard "TIEHASH" Interface The standard "TIEHASH" mechanism is available. This interface is recommended for simple uses, since the usage is exactly the same as regular Perl hashes after the "tie" is declared. Object Interface This module also provides an extended object-oriented interface that can be used for more powerful operations with the IxHash. The following methods are available: FETCH, STORE, DELETE, EXISTS These standard "TIEHASH" methods mandated by Perl can be used directly. See the "tie" entry in perlfunc(1) for details. Push, Pop, Shift, Unshift, Splice These additional methods resembling Perl functions are available for operating on key-value pairs in the IxHash. The behavior is the same as the corresponding perl functions, except when a supplied hash key already exists in the hash. In that case, the existing value is updated but its order is not affected. To unconditionally alter the order of a supplied key-value pair, first "DELETE" the IxHash element. Keys Returns an array of IxHash element keys corresponding to the list of supplied indices. Returns an array of all the keys if called without arguments. Note the return value is mostly only useful when used in a list context (since perl will convert it to the number of elements in the array when used in a scalar context, and that may not be very useful). If a single argument is given, returns the single key corresponding to the index. This is usable in either scalar or list context. Values Returns an array of IxHash element values corresponding to the list of supplied indices. Returns an array of all the values if called without arguments. Note the return value is mostly only useful when used in a list context (since perl will convert it to the number of elements in the array when used in a scalar context, and that may not be very useful). If a single argument is given, returns the single value corresponding to the index. This is usable in either scalar or list context. Indices Returns an array of indices corresponding to the supplied list of keys. Note the return value is mostly only useful when used in a list context (since perl will convert it to the number of elements in the array when used in a scalar context, and that may not be very useful). If a single argument is given, returns the single index corresponding to the key. This is usable in either scalar or list context. Delete Removes elements with the supplied keys from the IxHash. Replace Substitutes the IxHash element at the specified index with the supplied value-key pair. If a key is not supplied, simply substitutes the value at index with the supplied value. If an element with the supplied key already exists, it will be removed from the IxHash first. Reorder This method can be used to manipulate the internal order of the IxHash elements by supplying a list of keys in the desired order. Note however, that any IxHash elements whose keys are not in the list will be removed from the IxHash. Length Returns the number of IxHash elements. SortByKey Reorders the IxHash elements by textual comparison of the keys. SortByValue Reorders the IxHash elements by textual comparison of the values. EXAMPLE
use Tie::IxHash; # simple interface $t = tie(%myhash, Tie::IxHash, 'a' => 1, 'b' => 2); %myhash = (first => 1, second => 2, third => 3); $myhash{fourth} = 4; @keys = keys %myhash; @values = values %myhash; print("y") if exists $myhash{third}; # OO interface $t = Tie::IxHash->new(first => 1, second => 2, third => 3); $t->Push(fourth => 4); # same as $myhash{'fourth'} = 4; ($k, $v) = $t->Pop; # $k is 'fourth', $v is 4 $t->Unshift(neg => -1, zeroth => 0); ($k, $v) = $t->Shift; # $k is 'neg', $v is -1 @oneandtwo = $t->Splice(1, 2, foo => 100, bar => 101); @keys = $t->Keys; @values = $t->Values; @indices = $t->Indices('foo', 'zeroth'); @itemkeys = $t->Keys(@indices); @itemvals = $t->Values(@indices); $t->Replace(2, 0.3, 'other'); $t->Delete('second', 'zeroth'); $len = $t->Length; # number of key-value pairs $t->Reorder(reverse @keys); $t->SortByKey; $t->SortByValue; BUGS
You cannot specify a negative length to "Splice". Negative indexes are OK, though. Indexing always begins at 0 (despite the current $[ setting) for all the functions. TODO
Addition of elements with keys that already exist to the end of the IxHash must be controlled by a switch. Provide "TIEARRAY" interface when it stabilizes in Perl. Rewrite using XSUBs for efficiency. AUTHOR
Gurusamy Sarathy gsar@umich.edu Copyright (c) 1995 Gurusamy Sarathy. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. VERSION
Version 1.22 27 February 2010 SEE ALSO
perl(1) perl v5.12.1 2010-02-27 Tie::IxHash(3)
All times are GMT -4. The time now is 05:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy