FHEM Forum

FHEM => Automatisierung => DOIF => Thema gestartet von: Nestor am 31 Dezember 2020, 13:29:09

Titel: DOIF Perl unwanted replacement of [+-] with ::DOIF_time_once()
Beitrag von: Nestor am 31 Dezember 2020, 13:29:09
I have the following code in the middle a DOIF Perl condition:
$alias =~ s/[+-][\d.]+\s//;
which gets replaced with
$alias =~ s/[::DOIF_time_once($hash,3,$wday)][\d.]+\s//;
which is nonsensical.

Simple fix for now:
my $prefix = '+-';
$alias =~ s/[${prefix}][\d.]+\s//;


Should DOIF Perl just check the first line of the condition for timer syntax instead of replacing it in the whole function?
Titel: Antw:DOIF Perl unwanted replacement of [+-] with ::DOIF_time_once()
Beitrag von: Damian am 31 Dezember 2020, 17:31:01
Zitat von: Nestor am 31 Dezember 2020, 13:29:09
I have the following code in the middle a DOIF Perl condition:
$alias =~ s/[+-][\d.]+\s//;
which gets replaced with
$alias =~ s/[::DOIF_time_once($hash,3,$wday)][\d.]+\s//;
which is nonsensical.

Simple fix for now:
my $prefix = '+-';
$alias =~ s/[${prefix}][\d.]+\s//;


Should DOIF Perl just check the first line of the condition for timer syntax instead of replacing it in the whole function?

Time triggers may occur anywhere within a Perl block. It is incorrectly recognized as a time trigger. I would have to further restrict the time trigger check. Outsourcing to a function in the subs block would also help.