Tagged Questions
1
vote
3answers
39 views
Finding a particular value in an HTTP response using Perl
I have a little script in Perl, HTTP POST request
my $request = $ua->post( $url, [ 'country' => 10, 'evalprice' => 0 ] );
my $response = $request->content;
Now I know that in the ...
0
votes
2answers
53 views
Perl - assigning a composite string to a variable
I would like to assign the whole string on the right to the variable on the left
my $branch = "\t" x $level, "$level -> $treeRoot\n";
Where $level is a number and $treeRoot is a string. When I ...
-1
votes
3answers
64 views
Best way to extract string between underscores using Perl
I have something like:
$string = '/mfsi_rpt/files/mfsi/reports/bval/bval_parlcont_pck_m_20130430.pdf';
I would like to extract the parlcont from the string (the word between the 2nd and 3rd ...
1
vote
2answers
41 views
how can I split file into newlines using a delimiter?
Hi I have the following file:
>AKJDHDLFNLDNFLNFRFMD
>ALKSJLDKJSAD
>GLHGFNHHOTHJRTKHRNLGKNFKGNHGKHMNFGH
and I want to split this file by the '>' symbol to obtain:
>
AKJDHDLFNLDNFLNFRFMD
...
1
vote
3answers
44 views
Extract e-mail addresses if they contain certain strings with Perl
I have a big text file which is a list of e-mails (each followed by a /n).
I would like to run a perl command to make files with different lists based on whether the e-mail contains a certain string.
...
0
votes
2answers
76 views
split a string into array in perl
my $line = "file1.gz file1.gz file3.gz";
my @abc = split('',$line);
print "@abc\n";
Expected output:
file1.gz
file2.gz
file3.gz
I want the output to be file1.gz in $abc[0]
and $abc[1] should have ...
0
votes
5answers
116 views
How do we extract parts of a string in Perl?
I am new in Perl. I have a string of this format:
[ timestamp | integer | string ] Some other string here
Sample string:
[ 2013/05/28 21:39:02 | 2212 | MALFUNCTION ] Please check for ...
4
votes
3answers
72 views
is any of array items contained in a string
I have a keywords list and a blacklist.
I want to delete all keywords that contain any of blacklist item.
At the moment Im doing it this way:
my @keywords = ( 'some good keyword', 'some other good ...
0
votes
2answers
52 views
Replacing many words in brackets with a new one
I have the following string :
Cat dog (fox) catepillar bear foxy
I need to replace "cat" and "fox" words from this sentence to word "animal"
use warnings;
use strict;
# declare your vars with 'my' ...
2
votes
2answers
92 views
Perl: How to replace a variable by its value
Suppose, if a table has a column called test and inside test I have written a row as "Dear $name, Hello" where $name is a variable. I need to select this row for which I'm doing
my $test = ...
5
votes
2answers
117 views
Random sampling of non-overlapping substrings of length k
Given a string of length n, how would I (pseudo)randomly sample m substrings of size k such that none of the sampled substrings overlap? Most of my scripting experience is in Perl, but an easy-to-run ...
2
votes
2answers
47 views
what is the difference between the \L and the lc function in Perl?
What is the difference between \L and lc in Perl?
Where are these two applicable?
-2
votes
1answer
44 views
Indexing every occurrence of a key in an array of strings with perl
I have an array of strings @Sentences and I am trying to find the best way to index each occurrence of every word with respect to the line number they are on. I thought to do this with a nested for ...
1
vote
2answers
55 views
Perl - Process string with IDs and corresponding values in quotation marks
I'm working on a Perl project where i have a lot of strings containing ids and corresponding values in quotation marks, seperated by semicolons.
Example: main_id "1234567"; second_id "My_ID"; name ...
-3
votes
2answers
62 views
Perl - searching for partial matches in string array and returning matching indices
Suppose I have a string array @file_paths which contains
@file_paths= ["C:\Lazy\FolderA\test.cpp", "C:\Lazy\FolderA\test2.cpp",
"C:\Lazy\FolderB\test.cpp", ...