Visit Our UNIX and Linux User Community


"execution problem with perl"


 
Thread Tools Search this Thread
Top Forums Programming "execution problem with perl"
# 1  
Old 07-06-2011
Bug "execution problem with perl"

hi everyone,

before stating my problem ,
i just want to say
thanks in advance for the time and trouble taken:-)

i am an newbie to perl programming,
the problem is a text file needed to be parsed,
i have looked over regular expressions and string matching but coudnt helped out..
the text file contained the format:-
Code:
A,1,B
A,2,B
A,1,C
C,1_1,A
B,2,D
B,1_1,A
B,2_2,A
B,2_2,D


after doing the required parser, the output must be in the following format shown below
Code:
A,1,B
B,1_1,A
A,2,B
B,2_2,A
A,1,C
C,1_1,A
B,2,D
D,2_2,D

can anyone let me know how to get the above required format?

thanks
raghuraipur

Last edited by Franklin52; 07-06-2011 at 10:44 AM.. Reason: Please use code tags for code and data samples, thank you
# 2  
Old 07-06-2011
Is there any logic behind the ordering in the input and output? Sorry, I don't see it... you might wanna be more specific -- you'll improve your chances of getting the help you need.
What features are you trying to parse upon?
# 3  
Old 07-06-2011
thanks for replying mirni,

there is no logic in order, of input...
let us assume
A-source
1-message
B-destination..

so whenever we parse message, eg-1;
it should print all the messages passing between sources and destination..
after getting parsed ,it should print reponses from the destination
for eg-
if A,1,B is first line then,
B,1_1,A
should immediately follow after the first line,
and hence there is some logic in getting the output
it is something like, B is sending some response ACK for the message 1 to A

and same follows to other inputs..
input file
A,1,B A,2,B A,1,C C,1_1,A B,2,D B,1_1,A B,2_2,A B,2_2,Dafter parsing
A,1,B B,1_1,A
A,1,C C,1_1,A
A,2,B B,2_2,A B,2,D D,2_2,Dthis is the required output:-)Smilie

thanks and regards
raghuraipur
# 4  
Old 07-06-2011
OK... I think I'm starting to understand. You just need to reshuffle the lines so that the A-msg-B is followed by B-msg_msg-A.

Try this. Not super efficient, but should work:
Code:
IFS=',' 
while read src msg dst ; do 
  [[ $msg =~ _ ]] && continue 
  echo $src,$msg,$dst 
  grep "${dst},${msg}_${msg},${src}" responses.txt
done < responses.txt

where responses.txt is your input file
# 5  
Old 07-07-2011
hi mirni,

thanks for that,
but my task is being assigned to be deal with perl, scripting..
could you help oout for the same..

thanks in advance
raghuraipur

Previous Thread | Next Thread
Test Your Knowledge in Computers #772
Difficulty: Medium
An arcade system board is a dedicated computer system created for the purpose of running video arcade games.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

3. Shell Programming and Scripting

Problem of Perl's "join" function

$ perl -e '@f=("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","1","911"); print join("\t",@f)."\n";' aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ... (5 Replies)
Discussion started by: carloszhang
5 Replies

4. Shell Programming and Scripting

Problem using "system" command in perl

Hello!!! I'm trying to pass the output from bash command to perl variable in a perl script, and I used the "system" command to execute the bash statment and pass the result to perl string variable, in this perl script I used a variable $file that store data for using it as a regular expression.... (2 Replies)
Discussion started by: evolabo
2 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

"Execution problem". Getting error without sending e-mail

Hi, This is the end of the script. When i try to execute the script, i am getting the error. Please help me as to what is wrong with this script.? elif echo 'Load Failed -- Return Code =' $rc subject="Consent table load failed" ( echo "The log file is attached to... (1 Reply)
Discussion started by: msrahman
1 Replies

7. UNIX for Advanced & Expert Users

A question/problem about oracle "tns listener" and "enterprise manager"

hi, I have a problem about the Oracle related components. I'm not able to find any answer yet, and waiting for your responses... Here is the configuration of my system: * an IBM P550 machine, * an AIX 5.3 running on it and * an oracle database, already installed on it. The problem (or... (1 Reply)
Discussion started by: talipk
1 Replies

8. UNIX and Linux Applications

A question/problem about oracle "tns listener" and "enterprise manager"

hi, I have * an IBM P550 machine, * an AIX 5.3 running on it and * an oracle database, already installed on it. The problem (or question of my own) is: Oracle tns listener, "CT_LISTENER", and the enterprise manager (EM) of the instance, which is uniq instance and called... (0 Replies)
Discussion started by: talipk
0 Replies

9. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

Featured Tech Videos