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').
Is that enough?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;
In reply to Re: Re: Datafile doesn't update before being read
by ghopper
in thread Datafile doesn't update before being read
by ghopper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |