Re: Newbe needs help

2003-12-06 Thread sadman
Tim Johnson wrote:

I would recommend getting a strong grasp of Perl before you start trying to
make one-liners for problems like this, since you can end up making a simple
problem much more complicated.  What's wrong with this:


use strict;
use warnings;
open(OUTFILE,script1) || die Couldn't open script1 for writing!\n;
print OUTFILE ddd\n;
close OUTFILE;


-Original Message-
From: sadman [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 28, 2003 2:56 PM
To: [EMAIL PROTECTED]
Subject: Newbe needs help

Hi all can anyone help with a direct command line syntax for the following
im trying to add text to the end of the last line in a text file like so
aaa
bbb
ccc
Wishing to add ddd on the end of this list.
I have tried the following but it doesnt have quite the desired effect 
any help would be good.

perl -pi -e s/'$'/'ddd'/g script1

This gives me this

aaaddd
dddbbbddd
dddcccddd
dd
ddd


 

Hi Tim
 i have lert a few basics but still im stuck on a 
problem ;-( maybe you could help.
Using the code yyou sent me it will add the exact text stated at the 
bottom of the file it opens.
What i need to do now is instaed of having the text in the code, have it 
open up another txt file read the whole txt file and then add all the 
text from that said file to the end of the outfile, im sure this is 
simple but ive obviously missed something somewere ;-(
any help would be great
Thanks
sadman



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Newbe needs help

2003-12-06 Thread drieux
On Dec 5, 2003, at 11:20 PM, sadman wrote:
[..]
i have lert a few basics but still im stuck on a problem ;-(
[..]
What i need to do now is instaed of having the text in the code,
have it open up another txt file read the whole txt file and then
add all the text from that said file to the end of the outfile,
im sure this is simple but ive obviously missed something somewere ;-(
Now we are moving into the land of choices.

we need an input file, and an output file
to append it to???
say something like

	cat inputfile  outputfile

???
but in perl in the form
	append_file inputfile outputfile


my ($input_file , $output_file)  = @ARGV;
open(IN, $input_file) or die problem with inputfile: $!\n;
open(OUT, $output_file) or die problem with output_file: $!\n;

print OUT $_ while(IN);

close(IN);
close(OUT);


ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Newbe needs help

2003-10-28 Thread sadman
Hi all can anyone help with a direct command line syntax for the following
im trying to add text to the end of the last line in a text file like so
aaa
bbb
ccc
Wishing to add ddd on the end of this list.
I have tried the following but it doesnt have quite the desired effect 
any help would be good.

perl -pi -e s/'$'/'ddd'/g script1

This gives me this

aaaddd
dddbbbddd
dddcccddd
dd
ddd


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Newbe needs help

2003-10-28 Thread Tim Johnson

I would recommend getting a strong grasp of Perl before you start trying to
make one-liners for problems like this, since you can end up making a simple
problem much more complicated.  What's wrong with this:



use strict;
use warnings;
open(OUTFILE,script1) || die Couldn't open script1 for writing!\n;
print OUTFILE ddd\n;
close OUTFILE;



-Original Message-
From: sadman [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 28, 2003 2:56 PM
To: [EMAIL PROTECTED]
Subject: Newbe needs help


Hi all can anyone help with a direct command line syntax for the following
im trying to add text to the end of the last line in a text file like so

aaa
bbb
ccc


Wishing to add ddd on the end of this list.
 I have tried the following but it doesnt have quite the desired effect 
any help would be good.

perl -pi -e s/'$'/'ddd'/g script1

This gives me this


aaaddd
dddbbbddd
dddcccddd
dd
ddd



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]