new to perl

Discussion in 'Perl Misc' started by MES, Sep 2, 2004.

  1. MES

    MES Guest

    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!
     
    MES, Sep 2, 2004
    #1
    1. Advertising

  2. 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
     
    Jürgen Exner, Sep 3, 2004
    #2
    1. Advertising

  3. MES

    Joe Smith Guest

    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
     
    Joe Smith, Sep 3, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dpackwood
    Replies:
    3
    Views:
    1,861
  2. PerlFAQ Server

    FAQ 1.4 What are Perl 4, Perl 5, or Perl 6?

    PerlFAQ Server, Jan 23, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    331
    PerlFAQ Server
    Jan 23, 2011
  3. PerlFAQ Server
    Replies:
    0
    Views:
    724
    PerlFAQ Server
    Feb 3, 2011
  4. PerlFAQ Server

    FAQ 1.4 What are Perl 4, Perl 5, or Perl 6?

    PerlFAQ Server, Feb 27, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    322
    PerlFAQ Server
    Feb 27, 2011
  5. Replies:
    2
    Views:
    509
    Thomas 'PointedEars' Lahn
    Mar 11, 2008
Loading...

Share This Page