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?

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.