in reply to Re: Confused when reading Input within Perl and Shell Scripts
in thread Confused when reading Input within Perl and Shell Scripts

Thank you. Initially I want to provide a txt file with the filenames, for example, DsspCodes.txt:

2bx2.dssp 3cob.dssp 1nwn.dssp

Based on your comments and my novice use of perl, I have modified the code to:

use strict; use warnings; use Bio::Structure::SecStr::DSSP::Res; my @filenames; for my $filename (@filenames) { open my $dsspIn, '<', $filename or die "Unable to open $filename: $!\n +"; #Create a new DSSP object my $dssp_obj = Bio::Structure::SecStr::DSSP::Res->new ('-file'=> $dssp +In); .... close dsspIn; }

But if call in the commandline:

 DSSP_output.pl DsspCodes.txt

I don't get any errors but I also don't get any output??

Thanks for your patience as I learn this..

InfoSeeker

Replies are listed 'Best First'.
Re^3: Confused when reading Input within Perl and Shell Scripts
by GrandFather (Saint) on Nov 16, 2008 at 23:28 UTC

    Think about how the contents of the external file containing the file names are going to get into the @filenames array. At present your code has nothing to do that. One way would be:

    my $namesFileName = shift; # Get name of the file names file from comm +and line open my $inNames, '<', $namesFileName or die "Unable to open $namesFil +eName: $!\n"; my @filenames = <$inNames>; # Read the file names (one per line) close $inNames; chomp @filenames; # Remove the line end character from each entry ...

    or you could replace the for loop with a while loop and eliminate the array:

    use strict; use warnings; my $namesFileName = shift; # Get name of the file names file from co +mmand line open my $inNames, '<', $namesFileName or die "Unable to open $namesFil +eName: $!\n"; while (<$inNames>) { chomp; # Remove line end character from file name open my $dsspIn, '<', $_ or die "Unable to open $_: $!\n"; ... } close $inNames;

    Perl reduces RSI - it saves typing