Hello, I am confused about how to execute 'mass' commands when calling perl code in a shell script. I have around 30,000 DSSP files which I want to process within Perl. This entails creating a Bioperl DSSP object for every DSSP file that I will read. Part of the code (DSSP_output.pl) is as follows:

#!/usr/bin/perl -w use strict; use warnings; use Bio::Structure::SecStr::DSSP::Res; open (DSSPIN, "$ARGV[0]") || die $!; #Create a new DSSP object my $dssp_obj = new Bio::Structure::SecStr::DSSP::Res('-file'=>DSSPIN); # EXAMPLE OF HOW THE OBJECT IS NORMALLY DECLARED #my $dssp_obj = new Bio::Structure::SecStr::DSSP::Res('-file'=>'3bit.d +ssp'); #Get PDB ID and Compound representation for each DSSP file my $pdb_id = $dssp_obj->pdbID(); print "Analysis of PDB:: ". $pdb_id. "\n"; my $cmpd = $dssp_obj->pdbCompound(); print "Representing:: ". $cmpd. "\n"; etc...

My dilemma is as follows: In a shell script, I want to read a list of filenames and execute DSSP_output.pl for each file. I am using in shell this would translate to:

<some loop to read each dssp filename> dssp_output.pl filename.dssp <end loop>

Now how do I read each filename in perl? I can't use STDIN (I think) because I want this running automatically... the way I have written the code, DSSPIN produces the error:

Bareword "DSSPIN" not allowed when "strict subs" in use.

If I try the following:

open (DSSPIN, <>) || die $!; my $dssp_obj = new Bio::Structure::SecStr::DSSP::Res('-file'=>DSSPIN);

Same error. And finally:

@data_from_files = <>; #Create a new DSSP object my $dssp_obj = new Bio::Structure::SecStr::DSSP::Res('-file'=>$data_fr +om_files); Error: Global system @data_from_files, $data_from_files requires expli +cit package name

Apologies for a long post...I'm just badly confused with filehandling! What should I write to read in the DSSP filenames in the perl script? Much obliged!

A very confused InfoSeeker


In reply to Confused when reading Input within Perl and Shell Scripts by InfoSeeker

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.