On Sun, Mar 4, 2012 at 2:34 AM, Shawn H Corey <[email protected]> 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.
#!/usr/bin/env perl
use strict;
use warnings;
use File::Spec;
my $INPUTFILE = $ARGV[0];
my $tex_filename = $INPUTFILE;
my $bib_filename = "/home/lina/texmf/bibtex/bib/biophymd.bib";
my $bib_abbrev_filename ="/home/lina/texmf/bibtex/bib/biophyabbrev.bib";
# 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_bib_filename = File::Spec->catfile($path,"name.bib");
open my $bib_output, '>', $output_bib_filename
or die "Could not open $output_bib_filename:$!\n";
open my $texfile, '<', $tex_filename or die "Can't open ${tex_filename}:$!";
while (my $line = <$texfile>) {
if( $line =~ m/cite\{(\S+)\}/g) {
my $match_entry = $1 ;
print $match_entry,"\n";
}
}
Thanks,
>
>
> --
> Just my 0.00000002 million dollars worth,
> Shawn
>
> Programming is as much about organization and communication
> as it is about coding.
>
> It's Mutual Aid, not fierce competition, that's the dominate
> force of evolution. Of course, anyone who has worked in
> open source already knows this.
>
> --
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> http://learn.perl.org/
>
>
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/