Am Mittwoch 25 Juli 2018 schrieb Stefan Krusche:
Am Mittwoch 25 Juli 2018 schrieb Stefan Krusche:
When I start this script in bash it throws this error: $ /opt/trinity/share/apps/tdeio_info/kde-info2html '/opt/trinity/share/apps/tdeio_info/kde-info2html.conf' '/opt/trinity/share/icons/crystalsvg/22x22/actions' 'coreutils' 'dd invocation' Can't use 'defined(@array)' (Maybe you should just omit the defined()?) at /opt/trinity/share/apps/tdeio_info/kde-info2html line 154.
In the script there is:
150 while (<DIR>) { 151 next if $looking && !/* Menu/; 152 $looking = 0; 153 my @item = &ParseMenuItem($_,'dir'); 154 if (!defined(@item)) { next } 155 my ($MenuLinkTag, $MenuLinkFile, $MenuLinkRef, MenuLinkText) = @item; 156 if ($MenuLinkRef eq $FileName) { 157 &Redirect($MenuLinkFile, $MenuLinkTag); 158 exit 0; 159 } 160 }
Would it make sense to just do what the error message suggests, like this?:
154c154
< if (!defined(@item)) { next }
if (!@item) { next }
This patch made the script work again:
RCS file: ./RCS/kde-info2html,v retrieving revision 1.1 diff -u -r1.1 ./kde-info2html --- ./kde-info2html 2018-07-25 13:33:38+02 1.1 +++ ./kde-info2html 2018-07-25 13:39:20+02 @@ -151,7 +151,7 @@ next if $looking && !/* Menu/; $looking = 0; my @item = &ParseMenuItem($_,'dir'); - if (!defined(@item)) { next } + if (!@item) { next } my ($MenuLinkTag, $MenuLinkFile, $MenuLinkRef, $MenuLinkText) = @item; if ($MenuLinkRef eq $FileName) { &Redirect($MenuLinkFile, $MenuLinkTag); @@ -406,7 +406,7 @@ sub MenuItem2HTML { my ($Line, $BaseInfoFile) = @_; my @parse_results = &ParseMenuItem($Line, $BaseInfoFile); - if (!defined (@parse_results)) { return $Line; } + if (!@parse_results) { return $Line; } my ($MenuLinkTag, $MenuLinkFile, $MenuLinkRef, $MenuLinkText) = @parse_results; #-- produce a HTML line return "<tr class="infomenutr"><td class="infomenutd" width="30%"><ul><li><a href="info:/$MenuLinkFile/$MenuLinkTag">$MenuLinkRef</a></ul></td><td class="infomenutd">$MenuLinkText";
But, as I'm an absote perl newbie, someone with perl knowledge should probably check if that's okay. If so, it would be nice to include it upstream.
Thanks everybody Stefan