![]() |
perl pack equivalent in lua - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: perl pack equivalent in lua (/showthread.php?tid=3224) |
perl pack equivalent in lua - baggins - 15.03.2021 Hi, I am trying to convert a perl script to lua and ran into the pack command. Simplified, this is what's in the script: Code: #!/usr/bin/perl -l This results in : Code: ./test.pl |od -x --endian big How can I achieve this in lua? The perl script also uses the unpack command... Thanks for your help. RE: perl pack equivalent in lua - admin - 15.03.2021 This should do the trick: Code: data = "00990102" RE: perl pack equivalent in lua - baggins - 15.03.2021 Thanks admin. Now, I am developping this script not on LM but on a 'normal' Linux box, because I don't want to use the LM that is in production... Is there some standard lua equivalent for lmcore.hextostring? Also the perl script converts the command to a readable string for logging purposes: Code: $commandhex =~ s/(.)/sprintf("0x%x ",ord($1))/eg; How would that be done in lua? Thanks! RE: perl pack equivalent in lua - baggins - 15.03.2021 (15.03.2021, 14:21)baggins Wrote: Thanks admin. I've found a script and written another one that I can use on my Linux box. Code: function string.fromhex(str) |