One a file and save the contents in another file?

Heres the file And the data is being Parsed but the output is not beign stored in the file... Could someone please help?

The code should take out all the stop words and then store rest of the data in a  url.parse.
I and see the result on the sommand prompt but not in the file....


#!/usr/bin/perl

open KW, 'stop_words';
@kw = map {chop;$_} <KW>;
close KW;

#form RE

$re = join '\b)|(\b','(\b', @kw,'\b)';

open TXT,'test.out';
while(<TXT>){
  s/$re//goi;
  $content= print $_;
}

print $content;
cp_to_file($content, "url.parse");
print "\n\n\n";
# copies text to file

sub cp_to_file {
    my ($text, $to_file) = @_;

    open(OUT, ">" . $to_file);
    print OUT $text;
    close(OUT);
}
sdesarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lorentgCommented:
1 point?
0
ozoCommented:
#perhaps you meant to say
$content .= $_;
#instead of
$content= print $_;
0
sdesarAuthor Commented:
Thanks OZO....

Your suggestion worked as always... however... I am getting a bunch of  
11111111111111111
at the end of file...

What could I do to get rid of those  1s?


0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

sdesarAuthor Commented:
this is what I did on the command line --
$perl  parse2file

The words are parsed correctly but the data appears on the command line and the output file
url.parse only has a bunch of 11111111111s


The input file is test.out
the output file is url.parse


What wrong?
0
ozoCommented:
What did you change?
It sounds like you may have done something like

while(<TXT>){
  s/$re//goi;
  $content .= print $_;
}

instead of

while(<TXT>){
  s/$re//goi;
  $content .= $_;
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sdesarAuthor Commented:
Thanks OZO ...for all your help...

I want to give you excellent points for your work.

However, there seems to be a bug and points will go to someone else... i have reported it to EE.
I hope to hear from them soon.


0
sdesarAuthor Commented:
Thanks OZO!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.