Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Well, the first thing you'll need to do is tell Perl what the relevant files are. The simplest way to do that is to pass it in as a command-line argument. Look for @ARGV in perldoc perlvar for that.

If the files are all in the same directory and there are no other files in the directory (and you don't want to type out 25 separate filenames), you could use a loop on STDIN to receive piped into into your script:

my @filenames; push @filenames, $_ while (<STDIN>); chomp@filenames; use Data::Dumper; print Dumper(@filenames);

That way, you can get all your filenames into your script by simply doing:

ls | my_script.pl

As for actually opening each file for reading, you've already done that. What's confusing about reading the files? Have you checked perldoc -f open?

As for hashes, they're pretty simple:

my %hash; # Declare your hash. $hash{$key} = $sequence; # Assign $sequence to the hash with key $key. my $sequence_im_looking_for = $hash{$key}; # Get the sequence by looki +ng it up with its key $key.

It looks like you'll be alternating lines; line1 is the key for the sequence in line2, line3 is the key for the sequence in line4, etc.


In reply to Re^3: reading files in directory by Riales
in thread reading files in directory by anonym

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-25 06:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found