Thanks for the reply. I was afraid of that. The script is kind of long, and I'm not sure what is best thought relevant, but here we go. '$file' refers to the datafile I'm working with.
my $do; # function
# Get delete_links input (which links should be deleted?)
if ( $input =~ m/Delete\+all\+checked\+links%21$/ ) {
$do = 'delete';
$input =~ s/(.*?)&delete_links=.*$/$1/ ;
@del_links = split /&/, $input;
@del_links = map {
s/(\d+?)=checked/$1/ ;
$_;
} @del_links;
@del_links = reverse @del_links; # so that last ones are done f
+irst
}
[...]
my @metadata = &build_metadata_array;
my @strmeta = &parse_metadata(@metadata);
I am hoping you won't need to see the latter subroutines. The first simply reads in a datafile ($file), the second creates an array of references to the split data records. So, for example, @{$strmeta[0]} might consist of ('ap.1', 'ap.2', 'nyt.4', 'some random text about those ids').
if ($do eq 'delete') {
foreach my $num ( @del_links ) {
splice (@strmeta, $num, 1);
}
}
[...]
# Rewrite metadata/$file
open (META, ">metadata/$file");
foreach my $rec ( @strmeta ) {
my $summary = pop @{$rec};
my $ids = join (/,/, @{$rec});
print META "$ids\n$summary\n\n";
}
close META;
Is that enough? |