@rem = '--*-Perl-*-- @echo off if "%OS%" == "Windows_NT" goto WinNT perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9 goto endofperl :WinNT perl -x -S %0 %* if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl if %errorlevel% == 9009 echo You do not have Perl in your PATH. if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul goto endofperl @rem '; #!/usr/bin/perl #line 15 ## With all lines in clipboard: get last number on line and add it to total ## Put results in clipboard my $debug = 1; my $VERSION = 0.1; use Win32::Clipboard; # get clipboard into lines my $clip = Win32::Clipboard::GetText; my @lines = split(/\s*[\r\n]+/, $clip); for (@lines) { print "$_ :\n" if $debug >1; if (my @numbers = /([\d\.\-\s']+)/g) { print " ", join("|", @numbers) if $debug > 1; my $num = pop @numbers; $num =~ s/[\s']//g; $num =~ s/[\.\-]+$//; print " => '$num'\n" if $debug >1; push @nums, $num if $num; } else { print " -\n" if $debug; } } my ($total, $newclip); for (@nums) { $total += $_; printf " %6.2f\n", $_ if $debug; # $newclip .= sprintf " %6.2f\r\n", $_; } printf "Total: %6.2f\n", $total if $debug; $newclip .= sprintf "Total: %6.2f\r\n", $total; my $tva = $total*0.076; printf "TVA: %6.2f\n", $tva if $debug; $newclip .= sprintf "TVA: %6.2f\r\n", $tva; printf "Total TTC: %6.2f\n", $total + $tva if $debug; $newclip .= sprintf "Total TTC: %6.2f\r\n", $total + $tva; print $newclip if $debug > 1; Win32::Clipboard::Set($newclip); __END__ Total: 575.00 TVA: 0.76 Total TTC:%6,2f __END__ :endofperl