Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > simple perl script

Thread Tools

simple perl script

Jerry Maguire
Posts: n/a
I would like to write a perl script to open and file and add a prefix to all
the lines of that file.
The file will be like:


I have created the following script:
cat test |
while read name
printf 'new'$name>>newfile.txt;

Now the problem is it is adding all the lines in one line.
The output is:


Reply With Quote
Posts: n/a
On 18 Aug 2003, Sam Holden wrote:

> Except of course that echo adds a newline by default. And echo \n will
> output "n"... - since \n will be converted to n by most shells, if you
> have a strange shell that doesnt do that then it'll output "\n"
> > In the future, you might want to post in!

> A good idea.

Yeah, I forgot about! But, anyway, it worked ksh! I figured he might
have to tweak it some for his shell. I should had use '-n' option for the
echo command, or I just should left the 'printf' statement in but I
couldn't get it to work for me! 'printf' has a lot more options than
'echo', so I thought I would keep it simple with 'echo'. Thank you for
pointing that out!


-- Removed)
SDF Public Access UNIX System -
Interpreter, n.:
One who enables two persons of different languages to
understand each other by repeating to each what it would have been to
the interpreter's advantage for the other to have said.
-- Ambrose Bierce, "The Devil's Dictionary"

Reply With Quote

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call a simple perl script from HTML without need of HTTPS but simple HTTP ? Wladimir Borsov Perl Misc 4 05-11-2006 09:29 AM
Execute another perl script from my perl script Petterson Mikael Perl Misc 3 01-05-2005 01:31 PM
problem calling perl script from SOAP server perl script pj Perl Misc 3 04-09-2004 10:23 PM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM
How to make Perl Script "POST" call from another Perl Script??? Wet Basement Perl 1 07-15-2003 10:25 PM