Anirban Adhikary wrote: > Dear List > I have a source file as follows > hello how are you? > hello how are you? > What language did you want to use? > What language did you want to use? > I am here > You are there > this is my first perl script > What language did you want to use? > #################################################### > I want to write a script which will take a single line from the filehandel > and print the line without any space between words of that line > I have written a code as follows( I can achieve this by using an array but I > don't want to use an array) > > > use strict; > use warnings; > > my $fname="/home/anadhikary/perl/file1.txt"; > open my $FH,'<',$fname; > while(<$FH>) > { > my ($line)=split(/\s+/,$_); > print $line."\n"; > } > close($FH); > > But this code prints only the first words of every line.... > Where I am making the mistake???
First you have a text file that you want to check and print only distinct lines to a new file. Now you have exactly the same file and you want to remove the spaces from between words in its records. Forgive my cynicism, but that doesn't sound like a real-world requirement to me and I think you are asking us to solve homework assignments for you. By all means if you have tried your best and are completely stuck then come here for a hint or two, but do please come clean and explain where you are getting these questions from. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/