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

write to the file whose basename is argv[0]

Thread Next
From:
lina
Date:
March 3, 2012 08:38
Subject:
write to the file whose basename is argv[0]
Message ID:
CAG9cJmm16mBPznPvE3W5eyXDjppnR0ipxKN4+rJAD+k9cYRGgQ@mail.gmail.com
Hi,

I want to output the result into the file shared the same basename but
different extensions,

Below is what I have come up so far:

perl try.tex

#!/usr/bin/env perl

use strict;
use warnings;
use File::Basename;


my $bib_filename = "/home/lina/texmf/bibtex/bib/biophymd.bib";
my $bib_abbrev_filename ="/home/lina/texmf/bibtex/bib/biophyabbrev.bib"

open my $bib_abbrev, '<', $bib_abbrev_filename

my $bib_output, '>', "basename($ARGV[0]).bib"

### here the ARGV[0] is try.tex, so the output filename is try.bib.

my %dict;


my $tex_filename = $ARGV[0] ;

open my $file, '<', $tex_filename or die "Can't open $tex_filename:$!";

while (my $line = <$file>) {
	if($line =~ m/cite\{(\S+)\}/g) {
	print $1,"\n";
	}
}

Thanks for your time,

Best regards,

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