Sponsored Content
Top Forums Shell Programming and Scripting PERL : Read an array and write to another array with intial string pattern checks Post 302570986 by irudayaraj on Saturday 5th of November 2011 05:43:02 AM
Old 11-05-2011
PERL : Read an array and write to another array with intial string pattern checks

I have an array and two variables as below,

Quote:

@values = ("2011_11_05", "2011_11_04" , "2011_11_03");
my $filename = 'abc_yyyy_mm_dd';
my $datevar ='yyyy_mm_dd';

I need to check if $datevar is present in $filename.
If so, i need to replace $filename with the values in the array.

Quote:
output needed:

abc_2011_11_05
abc_2011_11_04
abc_2011_11_03
I need the output inside an ARRAY
How can this be done.

Any help will be appreciated. Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl -write values in a file to @array in perl

Hi can anyone suggest me how to write a file containing values,... say 19 20 21 22 .. 40 to an array @array = (19, 20, ... 40) -- Thanks (27 Replies)
Discussion started by: meghana
27 Replies

2. Shell Programming and Scripting

Perl: Read directories and assign to array

I would like to read directories and assign to an array where the user can select a directory from the output. For example, a dir list will populate with a number assigned to each dir. I would like to ask the user to select the dir they want. TIA, I don't know what this would be called so I... (2 Replies)
Discussion started by: man
2 Replies

3. 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

4. Shell Programming and Scripting

Perl:Use of array elements in pattern matching

I need to use array elements while pattern matching. @myarr = (ELEM1, ELEM2, ELEM3); following is the statement which I am using in my code. Basically I want to replace the ELEM1/2/3 with other thing which is mentioned as REPL here. if (condition) { s/(ELEM1|ELEM2|ELEM3): REPL: /; } I... (3 Replies)
Discussion started by: deo_kaustubh
3 Replies

5. Shell Programming and Scripting

Perl Array / pattern match large CPU usage

Hi, I have one file in this format 20 value1 33 value2 56 value3 I have another file in this format: 34,30-SEP-09,57,100237775,33614510126,2,34 34,30-SEP-09,57,100237775,33620766654,2,34 34,30-SEP-09,108,100237775,33628458122,2,34 34,30-SEP-09,130,100237775,33635266741,2,254... (6 Replies)
Discussion started by: Donkey25
6 Replies

6. 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

7. 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

8. 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

9. Shell Programming and Scripting

perl: Read array from a flat file

Hello Guru's I want to read an array into a flatfile Please let me know how to do the same So far this the below code use strict; use warnings; open (my $data , '<', $ARGV)|| die "could not open $ARGV:\n$!"; my @array=(<$data>); my @sorted=sort... (8 Replies)
Discussion started by: Pratik4891
8 Replies

10. Shell Programming and Scripting

Perl string formation from array

HI I ma using perl programming my perl is like this $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) {... (1 Reply)
Discussion started by: ptappeta
1 Replies
SOLRCLIENT(3)								 1							     SOLRCLIENT(3)

The SolrClient class

INTRODUCTION
Used to send requests to a Solr server. Currently, cloning and serialization of SolrClient instances is not supported. CLASS SYNOPSIS
SolrClient final SolrClient Constants o const integer$SolrClient::SEARCH_SERVLET_TYPE1 o const integer$SolrClient::UPDATE_SERVLET_TYPE2 o const integer$SolrClient::THREADS_SERVLET_TYPE4 o const integer$SolrClient::PING_SERVLET_TYPE8 o const integer$SolrClient::TERMS_SERVLET_TYPE16 o const integer$SolrClient::SYSTEM_SERVLET_TYPE32 o const string$SolrClient::DEFAULT_SEARCH_SERVLETselect o const string$SolrClient::DEFAULT_UPDATE_SERVLETupdate o const string$SolrClient::DEFAULT_THREADS_SERVLETadmin/threads o const string$SolrClient::DEFAULT_PING_SERVLETadmin/ping o const string$SolrClient::DEFAULT_TERMS_SERVLETterms o const string$SolrClient::DEFAULT_SYSTEM_SERVLETsystem Methods o public SolrUpdateResponse SolrClient::addDocument (SolrInputDocument $doc, [bool $overwrite = true], [int $commitWithin]) o public void SolrClient::addDocuments (array $docs, [bool $overwrite = true], [int $commitWithin]) o public SolrUpdateResponse SolrClient::commit ([bool $softCommit = false], [bool $waitSearcher = true], [bool $expungeDeletes = false]) o public SolrClient::__construct (array $clientOptions) o public SolrUpdateResponse SolrClient::deleteById (string $id) o public SolrUpdateResponse SolrClient::deleteByIds (array $ids) o public SolrUpdateResponse SolrClient::deleteByQueries (array $queries) o public SolrUpdateResponse SolrClient::deleteByQuery (string $query) o public void SolrClient::__destruct (void ) o public string SolrClient::getDebug (void ) o public array SolrClient::getOptions (void ) o public SolrUpdateResponse SolrClient::optimize ([int $maxSegments = 1], [bool $softCommit = true], [bool $waitSearcher = true]) o public SolrPingResponse SolrClient::ping (void ) o public SolrQueryResponse SolrClient::query (SolrParams $query) o public SolrUpdateResponse SolrClient::request (string $raw_request) o public SolrUpdateResponse SolrClient::rollback (void ) o public void SolrClient::setResponseWriter (string $responseWriter) o public bool SolrClient::setServlet (int $type, string $value) o public void SolrClient::system (void ) o public void SolrClient::threads (void ) PREDEFINED CONSTANTS
o SolrClient::SEARCH_SERVLET_TYPE -Used when updating the search servlet. o SolrClient::UPDATE_SERVLET_TYPE -Used when updating the update servlet. o SolrClient::THREADS_SERVLET_TYPE -Used when updating the threads servlet. o SolrClient::PING_SERVLET_TYPE -Used when updating the ping servlet. o SolrClient::TERMS_SERVLET_TYPE -Used when updating the terms servlet. o SolrClient::SYSTEM_SERVLET_TYPE -Used when retrieving system information from the system servlet. o SolrClient::DEFAULT_SEARCH_SERVLET -This is the intial value for the search servlet. o SolrClient::DEFAULT_UPDATE_SERVLET -This is the intial value for the update servlet. o SolrClient::DEFAULT_THREADS_SERVLET -This is the intial value for the threads servlet. o SolrClient::DEFAULT_PING_SERVLET -This is the intial value for the ping servlet. o SolrClient::DEFAULT_TERMS_SERVLET -This is the intial value for the terms servlet used for the TermsComponent o SolrClient::DEFAULT_SYSTEM_SERVLET -This is the intial value for the system servlet used to obtain Solr Server information PHP Documentation Group SOLRCLIENT(3)
All times are GMT -4. The time now is 10:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy