barrycarlyon has asked for the wisdom of the Perl Monks concerning the following question:
Fello Monks
Given this code snippet:
sub home { my $self = shift; my $html_template = $self->param('html_template'); my $cgi = CGI->new; my $session = $cgi->param('session'); my $empty; my $user_status; my ($session_id, $last_action_date, $last_action_time) = $session =~ + /^(\d\d)-(\d{10})-(\d{8})$/; my $datetime = Class::Date->now(); $datetime =~ tr/://d; my ($now_date, $now_hour, $now_min, $now_seconds) = $datetime =~ /^ +(\d{8}) (\d{2})(\d{2})(\d{2})$/; my $output; $html_template->process('home', { wrapper => $self->wrapper(), session => $session, user_status => $user_status, session_id => $session_id, now_date => $now_date, now_hour => $now_hour, now_min => $now_min, now_seconds => $now_seconds, session_id => $session_id, last_action_date => $last_action_date, last_action_time => $last_action_time, }, \$output) || die $html_template->error; return $output; }
Why wont all the now_ variables display on the relevant template when they are called in the template correctly?
In my Base.pm, I do something similar, but the varibles (now_ in the snippet) are put into an array, and used from there as an array
So my understanding is that the variables in the my (), are an array, so how can the array be split up, or am I approaching this wrong?
Update: And same question regarding the $session "split" with session_id, last_action_whatever, where $session is a string of numbers (say 00-0000000000-00000000)
Update: So wht i want to do is take $session, and put the first 2 digits/chars. into $session_id, then next 10 into $last_action_date, then the next 8 into $last_action_time, and use them on the page/in the rest of the function, and I dont care if my $session layout os wrong, Coz the question will still stand!
YoursFINAL UPDATE: All Sorted thanks to the Split Function suggested by ptum, its all I wanted to do was Split up a $memory and put the split bits into $other_mems
|
|---|