perl code


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl code
# 1  
Old 09-07-2011
perl code

Hi

Please read the below information carefully and help me to solve the issue .

I want to know ,how to catch the word before perticular word using perl code??

Eg:

if the row contains

===========================

Original Order Tuple

Duplicatel Execution Tuple

=============================

see below code-

Code:
   /Value of field name ([^,]+),Original (\w+) Tuple/ and do {
     ($category, $type) = ($1, $2);

in above code first it finds Original word and on the basis of Original it catches the Order and execution word in $type

insted of this i want to first catch Tuple and on the basis of Tuple word i want to figure out wheather it is is order or execution

How it is possible???


Thanks in advance

Last edited by vbe; 09-07-2011 at 11:18 AM.. Reason: code tags instead of quotes
# 2  
Old 09-07-2011
Quote:
Originally Posted by pspriyanka
...
Please read the below information carefully and help me to solve the issue .

I want to know ,how to catch the word before perticular word using perl code??

Eg:

if the row contains

===========================

Original Order Tuple

Duplicatel Execution Tuple

=============================

see below code-

Code:
   /Value of field name ([^,]+),Original (\w+) Tuple/ and do {
     ($category, $type) = ($1, $2);

in above code first it finds Original word and on the basis of Original it catches the Order and execution word in $type

insted of this i want to first catch Tuple and on the basis of Tuple word i want to figure out wheather it is is order or execution

How it is possible???
...
Your sample code does not correspond to your sample data.
The regex of your sample code will not match the sample data because the literal characters "Value of field name" are not present in your data.

Try something like this:

Code:
$
$
$ cat f14
Original Order Tuple
Duplicatel Execution Tuple
$
$
$ perl -lne 'print "The word right before \"Tuple\" is \"$1\"" if /.*\b(\w+) Tuple$/' f14
The word right before "Tuple" is "Order"
The word right before "Tuple" is "Execution"
$
$

tyler_durden
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl code help

i'm using the below perl code to get a list of ips: my @allipsfound ; for my $elem (@gatches) { my ($ip) = split ":",$elem; print "$ip \n"; } it spits out several lines of ips. most of those ips are the same. how do i do sort and uniq in the above code to make it so that it only... (3 Replies)
Discussion started by: SkySmart
3 Replies

2. Programming

Perl -- code

Hi All, I new to perl scripting, trying to write a program to get multiple inputs from the users and it should be stored in one variable. can some one help me with it . here is the sample code i tried , but its not working. # cat array.pl #!/usr/bin/perl print "enter the total no of... (4 Replies)
Discussion started by: nanduri
4 Replies

3. Shell Programming and Scripting

perl code

What is the meaning of below code, which is capturing from one file . $runDate = $1 if $str =~ m/,"TransactTime":"({10})/; # get transaction date as run date Is it the date from the first line of file or last line of file??? (Note:Each line from the file contains date) (2 Replies)
Discussion started by: aish11
2 Replies

4. Shell Programming and Scripting

perl code

Perl code to get the diff of the two baselines in clearcase ? (2 Replies)
Discussion started by: saku
2 Replies

5. Programming

Perl- How to catch the file in perl code?

Hi, plz see the below code , i have catch the file "Orders.20110714.out "file as a Orders*.out. but it giving me an error .it does not open the file. if the same thing i have done by code code-> ls Orders*.out then it gives me the output Orders.20110714.out i am trying apply the... (1 Reply)
Discussion started by: pspriyanka
1 Replies

6. Shell Programming and Scripting

perl: a way to see a sub code in debug mode: perl -de 0 ?

Is there a way to see or print a sub code? Sometime a sub could be already defined, but in the debug mode (so, interactively) it could be already out of screen. So, I would think about a way to check if the sub is defined (just 'defined' is not a problem) and how it is defined. Also, if... (4 Replies)
Discussion started by: alex_5161
4 Replies

7. Shell Programming and Scripting

PERL Code

I have a code block ... $cmd = "find $audit_dir -mtime +$days_to_keep -exec rm {} \\;"; unless(open(CMD, "$cmd |")){ $msg = "Error command : $cmd \n\n"; print_log $lgh,"$msg",1; exit 1; } print_log $lgh, "Deleting... (2 Replies)
Discussion started by: talashil
2 Replies

8. Shell Programming and Scripting

need help to write perl code

I have 2 files , one is master file and another file i am genearting which contains Number of fails for all host & version. The first file is master file which contains 2 column, Test Case name and Product Name: daily/DB/attach/attach_redundancy.exp: YRS daily/DB/help/help.exp: ... (0 Replies)
Discussion started by: getdpg
0 Replies

9. UNIX for Dummies Questions & Answers

perl code help

if anyone knows how to do the loop and the function listed, please let me know it would be a great help. Thanks! •Create an array NUM with the following ten values in it: 14, 25.6, 43, 22, 412.14, 819, 2, 721, 7.218, 11.9 •Print the array NUM •Create an array COLOR with the following... (1 Reply)
Discussion started by: circleW
1 Replies

10. Shell Programming and Scripting

Perl running C code

Ok, I am thinking about developing a small little web app to help teach C to people. So you can type some C code into a text area, then a CGI Perl script or something similar would compile the code, then possibly execute it showing the results in another text area. My concern of course is... (1 Reply)
Discussion started by: gdboling
1 Replies
Login or Register to Ask a Question