I would like to use "__DATA__" twice is that possible? Also I need to pass the values of variables ($date - $location) into the html inside the "__DATA__", any suggestion? If I run this I am getting the second "__DATA__" printed with the rest of the html code. My goal here is to separate as much as I can the HTML from the Perl.$data = do { local $/; <DATA> }; #do{$data = $data . $_ } while (<DATA>); #gives a uninitialized value +in concatenation
Thanks for looking!#!/usr/bin/perl use strict; use warnings; use Date::Calc qw( Today Today_and_Now Date_to_Days Add_Delta_Days Del +ta_Days Decode_Date_US ); my $display=qq(); my $data = qq(); my $date = sprintf "%02d/%02d/%04d", (Date::Calc::Today())[1,2,0]; my $location = "BR"; $display .= qq(\n\nStart Display\n\n); $data = do { local $/; <DATA> }; #do{$data = $data . $_ } while (<DATA>); #gives a uninitialized value +in concatenation $display .= $data; $display .=" <tr> <td>more data</td> </tr> <tr> <td>end of rows</td> </tr> </table>\n"; print $display; __DATA__ <table width="100%" border="0" bgcolor="#ffffff" cellpadding="0" cells +pacing="0"> <tr> <td colspan="2"> </td> </tr> <tr> <td width="60%">All Names List from:</td> <td width="40%" align="left"><b>$date</b></td> </tr> <tr> <td width="100%" colspan="2"> </td> </tr> </table> __DATA__ <table width="100%" border="0" bgcolor="#ffffff" cellpadding="0" cells +pacing="2"> <tr> <td><b>Name</b></td> <td><b>Address</b></td> <td><b>Phone</b></td> <td><b>Email</b></td> <td><b>$location</b></td> </tr> <tr> <td colspan="5"> </td> </tr>
In reply to How to use __DATA__ efficiently, help! by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |