Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Clipboard transform keys

by PhilHibbs (Hermit)
on Aug 16, 2004 at 11:39 UTC ( #383266=note: print w/ replies, xml ) Need Help??


in reply to Clipboard transform keys

Here is the latest version of my calculator script. It treats each line of input, stopping on an '=' character, as a separate calculation, and appends the answer after an '=' character. That way you can easily amend the calculation and perform it again.

@rem = '--*-Perl-*-- @echo off perl "%~dpnx0" %* goto endofperl @rem '; #!perl #line 8 use strict; use warnings; use Win32::Clipboard; sub X { return sprintf("%x",$_[0]); } sub x { return X($_[0]); } my $CLIP = Win32::Clipboard(); my $text = $CLIP->GetText(); my @text = split /\n/, $text; my @results = (); for ( @text ) { s[\x0a][]; s[\x0d][]; s/([^=]+)=.+/$1/; # trim after '=' s/(^|[^0-9\.])0+/$1/g; # remove leading zeros (don't want octal) print "\$_.=' =\t'.($_)\n"; eval("\$_.=' =\t'.($_)"); print " = $_\n"; push @results, $_; } $CLIP->Set(join("\n",@results)."\n"); __END__ 4*3 11-4*2 010+020+030 = 61 x(123) = 7b :endofperl


Comment on Re: Clipboard transform keys
Download Code
Reaped: Re^2: Clipboard transform keys
by NodeReaper (Curate) on Sep 10, 2007 at 18:04 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (15)
As of 2014-07-24 14:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (160 votes), past polls