Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

SirBones's scratchpad

by SirBones (Friar)
on Jun 10, 2004 at 21:04 UTC ( #363198=scratchpad: print w/ replies, xml ) Need Help??


/me sighs.

My company has an online form for ordering replacement cabinet keys. I put in the key number, and under quantity, I put 3. A week or so later, I received 1 key.

So I went back to the form and put in the key number, and quantity = 2.

I received 1 key.

So I went back again and put in quantity = 1.

I received 1.

$n>1 ? $n = $n-($n-1) : $n = 1;


A discussion on coverting a hex string to a signed int...

planetscape chuckles SirBones++
ChemBoy: when I do the same operation on x86, it comes out as you say. For 
unsigned numbers there's a good shortcut for this problem but not for signed, 
so you just insert reverse between the pack and the unpack.
ChemBoy: making the total line perl -le'$str = "0001";print unpack "s", reverse pack "H4",$str'
tye: that code depends on the endianness (in case that wasn't clear)
SirBones: Excellent! Works!
ChemBoy: sorry about the extra steps, I clearly need to recaffeinate
SirBones is near tears. It's sick how long I've spent on this bug.
ChemBoy: Yeah, if you ever distribute that code, you will probably want to do 
a little check to make sure your byte-order is correct before you run that line. 
Or I and the other SGI/Mac users of the world will hunt you down and smack you on 
the big end. ;-)
planetscape offers up the gnawed bones of her victims if that would make SirBones 
feel better...
SirBones appreciates the gesture, but is too tired to eat.
ChemBoy: That is to say: use Config; my $packed = pack "H4", $str; 
if ('4321' eq $Config{byteorder}) { $packed = reverse $packed; } 
print unpack "s", $packed;)
planetscape: maybe a wee hug would do instead... the dragon furls her wings 
'round SirBones and gives a gentle squeeze...


Passing a data structure via a dynamically-built subroutine call
How to check Inputs if Numeric
ybiC's scratchpad
perl opening a new command line window
HTML stripper in WWW::Mechanize doesn't seem to work
YuckFoo
How to kill perl?
Re: lhs substr(): refs vs. scalars
Reading a file from any arbitrary place in the file.
Win32 development
Erudil
Cron Jobs That Run For Too Long
Hex dump
3 questions... 2 about newlines, and one on how to be NICE
Line Feeds
how to run commandline perl on windows
Tk Realtime data aquisition
Patterns for your numbers
Interactive perl
Re: Calling a subroutine from a scalar
All-purpose data dump subroutine
(OT) Fixing Line Endings
Why chomp() is not considering carriage-return
Why chomp() is not considering carriage-return
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2014-07-22 09:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (109 votes), past polls