#!/usr/bin/perl my $slice=shift or die("usage: $0 slice file* where slice is p 3 (article 3) 4-12 p4-10,20-29 "); use strict; use Data::Dumper; undef $/; my %dudh; my (@l)=(); push (@l,'0') if($slice=~ s/p//); push (@l, (map { if(/(\d+)-(\d+)/){ ($1..$2) } else {($_)}} split(/,/,$slice))); print join("||",@l); for my $f (@ARGV){ open (my $fp,$f) or die("cant open $f\n"); my $t =<$fp>; my @l1 = ($t =~ m{.*?===p=(.*?)===1=(.*)}gs); $dudh{$f}=[$l1[0],split(/===/,$l1[1])]; close $fp; open ($fp,">", "_slice_$f") or die("cant open $f\n"); for(@l){print $fp "===\n$dudh{$f}[$_]\n"} close $fp; } __END__ =encoding utf8 =head1 NAME mkcomparableslice - extract some articles of DUHR in the desired languages =head1 SYNOPSIS mkcomparableslice p3-5,7 fr.txt ru.txt (to get preamb and articles 3,4,5,7 in _slice_fr.txt and _slice_ru.txt) =head1 DESCRIPTION =head1 AUTHOR J.Joao Almeida, jj@di.uminho.pt =head1 SEE ALSO perl(1). =cut