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> line 119503. line

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. line 139 is from my program

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 numeric in sprintf at ./rt_evdo_pcmd.pl

Re: sprintf function

2011-11-29 Thread Igor Dovgiy
googlesh "perl is_numeric" => http://www.perlmonks.org/?node_id=609478 qq{ Scalar::Util provides access to the underlying Perl API looks_like_number routine which Perl itself uses internally. } 2011/11/29 Chris Stinemetz > How can I check that t

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 first part, "%s%$Fmt%s", my understanding is the format part, > > which spe

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, > which specifies the formats for the second part, thelist part, ("% > $Fmt=

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 below. > > > my $ks

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); my $mbsize =

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 screen. $ perl -e 'printf "%30s\n","hello,world"'

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 sprintf( ... ); or printf( ... ); Damn

RE: sprintf is now working

2005-05-18 Thread Charles K. Clarkson
[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}${file}" ) )[9] ) / 86400; printf "%.03f", (

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 - left justified and padded with spaces o

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, $hour, $min; use POSIX qw( strftime );

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 `...` returns the program's output, which for da

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" > > and I always get a 0.15. > > Do I just remove with a reg

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
> 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. Using a regex might be the easiest way to solve the problem since I don't know t

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 tryng to do is take a number, say 5 or 10 and make

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 > 5 would become 005 > And 10 would become 010 > > my

Re: sprintf question

2001-07-17 Thread Abdulaziz Ghuloum
Hello, You can use something like: print lj("Hello", 30, '*') . "\n"; #prints Hello* sub lj{ return $_[0] . ($_[2]||' ') x ($_[1] - length $_[0]); } Aziz,,, In article <[EMAIL PROTECTED]>, "F.H" <[EMAIL PROTECTED]> wrote: > Hi, > Anybody know the right syntax

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, known as Hesinaur, the Winter-Sun. Are yo

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 sprintf, type 'perldoc

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" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTE