Dear Monks,
I have 2 files and I want to open them and print the first line of the first line, then <tab> and then the first line of the second file, and so on...
I tried the following:
print "Please specify 2 filenames\n";
print "Filename 1:";
my $userfile1=<STDIN>;
chomp($userfile1);
print "Filename 2:";
my $userfile2=<STDIN>;
chomp($userfile2);
open OUT, ">CONCATENATED_FILES";
open (USER1, "<$userfile1") or die "Couldn't open file: $userfile1";
open (USER2, "<$userfile2") or die "Couldn't open file: $userfile2";
while(<USER1>)
{
$line1=$_;
chomp $line1;
print OUT $line1."\t";
while(<USER2>)
{
$line2=$_;
chomp $line2;
print OUT $line2."\n";
}
}
close USER1;
close USER2;
close OUT;
but without success...What am I doing wrong?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.