Use of "Command line perl" in perl script using system command.
Hi,
I have not getting result, so I am describing my problem in deep. ================================================================= MY QUERY : >HUMAN1 ||elongation factor 2|HUMANA 43|||Manual >HUMAN2 |||elongation factor 5|HUMANA 87|||Manual >HUMAN3 |elongation factor 1|HUMANA 68|||Manual . . . . AND SO ON... I WANT : elongation factor 2 elongation factor 5 elongation factor 1 ================================================================= MY PERL SCRIPT : print "enter yr keyword \n"; $ok1=<stdin>; chomp($ok1); system("grep '^>' ".$ok1.".txt >".$ok1."_head.txt"); #[ NOTE :(Above system part is working for 'grep' command and i am getting result in # ".$ok1."_head.txt"). ] my $x=qw(perl -na -F'/\|+/' -e 'print "$F[1]\n"' ".$ok1."_head.txt" >".$ok1."6.txt"); system($x); # [ NOTE : this will create a file ".$ok1."6.txt" But it is empty, it means that it # is not working ] Would anyone help me? |
Either "escape" the + sign or do it like this
`perl -na -F'/\|+/' -e 'print \"$F[1]\n\"' a1.txt >a2.txt"` or my $x=qw(perl -na -F'/\|+/' -e 'print \"$F[1]\n\"' a1.txt >a2.txt); system($x); or system("perl -na -F'/\|\+/' -e 'print \"$F[1]\n\"' a1.txt >a2.txt"); |
Reply to SethsdadtheLinuxer
Hi, SethsdadtheLinuxer
I have tried your 3 options, but I am not getting answer, thats why I have described my QUERY in deep. I think now you can understand it properly. |
I'm not sure exactly what you're trying to do, but if you want to extract the "elongation factor 2" type fields out of the ok1.txt file, then you could just use the split command (error trapping not included).
Code:
open INPUT, "ok1.txt"; |
Reply to "speck"
Hi, speck
Thank you for your reply. I am getting your point, but I want to SOLVE THE PROBLEM using command line option only. You have given "\|+" option for solution that I have used in perl program, but Its not working in "COMMAND LINE" option. Regards, Naman |
All times are GMT -5. The time now is 05:51 PM. |