Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Appending!

Posted on 2000-05-16
8
Medium Priority
?
299 Views
Last Modified: 2010-03-05
Hi all,
Just a little query today! Can someone tell me what I need to add to the following code so that when the user types in y the file that's been dealt with will be appended to a new file called corpus......

Thanks a mil.!

print "Would you like to include this text in your corpus (Y/N)?\n";
     chomp ($string = <STDIN>);
                     if (uc($string) eq "Y")
                       
0
Comment
Question by:shels
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 16

Accepted Solution

by:
maneshr earned 240 total points
ID: 2814470
lets assume the file whose info needs to be appended is called sub.txt.


here is the code that will do what you require.

#!/usr/bin/perl

$corpus="/tmp/corpus.txt";
$sub="/tmp/sub.txt";
print "Would you like to include this text in your corpus (Y/N)?\n";
chomp ($string = <STDIN>);

if ($string=~ /^y$/i){
  open (CORP,">>$corpus") || die $!;  ##  Open corpus file in append mode

  undef $/;
  open (SUB,"$sub") || die $!;  ##  Open the other file for reading
  $var=<SUB>; ##  Read entire file in a variable;
  close(SUB);
  $/="\n";

  print CORP $var;  ##  Write the info to the end of corpus!!
  close(CORP);

}
0
 
LVL 84

Expert Comment

by:ozo
ID: 2814814
#or
print CORP <SUB>;
0
 

Author Comment

by:shels
ID: 2816828
Thanks for your help guys my program seems to be running fine, the only problem is when I open the corpus.txt file after running the program nothing has been appended to it!!!  Would you know why???  I can post the program if you need to see the code
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:shels
ID: 2817064
Thanks for your help guys my program seems to be running fine, the only problem is when I open the corpus.txt file after running the program nothing has been appended to it!!!  Would you know why???  I can post the program if you need to see the code
0
 

Author Comment

by:shels
ID: 2817067
Adjusted points from 50 to 60
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2817452
shels,

pl. post you code, so that i can look at it and maybe provide you with a final working solution.

Rgds
0
 

Author Comment

by:shels
ID: 2817693
Hi Maneshr!
I got it working so there's no need, but thanks very much anyway, you were a great help!  
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2818426
cool!!

Regards.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question