Sponsored Content
Top Forums Shell Programming and Scripting Perl string formation from array Post 302740945 by ptappeta on Friday 7th of December 2012 07:53:36 AM
Old 12-07-2012
Perl string formation from array

HI I ma using perl programming

my perl is like this

Code:
 
$InputFile = $ENV{UDE_TMP} . "/" ."cre_fmr_gen.temp_data_file_gen.dat";
@duplicates = `cat $InputFile | cut -d "|" -f 1,1 | sort | uniq -c | awk '{ if(\$1>1) {print \$2;}}'`;
my $cusiplist ;
foreach $cusip (@duplicates)
{
print("instrument is   $cusip"); 
$cusiplist = $cusiplist . "|" . $cusip  ;
}
print($cusiplist);
$tmp_file_1 = $ENV{UDE_TMP} . "/" ."prabhu1";
$tmp_file_2 = $ENV{UDE_TMP} . "/" ."prabhu2";
print($tmp_file_2 );
#$InputFile = $ENV{UDE_TMP} . "/" ."cre_fmr_gen.temp_data_file_gen.dat";
print ("$InputFile ");
use File::Copy;
copy( "$InputFile" , "$InputFile.CP.Prabhu");
$cmd = `cat $InputFile | egrep '$cusiplist'  > $tmp_file_1`;
#$cmd= `cat $InputFile  >$tmp_file_I`;
system(cmd);
print($cmd);

so now i am getting the out put as

Code:
instrument is   FN110OY12
instrument is   FN112OY10
instrument is   FN112OY11
instrument is   FN112OY12
instrument is   FN114OY03
instrument is   FN114OY09
instrument is   FN114OY10
instrument is   FN114OY11
instrument is   FN114OY12
instrument is   FN116OY03
instrument is   FN116OY04
instrument is   FN116OY05
instrument is   FN116OY09
instrument is   FN116OY10
instrument is   FN118OY03
instrument is   FN118OY04
instrument is   FN118OY05
instrument is   FN118OY08
instrument is   FN118OY09
instrument is   FN118OY10
instrument is   FN120OY03
instrument is   FN120OY08
instrument is   FN122OY05
instrument is   FN122OY07
instrument is   FN124OY08
|FN110OY12
|FN112OY10
|FN112OY11
|FN112OY12
|FN114OY03
|FN114OY09
|FN114OY10
|FN114OY11
|FN114OY12
|FN116OY03
|FN116OY04
|FN116OY05
|FN116OY09
|FN116OY10
|FN118OY03
|FN118OY04
|FN118OY05
|FN118OY08
|FN118OY09
|FN118OY10
|FN120OY03
|FN120OY08
|FN122OY05
|FN122OY07
|FN124OY08
/itf/ude/tmp/prabhu2/itf/ude/tmp/cre_fmr_gen.temp_data_file_gen.dat

But I wanted to make a string like this

'FN112OY12|FN114OY10|FN116OY03|FN116OY04|FN116OY05|FN118OY03|FN118OY04|FN118OY05|FN118OY08|FN118OY10 |FN120OY02
|FN120OY08|FN122OY05|FN124OY08'


what needs to be done?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Perl] Accessing array elements within a sed command in Perl script

I am trying to use a script to replace the header of each file, whose filename are stored within the array $test, using the sed command within a Perl script as follows: $count = 0; while ( $count < $#test ) { `sed -e 's/BIOGRF 321/BIOGRF 332/g' ${test} > 0`; `cat 0 >... (2 Replies)
Discussion started by: userix
2 Replies

2. Shell Programming and Scripting

search of string from an array in Perl

Hi All I want to search a string from an array in Perl. If a match occurs, assign that string to a variable else assign 'No match'. I tried writing the script as follows but it's in vain. Please help me.. #!/usr/bin/perl use strict; my $NER; my @text=("ORG","PER"); ... (4 Replies)
Discussion started by: my_Perl
4 Replies

3. Shell Programming and Scripting

perl, put one array into many array when field is equal to sth

Hi Everyone, #!/usr/bin/perl use strict; use warnings; my @test=("a;b;qqq;c;d","a;b;ggg;c;d","a;b;qqq;c;d"); would like to split the @test array into two array: @test1=(("a;b;qqq;c;d","a;b;qqq;c;d"); and @test2=("a;b;ggg;c;d"); means search for 3rd filed. Thanks find the... (0 Replies)
Discussion started by: jimmy_y
0 Replies

4. Shell Programming and Scripting

Perl and string array problem

#!/usr/bin/perl my @arr=("hello", "how", "are", "you"); $l=length(@arr); print $l; This print 1.Why? How can i print the array size = 4? I want to store these in an array. hello how are you And then i want to access these element through indexing. How can i do this? (4 Replies)
Discussion started by: cola
4 Replies

5. Shell Programming and Scripting

[Perl] Sorting an String-Array

Hi, i have a txtfile with the format <Nr>tab<word>tab<other stuff>new line and i want to sort the <word>-colum with a perl script. My textfile: <Nr>tab<word>tab<other stuff>new line 6807 die ART.Acc.Sg.Fem 6426 der ART.Gen.Sg.Fem 2 die ART.Nom.Sg.Fem 87 auf APPR.-- 486 nicht PTKNEG.--... (1 Reply)
Discussion started by: buckelede
1 Replies

6. Shell Programming and Scripting

Array in Perl - Detect several file to be in one array

Hi everyone I have one question about using array in perl. let say I have several log file in one folder.. example test1.log test2.log test3.log and the list goes on.. how to make an array for this file? It suppose to detect log file in the current directory and all the log file will... (3 Replies)
Discussion started by: sayachop
3 Replies

7. Shell Programming and Scripting

PERL : Read an array and write to another array with intial string pattern checks

I have an array and two variables as below, I need to check if $datevar is present in $filename. If so, i need to replace $filename with the values in the array. I need the output inside an ARRAY How can this be done. Any help will be appreciated. Thanks in advance. (2 Replies)
Discussion started by: irudayaraj
2 Replies

8. Programming

Perl script to create football formation

I need help to create varieties of football formation. The available positions are: GK SW DR DC DL WBR DM WBL MR MC ML AMR AMC AML ST But the conditions are: a. the maximum number in 1 formation: GK is 1 SW is 1 (1 Reply)
Discussion started by: Tzeronone
1 Replies

9. Programming

Not a repeated question (Perl Script Create Football Formation)

https://www.unix.com/programming/252468-perl-script-create-football-formation.html https://www.unix.com/members/43551.html, it is not repeated question. please read it before u block my question. Unblock it for me. Thanks:mad: (0 Replies)
Discussion started by: Tzeronone
0 Replies

10. UNIX for Beginners Questions & Answers

awk Associative Array and/or Referring to Field by String (Nonconstant String Value)

I will start with an example of what I'm trying to do and then describe how I am approaching the issue. File PS028,005 Lexeme HRS # M # PhraseType 1(1:1) 7(7) PhraseLab 501 503 ClauseType ZYq0 PS028,005 Lexeme W # L> # BNH # M #... (17 Replies)
Discussion started by: jvoot
17 Replies
DH_PERL(1)							     Debhelper								DH_PERL(1)

NAME
dh_perl - calculates Perl dependencies and cleans up after MakeMaker SYNOPSIS
dh_perl [debhelperoptions] [-d] [librarydirs...] DESCRIPTION
dh_perl is a debhelper program that is responsible for generating the ${perl:Depends} substitutions and adding them to substvars files. The program will look at Perl scripts and modules in your package, and will use this information to generate a dependency on perl or perlapi. The dependency will be substituted into your package's control file wherever you place the token ${perl:Depends}. dh_perl also cleans up empty directories that MakeMaker can generate when installing Perl modules. OPTIONS
-d In some specific cases you may want to depend on perl-base rather than the full perl package. If so, you can pass the -d option to make dh_perl generate a dependency on the correct base package. This is only necessary for some packages that are included in the base system. Note that this flag may cause no dependency on perl-base to be generated at all. perl-base is Essential, so its dependency can be left out, unless a versioned dependency is needed. -V By default, scripts and architecture independent modules don't depend on any specific version of perl. The -V option causes the current version of the perl (or perl-base with -d) package to be specified. library dirs If your package installs Perl modules in non-standard directories, you can make dh_perl check those directories by passing their names on the command line. It will only check the vendorlib and vendorarch directories by default. CONFORMS TO
Debian policy, version 3.8.3 Perl policy, version 1.20 SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Brendan O'Dea <bod@debian.org> 11.1.6ubuntu2 2018-05-10 DH_PERL(1)
All times are GMT -4. The time now is 05:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy