Will this do it for you?
#!/usr/bin/env perl # Just because you can be a SOB doesn't mean you should # or among the things you probably shouldn't do is this: # modify (read/write) the program's DATA section - # but hey, it was interesting and amusing. use Carp; use English qw(-no_match_vars); use strict; use warnings; open my $READER,'+<',$PROGRAM_NAME or Carp::confess "Can't open '$PROGRAM_NAME'! $OS_ERROR"; open my $WRITER,'+<',$PROGRAM_NAME # Don't us +e '+>' or Carp::confess "Can't open '$PROGRAM_NAME'! $OS_ERROR"; seek $READER,tell DATA ,0; seek $WRITER,tell DATA,0; # The overflow buffer: my @Buffer_a; #print "READER: @{[tell $READER ]} \n"; while (<$READER>) { #print "Read: '$_'\n"; # Read (past tense) a line - buffer its replacement ... { # Modify the line here! my $Update_s="x s $_"; push @Buffer_a,$Update_s; }; #print "WRITER: @{[tell $WRITER ]} \n"; # Write from the overflow buffer if we can ... while (@Buffer_a && tell($READER)-tell($WRITER) > length $Buff +er_a[0]) { # Enough room to write $Buffer_a[0] so write it ... #print "Writing '$Buffer_a[0]'\n"; print {$WRITER} shift @Buffer_a or Carp::confess "Error while writing \$WRITER: $OS_ER +ROR"; #print "WRITER: @{[tell $WRITER]} \n"; }; #print "READER: @{[tell $READER]} \n"; }; # Nothing more to read ... close $READER or Carp::confess "Can't close '$PROGRAM_NAME'! $OS_ERROR"; #print "WRITER: @{[tell $WRITER]} \n"; # If there's anything in the buffer write it ... while (@Buffer_a) { #print "Writing '$Buffer_a[0]'\n"; print {$WRITER} shift @Buffer_a or Carp::confess "Error while writing \$WRITER: $OS_ERROR" +; #print "WRITER: @{[tell $WRITER]} \n"; }; # Truncate the file, in case, what we're writing is shorter than w +hat we read truncate $WRITER,tell$WRITER; # ... and close close $WRITER or Carp::confess "Can't close '$PROGRAM_NAME'! $OS_ERROR"; exit; __END__ 0 1 2 3 4 5 6 7 8 9

In reply to Re: Is it possible to modify __DATA__ via the DATA file handle or otherwise? by clueless newbie
in thread Is it possible to modify __DATA__ via the DATA file handle or otherwise? by YenForYang

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.