Dear monks, I am using php for making an webserver. since i know a little of perl compared to PHP, the values which is on the php page is passed to a perl program. To make things easier, i am using unix system command. For example, to search an input ID, i use unix grep command. Since, i also need the sequence of the given ID, my program looks like this.
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");
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.
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
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.

In reply to system command and formatting by sugar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.