develooper Front page | perl.beginners | Postings from March 2012

Re: write to the file whose basename is argv[0]

Thread Previous | Thread Next
From:
Rob Dixon
Date:
March 4, 2012 02:21
Subject:
Re: write to the file whose basename is argv[0]
Message ID:
4F534222.9080603@gmx.com
On 04/03/2012 09:24, lina wrote:
> On Sun, Mar 4, 2012 at 2:34 AM, Shawn H Corey<shawnhcorey@gmail.com>  wrote:
>> On 12-03-03 11:37 AM, lina wrote:
>>>
>>> my $tex_filename = $ARGV[0] ;
>>
>>
>> # for catfile()
>> use File::Spec;
>>
>> # divide the input file name into its path and name,
>> # ignore its extension
>> my ( $name, $path ) = fileparse( $tex_filename, qr/\.[^\.]+$/ );
>>
>> # create a new name with .bib extension
>> my $output_text_filename = File::Spec->catfile( $path, "$name.bib" );
>>
>> # open the file
>> open my $bib_output, '>', $output_text_filename
>>     or die "could not open $output_text_filename: $!\n";
>>
>> # etc...
>
> $ perl extract_v2.pl try.tex
> Undefined subroutine&main::fileparse called at extract_v2.pl line 16.

The fileparse function is in File::Basename, so you need to add

   use File::Basename;

before you can use Shawn's code.

Rob

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About