Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > new to perl

Reply
Thread Tools

new to perl

 
 
MES
Guest
Posts: n/a
 
      09-02-2004
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!
 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      09-03-2004
MES wrote:
> 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


 
Reply With Quote
 
 
 
 
Joe Smith
Guest
Posts: n/a
 
      09-03-2004
MES wrote:

> $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
 
Reply With Quote
 
 
 
Reply

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
FAQ 2.17 What is perl.com? Perl Mongers? pm.org? perl.org? cpan.org? PerlFAQ Server Perl Misc 0 04-04-2011 10:00 PM
FAQ 1.4 What are Perl 4, Perl 5, or Perl 6? PerlFAQ Server Perl Misc 0 02-27-2011 11:00 PM
FAQ 2.17 What is perl.com? Perl Mongers? pm.org? perl.org? cpan.org? PerlFAQ Server Perl Misc 0 02-03-2011 11:00 AM
FAQ 1.4 What are Perl 4, Perl 5, or Perl 6? PerlFAQ Server Perl Misc 0 01-23-2011 05:00 AM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM



Advertisments