Re: sprintf function

2011-11-29 Thread Dr.Ruud
On 2011-11-29 14:49, Chris Stinemetz wrote: How can I check that the value assigned to $cell and $sector is numeric before I try to call the sprintf function? I am just trying to clear this warning. Argument "" isn't numeric in sprintf at ./rt_evdo_pcmd.pl line 139,<$FIN&g

Re: sprintf function

2011-11-29 Thread John W. Krahn
Chris Stinemetz wrote: How can I check that the value assigned to $cell and $sector is numeric before I try to call the sprintf function? I am just trying to clear this warning. Argument "" isn't numeric in sprintf at ./rt_evdo_pcmd.pl line 139,<$FIN> line 119503.

Re: sprintf function

2011-11-29 Thread Shlomi Fish
Hi Chris, On Tue, 29 Nov 2011 07:49:37 -0600 Chris Stinemetz wrote: > How can I check that the value assigned to $cell and $sector is numeric > before I try to call the sprintf function? > > I am just trying to clear this warning. > > Argument "" isn't numeri

Re: sprintf function

2011-11-29 Thread Igor Dovgiy
How can I check that the value assigned to $cell and $sector is numeric > before I try to call the sprintf function? > > I am just trying to clear this warning. > > Argument "" isn't numeric in sprintf at ./rt_evdo_pcmd.pl line 139, <$FIN> > line 119503. &g

sprintf function

2011-11-29 Thread Chris Stinemetz
How can I check that the value assigned to $cell and $sector is numeric before I try to call the sprintf function? I am just trying to clear this warning. Argument "" isn't numeric in sprintf at ./rt_evdo_pcmd.pl line 139, <$FIN> line 119503. line 139 is from my progr

Re: newbie question : about the perl sprintf

2009-10-25 Thread Dr.Ruud
Majian wrote: I found these : perl -e'print 01.234 + 01.234', "\n"' perl -e'print 01.234 + 011.234' "\n"' perl -e'print 01.234.12 + 01.234', "\n"' And the results were : 1235234 1235234 1235.12234 For other surprises, try also: perl -wle 'print length(01.234.12)' perl -wle 'print 01.234.12'

Re: newbie question : about the perl sprintf

2009-10-25 Thread Philip Potter
2009/10/25 Majian : > I found these : > perl -e'print 01.234 + 01.234', "\n"' print (01).(234+01).234, "\n"; this evaluates to '1'.'235'.'234' > perl -e'print 01.234 + 011.234' "\n"' I didn't get 1235234, I got 1243234. print (01).(234+011).(234),"\n" evaluates to print '1'.(234+9).'234',"\n";

Re: newbie question : about the perl sprintf

2009-10-25 Thread Majian
~~ On Sat, Oct 24, 2009 at 7:28 PM, Peter Scott wrote: > On Wed, 21 Oct 2009 20:52:05 +0800, Majian wrote: > > And I modify it like this "sprintf "The number in > > scientific > > notation is %e", 01.255;" > >

Re: newbie question : about the perl sprintf

2009-10-24 Thread Peter Scott
On Wed, 21 Oct 2009 20:52:05 +0800, Majian wrote: > And I modify it like this "sprintf "The number in > scientific > notation is %e", 01.255;" > The screen now output is " The number in scientific >

Re: newbie question : about the perl sprintf

2009-10-22 Thread uap12
On 21 Okt, 14:52, jian...@gmail.com (Majian) wrote: > Hi, all ; > >            I want to print  this sentence " The number in scientific > notation is 1.255000e+02". > >          So   I write a perl script like this : >                #!/usr/bin/perl >    

Re: newbie question : about the perl sprintf

2009-10-21 Thread Christian Bernini
> > sprintf "The number in scientific notation is %e", 1.255; > Sprintf doesn't print actually, it just returns a string based on the formats provided in the list you have. To actually print something you should use printf. printf "The number in scientific no

Re: newbie question : about the perl sprintf

2009-10-21 Thread Jim Gibson
At 8:52 PM +0800 10/21/09, Majian wrote: Hi, all ; I want to print this sentence " The number in scientific notation is 1.255000e+02". So I write a perl script like this : #!/usr/bin/perl sprintf "The number in scientific

newbie question : about the perl sprintf

2009-10-21 Thread Majian
Hi, all ; I want to print this sentence " The number in scientific notation is 1.255000e+02". So I write a perl script like this : #!/usr/bin/perl sprintf "The number in scientific notation is %e", 1.255; But

Re: Invalid conversion in sprintf "%\"

2009-02-19 Thread Jim Gibson
On 2/19/09 Thu Feb 19, 2009 7:56 AM, "John W. Krahn" scribbled: > Thank you for reading the documentation to me but '%1\$s' is not the > same as '%1$s'. True. However, I think the point should be made that "%1\$s" is in fact the same as '%1$s' Rob is using double-quotes in his program. I wo

Re: Invalid conversion in sprintf "%\"

2009-02-19 Thread John W. Krahn
Rob Dixon wrote: John W. Krahn wrote: Strings like '%1\$s16->' are not valid sprintf/printf formats. What does your data look like and what do you expect it to look like after using sprintf? From perldoc -f sprintf: format parameter index An explicit format parameter inde

Re: Invalid conversion in sprintf "%\"

2009-02-19 Thread Rob Dixon
John W. Krahn wrote: > > Strings like '%1\$s16->' are not valid sprintf/printf formats. What > does your data look like and what do you expect it to look like after > using sprintf? >From perldoc -f sprintf: > format parameter index > An explicit format

Re: Invalid conversion in sprintf "%\"

2009-02-19 Thread Rob Canning
y @phraseA = ("%1\$s16-> ", "%2\$s16-> ", "%3\$s16-> "); i also had to convert the array to a scalar for the InsertPitches subroutine to work correctly with the sprintf. thanks again to John and Jim for your hints, rob this now works for me my @phraseA

Re: Invalid conversion in sprintf "%\"

2009-02-18 Thread Jim Gibson
On 2/18/09 Wed Feb 18, 2009 10:20 AM, "Rob Canning" scribbled: > John W. Krahn said : >> Rob Canning wrote: >>> hi i have a sprintf which uses a scalar as its format: >>> my $Bformat = "%1\$s16-> %2\$s16 %3\$s16 %4\$s16 %5\$s16 %6\$s16-> %7\$

Re: Invalid conversion in sprintf "%\"

2009-02-18 Thread Rob Canning
John W. Krahn said : > Rob Canning wrote: >> hi i have a sprintf which uses a scalar as its format: >> my $Bformat = "%1\$s16-> %2\$s16 %3\$s16 %4\$s16 %5\$s16 %6\$s16-> %7\$s16 >> %8\$s16" >> >> >> what i would like to do is generate a ne

Re: Invalid conversion in sprintf "%\"

2009-02-18 Thread John W. Krahn
Rob Canning wrote: hi i have a sprintf which uses a scalar as its format: my $Bformat = "%1\$s16-> %2\$s16 %3\$s16 %4\$s16 %5\$s16 %6\$s16-> %7\$s16 %8\$s16" what i would like to do is generate a new format for the sprintf by doing permutations of 5 arrays like this: my @

Invalid conversion in sprintf "%\"

2009-02-18 Thread Rob Canning
hi i have a sprintf which uses a scalar as its format: my $Bformat = "%1\$s16-> %2\$s16 %3\$s16 %4\$s16 %5\$s16 %6\$s16-> %7\$s16 %8\$s16" what i would like to do is generate a new format for the sprintf by doing permutations of 5 arrays like this: my @phraseA = qw( %1\$s1

Re: output of permute() to list for sprintf

2009-02-04 Thread Rob Canning
Dermot wrote: 2009/2/4 Rob Canning : hello, i am new to this list and very new to pearl. i have run into a problem i cant find a solution - i have searched the net for an answer but as i am so new to perl (and programming in general) perhaps i dont even know the right keywords... ok here it

Re: output of permute() to list for sprintf

2009-02-04 Thread Dermot
2009/2/4 Rob Canning : > hello, > i am new to this list and very new to pearl. > i have run into a problem i cant find a solution - i have searched the net > for an answer but as i am so new to perl (and programming in general) > perhaps i dont even know the right keywords... > > ok here it goes..

output of permute() to list for sprintf

2009-02-04 Thread Rob Canning
it into the first index of the array as a string? what i need is an @array i can use as a list in sprintf sub InsertPitches { my ($num, $form, @notes) = @_; my ($output, @temp); while (@notes) { (@temp[0..$num-1], @notes) = @notes; $output .= sprintf $form, (@temp); } ret

Re: sprintf format question

2008-06-05 Thread April
On Jun 4, 8:00 am, [EMAIL PROTECTED] (Rob Dixon) wrote: > April wrote: > > sprintf( "%s%$Fmt%s", ("%$Fmt=|", $TestStr, "|")) > > > This is in Perl for Dummies, 4th ed, p160. > > > I'm trying to understand this ... > > > the

Re: sprintf format question

2008-06-04 Thread Rob Dixon
April wrote: > sprintf( "%s%$Fmt%s", ("%$Fmt=|", $TestStr, "|")) > > This is in Perl for Dummies, 4th ed, p160. > > I'm trying to understand this ... > > the first part, "%s%$Fmt%s", my understanding is the format part, > whic

sprintf format question

2008-06-04 Thread April
sprintf( "%s%$Fmt%s", ("%$Fmt=|", $TestStr, "|")) This is in Perl for Dummies, 4th ed, p160. I'm trying to understand this ... the first part, "%s%$Fmt%s", my understanding is the format part, which specifies the formats for the second part, thel

Re: Variable division, assignment and sprintf in one line

2007-11-29 Thread Jenda Krynicky
From: Steve Bertrand <[EMAIL PROTECTED]> > >> $var = sprintf ("%.2f", (($var /=1024) /=1024))) > > > > What the ...?!? > > > > /= ? > > It was an off the top of my head example of what I wanted to do. Without > being at the code at

Re: Variable division, assignment and sprintf in one line

2007-11-28 Thread Steve Bertrand
> $var = sprintf ("%.2f", $var / (1024*1024)); > > And it will be more efficient because the multiplication will be done > at compile time (once) and you'll only do a single division each > time. Which is also more precise, though in this case it doesn't seem

Re: Variable division, assignment and sprintf in one line

2007-11-28 Thread Steve Bertrand
>> $var = sprintf ("%.2f", (($var /=1024) /=1024))) > > What the ...?!? > > /= ? It was an off the top of my head example of what I wanted to do. Without being at the code at the time, I was simply thinking +=. > You divide the value of $var by 1024, assign i

Re: Variable division, assignment and sprintf in one line

2007-11-28 Thread Jenda Krynicky
From: Steve Bertrand <[EMAIL PROTECTED]> > Hi again all, > > Is there a way that one can use sprintf on a variable and assign the > value back to the variable without having the leading $var= ? > > $var = sprintf ("%.2f", (($var /=1024) /=1

Re: Variable division, assignment and sprintf in one line

2007-11-28 Thread Steve Bertrand
Gunnar Hjalmarsson wrote: > Steve Bertrand wrote: >> Is there a way that one can use sprintf on a variable and assign the >> value back to the variable without having the leading $var= ? >> >> $var = sprintf ("%.2f", (($var /=1024) /=1024))) > > You c

Re: Variable division, assignment and sprintf in one line

2007-11-28 Thread Gunnar Hjalmarsson
Steve Bertrand wrote: Is there a way that one can use sprintf on a variable and assign the value back to the variable without having the leading $var= ? $var = sprintf ("%.2f", (($var /=1024) /=1024))) You can write a function. convert( $var ); sub convert { $_[0] = spr

Re: Variable division, assignment and sprintf in one line

2007-11-28 Thread Aaron Priven
On Nov 28, 2007, at 11:26 AM, Steve Bertrand wrote: Is there a way that one can use sprintf on a variable and assign the value back to the variable without having the leading $var= ? I don't think you can do it directly, but you can use the aliasing properties of sub o

Variable division, assignment and sprintf in one line

2007-11-28 Thread Steve Bertrand
Hi again all, Is there a way that one can use sprintf on a variable and assign the value back to the variable without having the leading $var= ? $var = sprintf ("%.2f", (($var /=1024) /=1024))) I've got a hash of hashrefs of hashrefs and I'd rather not specify the variable

Re: One sprintf() initializations problem

2007-10-30 Thread Tom Phoenix
On 10/29/07, jiangfan <[EMAIL PROTECTED]> wrote: > What is wrong with this statement? > > my $time = sprintf( "0x%08x", `date +%s` ); I don't know what's wrong with it on your machine, but I'd change the command in backticks to be Perl's time o

Re: One sprintf() initializations problem

2007-10-30 Thread Matthew Whipple
jiangfan wrote: > Hi, > > What is wrong with this statement? > > my $time = sprintf( "0x%08x", `date +%s` ); > > I got > > "Use of uninitialized value in sprintf at /opt/MoteWorks/tos/../make/ > scripts/ident_flags line 15." > > Thanks. &

One sprintf() initializations problem

2007-10-30 Thread jiangfan
Hi, What is wrong with this statement? my $time = sprintf( "0x%08x", `date +%s` ); I got "Use of uninitialized value in sprintf at /opt/MoteWorks/tos/../make/ scripts/ident_flags line 15." Thanks. Jiangfan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additio

Re: sprintf - Rounding down

2007-03-15 Thread Beginner
On 15 Mar 2007 at 8:05, Tom Phoenix wrote: > On 3/15/07, Beginner <[EMAIL PROTECTED]> wrote: > > > For some reason my sprintf usage is not returning the numbers I had > > expected and appears to be rounding down. Is there something wrong > > with my formatting be

Re: sprintf - Rounding down

2007-03-15 Thread Tom Phoenix
On 3/15/07, Beginner <[EMAIL PROTECTED]> wrote: For some reason my sprintf usage is not returning the numbers I had expected and appears to be rounding down. Is there something wrong with my formatting below. my $ksize = sprintf("%.2f",$size/1024);

sprintf - Rounding down

2007-03-15 Thread Beginner
Hi, For some reason my sprintf usage is not returning the numbers I had expected and appears to be rounding down. Is there something wrong with my formatting below. === code snip == my ($x,$y) = imgsize($fqn); my $size = $x*$y*3; my

Re: sprintf and printf in Perl

2006-09-14 Thread jeffhua
Hello, The simple difference is,'sprintf' format the strings and pass the result to a variable. $ perl -e 'my $var=sprintf "%30s\n","hello,world";print $var' hello,world While 'printf' print the result directly to

sprintf and printf in Perl

2006-09-14 Thread chen li
Hi all, First of all I want to thank you all for reading and replying my previous posts. Now I come across to another problem: I want to print out a AoA. If I use printf I get what I expect. If I use sprintf for string I get error messages but the remaining still look OK. But If use sprintf

Re: Leading zero with sprintf and option "f".

2006-07-05 Thread Mumia W.
John Hennessy wrote: [...] I am using %03.4f to provide output that looks like 100. I would like number less than 100. to look like 099. I would like to keep the 3 digits prior to the decimal point either with or without the leading zero as required. Any suggestions welcomed. Than

Re: Leading zero with sprintf and option "f".

2006-07-05 Thread John W. Krahn
John Hennessy wrote: > Hi, how is it possible to prefix a leading zero to the $Count result > below when this value is less than 100. ? > > > while ($count < 110.000) { >$count += 10; >$Count = sprintf "%03.4f", $count; >print "Count is

Leading zero with sprintf and option "f".

2006-07-05 Thread John Hennessy
Hi, how is it possible to prefix a leading zero to the $Count result below when this value is less than 100. ? while ($count < 110.000) { $count += 10; $Count = sprintf "%03.4f", $count; print "Count is now $Count\n"; } I am using %03.4f to provide output t

Re: Help with sprintf

2005-09-12 Thread John W. Krahn
Kevin Old wrote: > Hello everyone, Hello, > I'm having trouble with sprintf. I know it's some silly mistake I'm > making, but can't seem to figure it out. > > Here's what I have: > > my @time = localtime(); > $time[4]++; > $time[5]

Re: Help with sprintf

2005-09-12 Thread Octavian Rasnita
- Original Message - Hello everyone, I'm having trouble with sprintf. I know it's some silly mistake I'm making, but can't seem to figure it out. Here's what I have: my @time = localtime(); $time[4]++; $time[5] += 1900; my $lastmonday = sprintf("%0

Re: Help with sprintf

2005-09-12 Thread Wijaya Edward
- Original Message - From: Kevin Old <[EMAIL PROTECTED]> Date: Tuesday, September 13, 2005 5:31 am Subject: Help with sprintf > Hello everyone, Hello, > My result is: 20050901, but what I'm trying to get is 050901. > You can try with two possibilities: 1. Using

Help with sprintf

2005-09-12 Thread Kevin Old
Hello everyone, I'm having trouble with sprintf. I know it's some silly mistake I'm making, but can't seem to figure it out. Here's what I have: my @time = localtime(); $time[4]++; $time[5] += 1900; my $lastmonday = sprintf("%02d", $time[5]) . sprintf(&quo

Re: sprintf is now working

2005-05-18 Thread Jean-Sébastien Guay
Hi Derek, sprintf ("%.03f",($now - (stat("${hdir}${file}"))[9])/86400); sprintf prints to a string, so you need to assign its return value to something... or print it... or simply switch to printf. my $value = sprintf( ... ); print $value; or print sprin

RE: sprintf is now working

2005-05-18 Thread Charles K. Clarkson
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> wrote: : I am getting this error, can anyone help? : : sprintf ("%.03f",($now - (stat("${hdir}${file}"))[9])/86400); Use either of these: print sprintf "%.03f", ( $now - ( stat( "${hdir}

sprintf is now working

2005-05-18 Thread DBSMITH
I am getting this error, can anyone help? thanks derek # perl -c dir.pl Useless use of sprintf in void context at dir.pl line 29. dir.pl syntax OK #!/usr/bin/perl use strict; use warnings; use Time::localtime; $ENV{"PATH"} = qq(/opt/SUNWsamfs/sbin:/usr/bin:/usr/sbin:/usr/local/log);

RE: Perl cant add up with sprintf ?

2004-11-26 Thread ext-Chetak.Sasalu
I have an 11 digit number. I want to add another number to it and format to 11 digits as well. my $amount1 = 14313562897; my $amount2 = 0013625; $amount = sprintf("%011d", $amount1 + $amount2); print $amount."\n"; The answer perl gives me is -01 How can t

Re: Perl cant add up with sprintf ?

2004-11-25 Thread Oliver Schnarchendorf
On Fri, 26 Nov 2004 17:47:25 +1100, David Clarke wrote: > As well, if the large number starts with 0, I get an "Illegal octal > digit '8' at test.pl line 2, at end of line". Sorry, forgot this one. A number can't start with a zero (except if it is in front of a comma). If a number starts with a z

Re: Perl cant add up with sprintf ?

2004-11-25 Thread Oliver Schnarchendorf
On Fri, 26 Nov 2004 17:47:25 +1100, David Clarke wrote: > my $amount1 = 14313562897; > my $amount2 = 0013625; > $amount = sprintf("%011d", $amount1 + $amount2); > print $amount."\n"; > > The answer perl gives me is -01 > How can this be ? >

Re: Perl cant add up with sprintf ?

2004-11-25 Thread Edward WIJAYA
Hi Dave, my $amount2 = 0013625; As you pointed already. 0 is an octal constant $amount = sprintf("%011d", $amount1 + $amount2); and: printf "%d" casts to a signed int unfortunately the printf interface doesn't give a good way to say "deal with this num

Perl cant add up with sprintf ?

2004-11-25 Thread David Clarke
I have an 11 digit number. I want to add another number to it and format to 11 digits as well. my $amount1 = 14313562897; my $amount2 = 0013625; $amount = sprintf("%011d", $amount1 + $amount2); print $amount."\n"; The answer perl gives me is -01 How can th

RE: sprintf query

2004-11-24 Thread Michael Kraus
G'day... > Does anyone know how to format a string so that the spaces are padded > on the right, not the left. > > Im using $dates = sprintf("%64s", $dates); > > this right justifies the data and pads the left with spaces. > I need the other way around - l

sprintf query

2004-11-24 Thread David Clarke
Does anyone know how to format a string so that the spaces are padded on the right, not the left. Im using $dates = sprintf("%64s", $dates); this right justifies the data and pads the left with spaces. I need the other way around - left justified and padded with spaces on

RE: Help with sprintf and prinf

2004-10-21 Thread A Taylor
gt; > Can anyone give me a simple example of this - i am not having any joy > by myself :s Please learn how to use perldoc, Google, &/or books. The first hit on a Google search for "perldoc sprintf" gives this: # Round number to 3 digits after decimal point $roun

Re: Help with sprintf and prinf

2004-10-21 Thread Chris Devers
to do is > format a number into a currency, so 9.9 would be printed as 9.90 > > Can anyone give me a simple example of this - i am not having any joy > by myself :s Please learn how to use perldoc, Google, &/or books. The first hit on a Google search for "perldoc sprintf"

Help with sprintf and prinf

2004-10-21 Thread A Taylor
Hi all, I am trying to figure out sprint and prinf: what I am trying to do is format a number into a currency, so 9.9 would be printed as 9.90 Can anyone give me a simple example of this - i am not having any joy by myself :s Thanks in advance Anadi

Help with sprintf and prinf

2004-10-21 Thread A Taylor
Hi all, I am trying to figure out sprint and prinf: what I am trying to do is format a number into a currency, so 9.9 would be printed as 9.90 Can anyone give me a simple example of this - i am not having any joy by myself :s Thanks in advance Anadi

Help with sprintf and prinf

2004-10-21 Thread A Taylor
Hi all, I am trying to figure out sprint and prinf: what I am trying to do is format a number into a currency, so 9.9 would be printed as 9.90 Can anyone give me a simple example of this - i am not having any joy by myself :s Thanks in advance Anadi

Help with sprintf and prinf

2004-10-21 Thread A Taylor
Hi all, I am trying to figure out sprint and prinf: what I am trying to do is format a number into a currency, so 9.9 would be printed as 9.90 Can anyone give me a simple example of this - i am not having any joy by myself :s Thanks in advance Anadi

Re: printf sprintf

2004-01-09 Thread david
R. Joseph Newton wrote: > All the use one could imagine. The printf function can print pretty much > anywhere. I believe that it preceded sprintf historically, but I wouldn't > swear > > Many C coders have told me that it is the most efficient way to > write files.

Re: printf sprintf

2004-01-08 Thread R. Joseph Newton
Paul Kraus wrote: > What is the difference. The only I see is that printf can take a filehandle? > But what use would that be. All the use one could imagine. The printf function can print pretty much anywhere. I believe that it preceded sprintf historically, but I wouldn't swear to

Re: printf sprintf

2004-01-08 Thread Wiggins d Anconia
> Wiggins D Anconia wrote: > > > > Notice the difference in the docs: > > > > printf FILEHANDLE FORMAT, LIST > > printf FORMAT, LIST > > > > In the first there is NO comma following the filehandle, this means it > > is interpreted in a different manner than the rest of the argument list, > > or p

Re: printf sprintf

2004-01-08 Thread Rob Dixon
Wiggins D Anconia wrote: > > Notice the difference in the docs: > > printf FILEHANDLE FORMAT, LIST > printf FORMAT, LIST > > In the first there is NO comma following the filehandle, this means it > is interpreted in a different manner than the rest of the argument list, > or probably to be more pre

Re: printf sprintf

2004-01-08 Thread Rob Dixon
Wiggins D Anconia wrote: > > Notice the difference in the docs: > > printf FILEHANDLE FORMAT, LIST > printf FORMAT, LIST > > In the first there is NO comma following the filehandle, this means it > is interpreted in a different manner than the rest of the argument list, > or probably to be more pre

RE: printf sprintf

2004-01-08 Thread Dan Muey
> > > What is the difference. The only I see is that printf can > > > > One difference is printf prints it's output and sprintf > returns it';s > value. > > > > printf ... > > my $formatted_goodies = sprintf ... > > > >

RE: printf sprintf

2004-01-08 Thread Wiggins d Anconia
> > What is the difference. The only I see is that printf can > > One difference is printf prints it's output and sprintf returns it';s value. > > printf ... > my $formatted_goodies = sprintf ... > > > take a filehandle? But what use would that be.

Re: printf sprintf

2004-01-08 Thread Wiggins d Anconia
> > What is the difference. The only I see is that printf can take a filehandle? > But what use would that be. > The filehandle tells printf where to print the result, aka which filehandle, by default STDOUT. Which doesn't have a purpose with sprintf since it returns i

RE: printf sprintf

2004-01-08 Thread Dan Muey
> What is the difference. The only I see is that printf can One difference is printf prints it's output and sprintf returns it';s value. printf ... my $formatted_goodies = sprintf ... > take a filehandle? But what use would that be. > To format the contents of it. For

printf sprintf

2004-01-08 Thread Paul Kraus
What is the difference. The only I see is that printf can take a filehandle? But what use would that be. Paul Kraus --- PEL Supply Company Network Administrator --- 800 321-1264 Toll Free 216 267-5775 Voice 216 267-6176 Fax www.pelsupply.com -

Re: sprintf question

2003-09-24 Thread John W. Krahn
Rmck wrote: > > How do you use a shell command in a sprintf. Im trying to add the week of the > year to the end of my file name: > > my $logfile = sprintf '/var/sno/weeks/week_'. `date +%W`.'/%02d%02d%02d%02d%02d.sno', > $year % 100, $mon + 1, $day,

Re: sprintf question

2003-09-23 Thread Jeff 'japhy' Pinyan
On Sep 23, rmck said: >my $logfile = sprintf '/var/sno/weeks/week_'. `date >+%W`.'/%02d%02d%02d%02d%02d.sno', > $year % 100, $mon + 1, $day, $hour, $min; > >It like its putting in a return in the $logfile?? Thanks Up front. Yes, it is, because `...` retu

sprintf question

2003-09-23 Thread rmck
How do you use a shell command in a sprintf. Im trying to add the week of the year to the end of my file name: my $logfile = sprintf '/var/sno/weeks/week_'. `date +%W`.'/%02d%02d%02d%02d%02d.sno', $year % 100, $mon + 1, $day, $hour, $min; but when it is used I get: ba

Re: sprintf and wanting NO leading zero on a decimal less than 1( ie, .15 prints as .15 and not 0.15)

2003-07-30 Thread Rob Dixon
Rob Hanson wrote: > > I am trying to get .15 and end up with 0.15. > > I don't believe that ".15" is a valid floating point value, I think there > always has to be at least one digit to the left of the decimal... so the "f" > format won't help. perl -e "print .15" OUTPUT 0.15 :) Rob --

Re: sprintf and wanting NO leading zero on a decimal less than 1(ie, .15 prints as .15 and not 0.15)

2003-07-30 Thread Rob Dixon
David --- Senior Programmer Analyst --- Wgo Wagner wrote: > I am trying to get .15 and end up with 0.15. I have tried a number of combinations > of sprintf and %f. > > sprintf "%.2f" > sprintf "%2.2f" > sprintf "% .2f" > sprintf "% 2.f&q

RE: sprintf and wanting NO leading zero on a decimal less than 1( ie, .15 prints as .15 and not 0.15)

2003-07-30 Thread Hanson, Rob
ve the problem since I don't know that sprintf will help you here. $val = sprintf("%.2f", $val); $val =~ s/^0//; Rob -Original Message- From: Wagner, David --- Senior Programmer Analyst --- WGO [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 30, 2003 1:09 PM To: Beginner P

sprintf and wanting NO leading zero on a decimal less than 1(ie, .15 prints as .15 and not 0.15)

2003-07-30 Thread Wagner, David --- Senior Programmer Analyst --- WGO
I am trying to get .15 and end up with 0.15. I have tried a number of combinations of sprintf and %f. sprintf "%.2f" sprintf "%2.2f" sprintf "% .2f" sprintf "% 2.f" and I always get a 0.15. Do I

RE: Round/sprintf

2003-07-30 Thread Dan Muey
n't seem to remember the round type functions name and > am always screwy with sprintf. > : > : What combo of sprintf() and round() or whatever would do > what I'm trying to accomplish? > > sprintf will do a fair job of rounding for you. See the following > docum

Re: Round/sprintf

2003-07-30 Thread Casey West
e and am always screwy with sprintf. : : What combo of sprintf() and round() or whatever would do what I'm trying to accomplish? sprintf will do a fair job of rounding for you. See the following document: perldoc -q round But basically, you could do: my $rounded = sprintf '

Round/sprintf

2003-07-30 Thread Dan Muey
If I have a number like so: 5.8592675 I need to make it a x.xx instead of x.x and I need to round it up to the next hundredth like so : 5.86 I can't seem to remember the round type functions name and am always screwy with sprintf. What combo of sprintf() and round() or whatever

RE: Sprintf help

2003-07-01 Thread Dan Muey
Thanks for the quick replies guys: sprintf "%03d", $num Did the trick, I need to study that a bit more to I think. Thanks Dan > Howdy all, > > I know I'm being a puts but I can't for the life of me get > sprintf to do my bidding. > > What I'm tr

RE: Sprintf help

2003-07-01 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Dan Muey wrote: > Howdy all, > > I know I'm being a puts but I can't for the life of me get sprintf to > do my bidding. > > What I'm tryng to do is take a number, say 5 or 10 and make them > three digits long with Zeros on the left: > > IE >

Sprintf help

2003-07-01 Thread Dan Muey
Howdy all, I know I'm being a puts but I can't for the life of me get sprintf to do my bidding. What I'm tryng to do is take a number, say 5 or 10 and make them three digits long with Zeros on the left: IE 5 would become 005 And 10 would become 010 my $five = 5; my $te

RE: floating-point number on the right side with sprintf

2003-01-16 Thread Beau E. Cox
Hi - > -Original Message- > From: Konrad Foerstner [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, January 15, 2003 11:27 AM > To: [EMAIL PROTECTED] > Subject: floating-point number on the right side with sprintf > > > Hi, > > I have a problem with formati

floating-point number on the right side with sprintf

2003-01-16 Thread Konrad Foerstner
Hi, I have a problem with formating my output. I use sprintf to format a floating-point number. My output with "%.4f" looks like this: 111.5611 21.4870 10.7046 8.8443 8.6823 but I would like to see it that way: 111.5611 21.4870 10.7046 8.8443 8.6823 So,

RE: floating-point number on the right side with sprintf

2003-01-15 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Konrad Foerstner wrote: > Hi, > > I have a problem with formating my output. I use sprintf to format a > floating-point number. My output with "%.4f" looks like this: > > 111.5611 > 21.4870 > 10.7046 > 8.8443 > 8.6823 > > but I would like to see it

floating-point number on the right side with sprintf

2003-01-15 Thread Konrad Foerstner
Hi, I have a problem with formating my output. I use sprintf to format a floating-point number. My output with "%.4f" looks like this: 111.5611 21.4870 10.7046 8.8443 8.6823 but I would like to see it that way: 111.5611 21.4870 10.7046 8.8443 8.6823 So,

Re: sprintf question

2001-07-17 Thread Abdulaziz Ghuloum
L PROTECTED]> wrote: > Hi, > Anybody know the right syntax to left justify a string with zeros using > sprintf ot any other function? $test = "mytest"; > $test = sprintf "0%24s", $test; > print "test"; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: sprintf question

2001-07-17 Thread Jeff 'japhy' Pinyan
On Jul 17, F.H said: >$test = sprintf "0%24s", $test; > >I am getting only one zero. Your 0 is misplaced. sprintf '%024s', $test; -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ I am Marillion, the wielder of Ringril,

sprintf question

2001-07-17 Thread F.H
Hi, Anybody know the right syntax to left justify a string with zeros using sprintf ot any other function? $test = "mytest"; $test = sprintf "0%24s", $test; print "test"; I am getting only one zer

RE: Format & Sprintf

2001-07-02 Thread Wagner-David
[mailto:[EMAIL PROTECTED]] Sent: Monday, July 02, 2001 12:11 To: [EMAIL PROTECTED] Subject: Format & Sprintf Hello, The following is based on the first example in Programming Perl, and have a question about some of the syntax (and or why it was doen this way) $grades{$student} .= $g

Format & Sprintf

2001-07-02 Thread David Gilden
Hello, The following is based on the first example in Programming Perl, and have a question about some of the syntax (and or why it was doen this way) $grades{$student} .= $grade . " "; Why not $grades{$student} = $grade; Why the concatenation and the extra space? $average = spr

Re: sprintf

2001-05-31 Thread Brett W. McCoy
On Thu, 31 May 2001, Nichole Bialczyk wrote: > i know that for numbers you can use sprintf %u, %i etc > > is there something similair for alphnumerics? %s is used to print a string, %c is used to print a character, %% is used to print a percent sign... To learn more about spri

Re: sprintf

2001-05-31 Thread Ken
%s prints out strings For a complete list look at: perldoc -f sprintf Skip to the part that begins(about the second 24 line page): Perl's "sprintf" permits the following universally-known conversions - Original Message - From: "Nichole Bialczyk" <[E

  1   2   >