LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-01-2011, 09:13 PM   #1
Quest ion
Member
 
Registered: Oct 2011
Posts: 45

Rep: Reputation: Disabled
perl scripting question


How would I display interleaved output of two files, like for instance,

$cat file1 file2
file1-line1
file1-line2
file1-line3
file2*line1
file2*line2

the output of exectuting inter2files is

$./inter2files.pl file1 file2
file1-line1
file2*line1
file1-line2
file2*line2
file1-line3


I understand this is an extremely challenging question and most people probably would hav a very hard time with it (myself included) but was hoping someone would be able to help me out on this one as thus far I've tried alot on this one but am currently stumped, any help would be much appreciated!
 
Old 12-01-2011, 11:02 PM   #2
Quest ion
Member
 
Registered: Oct 2011
Posts: 45

Original Poster
Rep: Reputation: Disabled
Can someone please help, this is kind of urgent, I worked on this for a long time and really need some help tonight, I'm sure some of the so called "experts" here are busy masterbating to old pics of Steve Jobbs from the 1980's, but the actual skilled people's help would be greatly appreciated! TY!
 
0 members found this post helpful.
Old 12-01-2011, 11:19 PM   #3
timetraveler
Member
 
Registered: Apr 2010
Posts: 243
Blog Entries: 2

Rep: Reputation: 31
Did you try? What did you come up with? You gotta show, at least, you tried.
 
Old 12-01-2011, 11:24 PM   #4
Quest ion
Member
 
Registered: Oct 2011
Posts: 45

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by timetraveler View Post
Did you try? What did you come up with? You gotta show, at least, you tried.
Here's what I cam up with asshole, problem solved.


$f1=$ARGV[0];
$f2=$ARGV[1];
$ef1=0;
$ef2=0;
open $fh1,"$f1";
open $fh2,"$f2";
while ($ef1==0 and $ef2==0)
{
if ($l1=<$fh1>)
{
print "$l1\n";
}
else
{ $ef1=1; }
if ($l2=<$fh2>)
{ print "$l2\n";}
else {$ef2=1;}
}
 
0 members found this post helpful.
Old 12-02-2011, 03:39 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Quest ion, please refrain from being obnoxious and rude, or you won't find yourself being a member of LQ.org for much longer. Thanks.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl scripting question Quest ion Programming 10 11-13-2013 09:56 AM
[SOLVED] Perl scripting question zeratul111 Linux - General 4 10-13-2010 03:53 PM
Perl Scripting magin Programming 9 04-24-2007 08:40 AM
question about perl scripting feetyouwell Linux - Software 2 02-13-2004 03:11 PM
Perl scripting Rameriez Programming 4 02-03-2003 01:01 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration