Thank you for your suggestions. I have incorporated a number of them into my program, as well as made it more streamlined. However, my problem still remains. I need to print the data from @signal into consecutive columns, as shown in my post at the end of the thread. The only way I know how to make this managable is to take the data pushed into @signal, grep it, and then shove it into 5 separate arrays (there are 5 input files CURRENTLY). This is all well and good, except that I need to somehow make this program capable of handling different numbers of files each time it is run. Do I need to manually assign, say 30, arrays in which to put the data, placing a limit on the program? I'm sure there are better ways to do this, but I don't know how.
NOTE: please be patient with me, as I'm only a beginning programmer, perl being my first language. Having only been working with it for a month now, I suppose I could be doing worse...:-)
My latest code:
#! usr/local/bin/perl -w use Cwd; use IO::Dir; use IO::File; print STDOUT "Please enter the name and location of the directory to p +arse\:\n"; chomp (my $directory=<STDIN>); open (OUTPUTFILE,">junk.txt"); my $dh = IO::Dir->new($directory) || die "Cannot open directory '$dire +ctory': $!\n"; my @filenames; push @filenames, $_ for map { "$directory/$_" } grep !/^\.\.?/, $dh->r +ead; $dh->close; @output=get_signal; for (@output){ @{$signal[0-4]}; @{$rprobe};} print OUTPUTFILE "@signal"; close OUTPUTFILE; exit; sub get_signal { while (@filename) { $file=shift @filename; use Cwd 'chdir'; chdir "./data"; open (FILE, "$file") or die; @data=<FILE>; my $i=0; foreach (@data) { next while $i++ <=14; push @signal, (split(/\t/))[3];} my $g=0; foreach (@data) { next while $g++ <=14; @probe=(split(/\t/))[0];} $hash{$file}=\@signal; close (FILE); } @values=values(%hash); $rprobe=\@probe; return @values; return $rprobe; }
Bioinformatics

In reply to Re: Re: Unique Variable names... by bioinformatics
in thread Unique Variable names... by bioinformatics

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.