what im trying to do is open a file and use the join function to join them togeter and then use that to ovverright the file names.
the file names just has
Jacob
Michael
Joshua
Matthew
this is what i have so far
#!/usr/bin/perl -w
open (GOOD, '<names');
@myNames = (<GOOD>);
#print "@myNames\n";
#exit;
$hio = join(',', @myNames);
print "$hio";
print(<GOOD>) "$hio" or die "couldnt print and join";
close (GOOD);
the problem is in the line with
print(<GOOD>) "$hio" or die "couldnt print and join";
[edited by: phranque at 10:11 pm (utc) on July 25, 2008]
[edit reason] disabled smileys ;) [/edit]
this is what i have so far
#!/usr/bin/perl -wopen (GOOD, '<names'); <-- FILE OPENED FOR READING ONLY
@myNames = (<GOOD>); <-- READS TO THE END OF THE FILE AND STORES ALL THE LINES IN THE ARRAY. THE PARENTHESIS ARE NOT NEEDED.
#print "@myNames\n";
#exit;$hio = join(',', @myNames); <-- JOINS ALL THE LINES WITH A COMMA BUT THERE ARE STILL NEWLINES IN THE LINES SO THE OUTPUT WILL LOOK AKWARD
print "$hio"; <-- PRINTS THE JOINED LINES
print(<GOOD>) "$hio" or die "couldnt print and join"; <-- THIS DOES NOTHING BECAUSE THE FILE POINTER IS AT THE END OF THE FILE SO THERE IS NOTHING LEFT TO READ. IT DOES NOT PRINT TO THE FILE WHICH WAS OPENED FOR READING ONLY ANYWAY.
close (GOOD);
[edited by: phranque at 12:16 am (utc) on July 26, 2008]
[edit reason] disabled smileys ;) [/edit]
oops, that will not work. Should be:print GOOD "here is what you want to print" or die "blah blah blah";
The parenthesis will throw a syntax error.
good catch, perl_diver!
it probably wouldn't hurt to put the error number in the error message:
print GOOD "here is what you want to print" or die "$!: blah blah blah";
lets say i have this in a .txt file
>YCR008W SAT4 SGDID:S000000601, Verified ORF
ATGACTGGTATGAATGATAATAATGCCGCTATTCCTCAGCAAACTCCAAGGAAA
>YCR090C SGDID:S000000686, Uncharacterized ORF
ATGCCGTTATTTTTGGTTCTGAAAGCAACATTATCAGAAAACGT
>YCR008W SAT4D SGDID:dupe1, Verified ORF
ATGACTGGTATGAATGATAATAATGCCGCTAT
what im trying to do is find a way to get the lines that end in Verified ORF and the line after it
sorry for wasting your time with the join function.
while (my $line = <FILE>) {
chomp $line;
if ($line =~ /Verified ORF$/) {
my $next_line = <FILE>;
push @lines, "$line $next_line";
}
}
Or some variation thereof.
[edited by: phranque at 11:11 pm (utc) on July 29, 2008]
[edit reason] disabled smileys ;) [/edit]