[EMAIL PROTECTED] wrote: > Help a perl newbie coding for a bioinfo guy please. > > I have a shell script that contains the following code > > # $1=sequence_file, $2=input_file, $3=output file, $4=chain. > > if [ $# != 4 ] > then > echo "Usage: parse_pdb.sh sequence_file pdb_file output_file > chain" exit > fi > > TEMP_FILE=$$; > #basename $2 >> $3 > > grep ^HELIX $2|sed 's/\ \ */\ /g'|cut -d" " -f1,5,6,9 >$TEMP_FILE > grep ^SHEET $2|sed 's/\ \ */\ /g'|cut -d" " -f1,6,7,10 >>$TEMP_FILE > > parse_pdb.pl $1 $TEMP_FILE $3 > > rm $TEMP_FILE > > I have to write a cgi-perl script which takes the same inputs as the > shell script and pass them to the parse_pdb.pl script. For that I have > to replicate the grep command. How can I do that using perl ? > Ofcourse I dont have to use the shell script now.
If I was writing the shell script, I would have used awk (or Perl!). This guy maybe didn't know awk so he used grep, sed, and cut. Suppose you've opened the input file in your CGI script as handle IN and an output file corresponding to TEMP_FILE above as handle OUT. A loop to do what the grep/sed/cut business above is doing would look something like: while (<IN>) { my @F = split; print OUT "@F[0,4,5,8]\n" if /^HELIX/; print OUT "@F[0,5,7,9]\n" if /^SHEET/; } Is that what you're after? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>