A while back you posted this code on one of my questions, I never used the __DATA__ I need to replace that on the "while( <DATA> ){" line with a variable i tried while($var_records){ but the script stop working after that, how can I do this?
below is the code as I have now: it hangs I think it's on a infinite looping because of the variable on the "while"
#-------------------------
----------
----------
-------
$var_records = qq~
2007|3|21|00|00||00|01||SY
S|employee
1
2007|3|21|00|00||00|01||SY
S|employee
2
2007|3|21|00|00||00|01||SY
S|employee
3
2007|3|21|00|00||00|01||SY
S|employee
4
2007|3|21|00|00||00|01||SY
S|employee
5
2007|3|21|00|00||00|01||SY
S|employee
6
2007|3|21|00|00||00|01||SY
S|employee
7
2007|3|21|00|00||00|01||SY
S|employee
8
2007|3|21|00|00||00|01||SY
S|employee
9
2007|3|21|00|00||00|01||SY
S|employee
10
~;
%schedule;
while($var_records){
(@date,@start,@end,$employ
ee);
(@date[0..2],@start[0,1],@
end[0,1],$
employee)=
(split/\|/
)[0..2,3..
4,6..7,10]
;
push @{$schedule{$employee}},["
@date",$st
art[0]*60+
$start[1],
$end[0]*60
+$end[1]];
}
sub available{
(@date,@start,@end);
# local $_=shift; #sorry, this should not have been left here
(@date[0..2],@start[0,1],@
end[0,1])=
@_;
@available;
($d,$s,$e)=("@date",$start
[0]*60+$st
art[1]-30,
$end[0]*60
+$end[1]+3
0);
while( my($k,$v) = each %schedule ){
push @available,$k unless grep{$d eq $_->[0] && $s < $_->[2] && $e > $_->[1]}@$v;
#print qq~@available,$k unless grep{$d eq $_->[0] && $s < $_->[2] && $e > $_->[1]}@$v <BR><BR>~;
}
return sort @available;
}
print join"\n",available(2007,03
,21,12,30,
13,31),'';
Start Free Trial