i declared the following sub (In reality, the values come out of the Database - so i simplified it):
sub get_date {
my ($ref_last)=@_;
$$ref_last->{duration}='24,0,4';
($$ref_last->{duration}->{d},
$$ref_last->{duration}->{h},
$$ref_last->{duration}->{m})
= split(/\,/, $$ref_last->{duration});
}
This sub is called from the main-Part of the script, like this:
my $hashy;
get_date(\$hashy);
print $hashy->{duration}->{d};
Everything ist fine, and works like a charm, until i use strict:
use strict;
my $hashy;
get_date(\$hashy);
print $hashy->{duration}->{d};
in this case perl says "Can't use string ("24,0,4") as a HASH ref while "strict refs" in use"
I already tried ref($ref_last) - but ref is a read-only function.
Any suggestions, why this happens - and perhaps a better solution ?
Here's the full (non)-Working script:
#!/usr/bin/perl -w
use strict;
my $hashy;
get_date(\$hashy);
print $hashy->{duration}->{d};
sub get_date {
my ($ref_last)=@_;
$$ref_last->{duration}='24,0,4';
($$ref_last->{duration}->{d},
$$ref_last->{duration}->{h},
$$ref_last->{duration}->{m})
= split(/\,/, $$ref_last->{duration});
}