This way works:
## read the .bib database and extract the cited out
foreach $item (@citeditems){
match($item);
}
sub match{
open my $fh2, '<', $bib_filename;
LINE: while(my $line = <$fh2>){
if ($line =~ m/@_\,/ .. $line =~ /^\}$/){
## read the .bib database and extract the cited out
open my $fh2, '<', $bib_filename;
foreach $item (@citeditems){
match($item);
}
sub match{
my $reg = @_;
LINE: while(my $line = <$fh2>){
if ($line =~ m/$reg\,/ .. $line =~ /^\}$/){
Hi Lina,
On Wed, Mar 14, 2012 at 10:15 AM, lina wrote:
> Thanks all, here comes the update one:
>
> #!/usr/bin/env perl
>
> use strict;
> use warnings;
> use Carp qw(croak);
> use autodie qw(open close);
> use File::Basename;
>
> croak "Usage: ./bibextract.pl tex_file.tex" unless defined $ARGV[0
Thanks all, here comes the update one:
#!/usr/bin/env perl
use strict;
use warnings;
use Carp qw(croak);
use autodie qw(open close);
use File::Basename;
croak "Usage: ./bibextract.pl tex_file.tex" unless defined $ARGV[0];
my $infile = $ARGV[0];
my $tex_file = $infile;
#my $bib_filename = "/hom
open my $fh, '<', $tex_file;
while(<$fh>){
if(/cite\{(\S+)\}/){
$cited = sprintf "%s\n",$1;
$cited =~ tr/\,/\n/;
push(@citeditems,$cited);
}
}
close($fh);
## read the .bib database and extract the cited out
open my $fh2, '<',
I updated a bit to
sr/bin/env perl
use strict;
use warnings;
use Carp qw(croak);
use autodie qw(open close);
use File::Basename;
croak "Usage: ./bibextract.pl tex_file.tex" unless defined $ARGV[0];
my $infile = $ARGV[0];
my $tex_file = $infile;
#my $bib_filename = "/home/lina/texmf/bibtex/bib/