new to perl

M

MES

I have a quick question - I have a script that reads .txt files and
from the file creates a file that is emailed to the requestor. I
want the name of the file to be the name of the input file without the
..txt at the end. How can this be done?

Ex:

$file = text.txt

outputfile = "$file .html


My outputfile comes out - test.txt.html

I would like it to be test.html

Can anyone help?

Thanks!
 
J

Jürgen Exner

MES said:
I have a quick question - I have a script that reads .txt files and
from the file creates a file that is emailed to the requestor. I
want the name of the file to be the name of the input file without the
.txt at the end. How can this be done?

Ex:

$file = text.txt

outputfile = "$file .html


My outputfile comes out - test.txt.html

I would like it to be test.html

perldoc -f rename

jue
 
J

Joe Smith

MES said:
$file = text.txt
outputfile = "$file .html

My outputfile comes out - test.txt.html

I would like it to be test.html

Can anyone help?

That is a trivial application of the substitute operator.

($outputfile = $file) =~ s/search_string/replacement_string/;

You should be able to figure out what to put for search_string and
replacement_string.

-Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top