For example, I would like to move the variable new/updated mod by Bobsie to its own sub (rather than repeat the code in site_html_link, site_html_detailed, etc), and need to pass $rec{'DateAdded'} and $rec{'Date'}. Any ideas?
Did you try creating a sub-routine called sub new_stuff and then calling that sub-routine by &new_stuff; in those other sub-routines?
Regards,
------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------
Regards,
------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------
Jan 3, 2000, 6:37 PM
User (431 posts)
Jan 3, 2000, 6:37 PM
Post #3 of 3
Views: 620
Eliot,
I was considering (but haven't implemented yet)... in site_html_lnik, or whatever...
and then a sub...
my ($date, $update) = @_;
my ($new_mod_img);
$days_old = &days_old($date);
if ($days_old <= 2) { $new_mod_img = qq|<img src="/img/icon/new1.gif" border="0" width=24 height=12 alt="New in the last 48 hours" align="absmiddle">|; }
elsif ($days_old <= 7) { $new_mod_img = qq|<img src="/img/icon/new2.gif" border="0" width=24 height=12 alt="New in the last week" align="absmiddle">|; }
elsif ($days_old <= $db_new_cutoff) { $new_mod_img = $new_7 = qq|<img src="/img/icon/new3.gif" border="0" width=24 height=12 alt="New in the last 2 weeks" align="absmiddle">|; }
if (($new_mod_img eq "") && (&compare_dates($date, $update))) {
$days_old = &days_old($date);
if ($days_old <= $db_new_cutoff) { $new_mod_img = qq|<img src="/img/icon/update.gif" border="0" width=24 height=12 alt="Updated" align="absmiddle">|; }
}
return $new_mod_img;
}
[This message has been edited by oldmoney (edited January 03, 2000).]
I was considering (but haven't implemented yet)... in site_html_lnik, or whatever...
Code:
new_mod_img => &get_new_image ($rec{'DateAdded'},$rec{'Date'}),Code:
sub get_new_image { my ($date, $update) = @_;
my ($new_mod_img);
$days_old = &days_old($date);
if ($days_old <= 2) { $new_mod_img = qq|<img src="/img/icon/new1.gif" border="0" width=24 height=12 alt="New in the last 48 hours" align="absmiddle">|; }
elsif ($days_old <= 7) { $new_mod_img = qq|<img src="/img/icon/new2.gif" border="0" width=24 height=12 alt="New in the last week" align="absmiddle">|; }
elsif ($days_old <= $db_new_cutoff) { $new_mod_img = $new_7 = qq|<img src="/img/icon/new3.gif" border="0" width=24 height=12 alt="New in the last 2 weeks" align="absmiddle">|; }
if (($new_mod_img eq "") && (&compare_dates($date, $update))) {
$days_old = &days_old($date);
if ($days_old <= $db_new_cutoff) { $new_mod_img = qq|<img src="/img/icon/update.gif" border="0" width=24 height=12 alt="Updated" align="absmiddle">|; }
}
return $new_mod_img;
}
[This message has been edited by oldmoney (edited January 03, 2000).]