My doubts: Why am i not able to store the exec command in a scalar or array variable and then print it. It doesnt work that way, and it works only if i print it directly. I need to save it to a variable because, i need to split the sequence line into 5 characters per line.file name1:seq.txt ------------------- >ID_101 AGCTGAGTAGACTGA >ID_102 CGATGCTAGCTAGCTACAT >ID_103 ATCTTATCTTTTTATACC file name2:seq_updated.txt -------------------------- >ID_104 AATAGCTAGAAGGA >ID_105 AGATCGACTGAA >ID_106 ACTAGCTACGATATATTATATATAT my php page: ----------- $foo="ID_106" //ID to be searched. $cmd="perl split.pl $foo"; echo exec($cmd); my perl program: --------------- $bar=$ARGV[0]; print exec("grep -h -A 1 $bar *.txt");
well, am i making things complicated? Can i use unix one liner system command to print 5 characters per line when i grep the ID? Please guide. Thank you.what i was planning to do with the variable is this: ---------------------------------------------------- foreach $str(@array){ if($str=~/\w+/){@strs=split(//,$str); for($i=1;$i<=scalar(@strs);$i++){ print "$strs[$i] "; if($i%5==0){print"\n";} } } } } this is how my webpage result should look like: ----------------------------------------------- >ID_106 ACTAG CTACG ATATA TTATA TATAT
In reply to system command and formatting by sugar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |