Try this:
use Number::Format;
my $x = new Number::Format(-decimal_fill => 1);
$formatted = $x->format_number(221659.20);
print "\$$formatted";
I believe the module comes default with perl. Read the docs for full information on use of the module...
The pack method has to be passed -side => 'left' in order for the buttons to line up side by side. But the buttons will also cling to the left side of the main window. If you want the buttons to be in the exact center, you have to create a new frame, anchor it in the center, and the pack the...
Some other problems with your code.
If you are only passing one file name from the command line, then you need to call $ARGV[0] not $ARGV[1]. You should also use strict and add error checking to your file reads and file writes. It will go a long way to helping troubleshoot problems. Here is...
Kirsle,
my $curX = $Tk::event->x;
my $curY = $Tk::event->y;
needs to read
my $curX = $Tk::event->X;
my $curY = $Tk::event->Y;
The X and Y needs to be capitalized.
Small caps xy returns the event's coordinate relative to the widget.
Upper caps XY returns the event's...
Another way to do it would be to split the string along spaces and use an array slice to capture the values:
while(<DATA>){
my @vals = (split/\s+/)[2,3,4,5,6,7,9,10,11,12];
print join(' ', @vals) . "\n";
}
__DATA__
1152897223 4 Fri 07 14 13:13:43 2006 Node1 M NW IC-3 Node Up Node1...
use strict;
open (IN, "$file"); # The data file: replace $file with path to file
open (OUT, ">$new_file"); # Open a file to write to
while (<IN>) { # Read IN file line by line
chomp;
if (/^\.\//) { # Look for ./
my ($junk,$string) = split(/=/); # Split on the = sign
print...
Windows has always been weak in this area, but they introduced a new program called taskkill in Windows XP. You could execute it with a system call from a perl script.
c:\>taskkill /? # get all the details on usage
Or I would recommend using a third party command line app.
This freeware app...
Ishnid,
How would you modify your "buffer of sorts" to capture all of the numerical data. That particular snippet only captures the first ten lines of numbers, but leaves off substantially more.
Chep80,
I know your file is some 40,000+ lines, so you may not want to read the whole thing into...
From Mastering Perl/Tk
Never used this method so I can't give a specific example, but maybe this link will help.
http://www.codecomments.com/archive234-2004-9-279207.html
To print the file back out, use this code (other minor code corrections also included):
use strict;
use Math::BigFloat;
open(IN, "c:/temp/data.txt");
open(OUT, ">c:/temp/newdata.txt");
my $convert;
while (<IN>) {
if ($convert) {
my @vals = split(/ /);
foreach my $num...
No problem. The __DATA__ is there just for testing and demonstration purposes. I don't have the file, so I can't code it exactly. Here is an approximation:
use strict;
use Math::BigFloat;
open(IN, "c:/temp/data.txt");
my $convert;
while (<IN>) {
if ($convert) {
my @vals =...
Oops, small bug in the code.
use strict;
use Math::BigFloat;
my $convert;
while (<DATA>) {
if ($convert) {
my @vals = split(/ /);
foreach my $num (@vals) {
my $x = Math::BigFloat->new($num);
print $x->bstr() . " ";
}
print "\n";
}...
What do you think of this?
use strict;
use Math::BigFloat;
my $convert;
while (<DATA>) {
if ($convert) {
chomp;
my @vals = split(/ /);
foreach my $num (@vals) {
my $x = Math::BigFloat->new($num);
print $x->bstr() . " ";
}
print...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.