A recent post used a nice feature for providing test data to a script. (See __DATA__ below) I've seen it before but never understood it. How does it work? What signals the end of the data to the while (my $line = <DATA>) { ? Is this a type of here document? Can someone point me where it's descibed in the perl doc?
TIA, Phil > use warnings; > use constant {SECS_PER_DAY => 24 * 60 * 60}; > use POSIX qw{strftime}; > > my $startDate = strftime "%Y-%m-%d_", localtime(); > my $endDate = strftime "%Y-%m-%d_", localtime(time + 2 * SECS_PER_DAY); > my $dateRE = qr{\d{4}-\d{2}-\d{2}_}; > > while (my $line = <DATA>) { > if ($line =~ m/^start_date/) { > $line =~ s/$dateRE/$startDate/g; > } > elsif ($line =~ /^end_date/) { > $line =~ s/$dateRE/$endDate/g; > } > print $line; > } > > __DATA__ > First line > start_date = '2012-04-29_00:00:00', '2012-04-29_00:00:00', > '2012-04-29_00:00:00', > end_date = '2012-05-01_00:00:00', '2012-05-01_00:00:00', > '2012-05-01_00:00:00', > Last line > > HTH > > -- > Brian Raven _______________________________________________ ActivePerl mailing list ActivePerl@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs