Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: pack on unpack with same template

by syphilis (Archbishop)
on Jul 28, 2021 at 06:39 UTC ( [id://11135420]=note: print w/replies, xml ) Need Help??


in reply to Re^2: pack on unpack with same template
in thread pack on unpack with same template

Just as a confirmation (changed != to == ....

Yes, if nvsize <= doublesize (not that nvsize is ever less than doublesize) then the equality holds.
Otherwise the equality doesn't hold.

... and swapped the quotes around for *nix command line

That was actually unneeded. (No big deal ... just FYI.)
The rendition that I posted works fine on both Linux and windows.
Perl one-liners inside double-quotes generally aren't a problem on Linux unless there's a scalar variable in the code - and I deliberately crafted my one-liner without inclusion of a scalar variable in order to achieve that portability ;-)

Cheers,
Rob
  • Comment on Re^3: pack on unpack with same template

Replies are listed 'Best First'.
Re^4: pack on unpack with same template
by hippo (Bishop) on Jul 28, 2021 at 08:56 UTC
    Perl one-liners inside double-quotes generally aren't a problem on Linux unless there's a scalar variable in the code - and I deliberately crafted my one-liner without inclusion of a scalar variable in order to achieve that portability ;-)

    You were also careful to ensure (or just lucky) that your code did not contain any of the default history control characters in a valid combination: !, ^ and #. These can vary from shell to shell and can (in many shells) be changed to other characters by the user. Try some of these rather contrived examples which will work if single quotes are used instead:

    • perl -E "say q/Hello!/"
    • perl -E "say q/Hello!!/"
    • perl -E "say q/found/ if shift =~ /^foo[^!#]/" foobar

    IMHO there is no reason not to use single quotes to delimit the entire script on the command line in any non-MSWin32 system and it is almost always the better choice where shell interpolation is not expressly intended.


    🦛

Re^4: pack on unpack with same template
by kcott (Archbishop) on Jul 28, 2021 at 07:06 UTC
    "That was actually unneeded. (No big deal ... just FYI.) ..."

    Well, that surprised me but it seems you are quite correct:

    $ perl -e "print 'qwe'" qwe $ perl -e "my $x = 'qwe'; print $x" syntax error at -e line 1, near "my =" Execution of -e aborted due to compilation errors.

    I've had so much trouble with perl -e "..." in the past, that I now just automatically write perl -e '...', without giving it a second thought. I suppose my one-liners usually have a variable. Anyway, good to know; although, my muscle memory may take some convincing. :-)

    — Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11135420]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-24 20:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found