FHEM Forum

FHEM => English Corner => Thema gestartet von: @lex99 am 05 Februar 2022, 21:52:21

Titel: myAverage function throws error: Experimental aliasing via reference not enabled
Beitrag von: @lex99 am 05 Februar 2022, 21:52:21
Hi,

I'm trying to use the function myAverage (from the Wiki).

Upon typing this:

define KS300_W_notify notify KS300:wind.* {\
  my $avg = myAverage("10800", "FileLog_KS300", "8:::");;\
  my $event = sprintf("Wc: %0.1f Wd: %0.1f Wm: %0.1f Wlh: %0.1f", ReadingsVal("KS300","wind","0"), ReadingsVal("KS300", "W_avg_day","0"), ReadingsVal("KS300","W_avg_month","0"), $avg);;\
  Log 2, ("K300_W: Event: $event");;\
  fhem("trigger KS300_W data: $event");;\
  fhem("trigger KS300 average-wind: $avg");;\
}

I get: Experimental aliasing via reference not enabled

Can a Perl expert help here ?

Thanks !
Titel: Antw:myAverage function throws error: Experimental aliasing via reference not enabled
Beitrag von: rudolfkoenig am 06 Februar 2022, 11:38:18
ZitatUpon typing this:
What exactly do you mean by "typing"?
I get no message at all, when I'm typing that :)
What is your perl version?
Titel: Antw:myAverage function throws error: Experimental aliasing via reference not enabled
Beitrag von: herrmannj am 06 Februar 2022, 16:30:22
the backslashes throw that error
Titel: Antw:myAverage function throws error: Experimental aliasing via reference not enabled
Beitrag von: @lex99 am 06 Februar 2022, 16:37:40
I have Perl 5.24.1
Titel: Antw:myAverage function throws error: Experimental aliasing via reference not enabled
Beitrag von: @lex99 am 06 Februar 2022, 16:40:54
Zitat von: herrmannj am 06 Februar 2022, 16:30:22
the backslashes throw that error

OK, thanks - it works in a single line.  Best to modify in the wiki then to avoid confusion.

Should I upgrade my Perl to the latest one ?  Via Perlbrew ?
Titel: Antw:myAverage function throws error: Experimental aliasing via reference not enabled
Beitrag von: herrmannj am 06 Februar 2022, 17:08:28
Works but not that easy. Either via os upgrade or let it go, unless you know how to do it via perlbrew. Fhem usually runs with the user fhem
Titel: Antw:myAverage function throws error: Experimental aliasing via reference not enabled
Beitrag von: Beta-User am 07 Februar 2022, 12:30:14
Zitat von: @lex99 am 06 Februar 2022, 16:40:54
Best to modify in the wiki then to avoid confusion.
...not sure about that..

You are referring to the notify at the end of https://wiki.fhem.de/wiki/Gleitende_Mittelwerte_berechnen_und_loggen#Funktion_myAverage.28.29_aufrufen_und_nutzen?

The format shown there is the "RAW"-Format as explained in https://wiki.fhem.de/wiki/Import_von_Code_Snippets. You will find that kind of notation throughout the entire Wiki, so it's not possible to eleminate that completely despite the fact it might be possible in this single case.

Note: there had been some "use POSIX;"-lines in the shown code in the wiki. Please delete these also in your code.