加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

perl printf

发布时间:2020-12-15 21:04:42 所属栏目:大数据 来源:网络整理
导读:#!/usr/bin/perl -w #one map one location. #####################format transfer char #%b???? == non symbol binary integer #%c???? == char #%d %i? == decimal integer #%e???? == scientific count #%E???? == scientific count with E #%f %F? == f

#!/usr/bin/perl -w #one map one location. #####################format transfer char #%b???? ==> non symbol binary integer #%c???? ==> char #%d %i? ==> decimal integer #%e???? ==> scientific count #%E???? ==> scientific count with E #%f %F? ==> float number #%g???? ==> fetch min width,using e or f transfer char #%G???? ==> fetch max width,using e or f transfer char #%id %D ==> long decimal integer #%lu %U ==> non symbol long decimal integer #%lo %O ==> long octal integer #%p???? ==> pointer (hexadecimal) #%s???? ==> string #%u???? ==> non symbol decimal number #%x???? ==> hexadecimal number #%X???? ==> hexadecimal number,using UPPER X #%1x??? ==> hexadecimal long integer #%%???? ==> print % #%o???? ==> octal integer # ######################mark decorate char #%-???? ==> left aligning? (default is right aligning) #%#???? ==> "0" leading char for octal,and "0x" for hexadecimal #%+???? ==> use d e f g transfer char,display part of integer,and positive and negative #%0???? ==> replace the blank to zero 0 #%number? ==> maximum column width,like %6d #%.number? ==> the precision of float number,like %.2f? like %4.2? ==> 33.33 #$s ==> conversion character,$d ==> decimal output # ########example: printf("The name is %s and the number is %dn","John",50); printf "Hello to you and yours %s n","Sam McGoo!";? #string printf ("%-15s %20s n","Jack n","Sprat n"); #left aligning and right aligning printf "The number in decimal is %d n",45;? #45 printf "The formatted number is | %10d | n",100; #"?????? 100" printf "The number printed with leading zeros is | %010d | n",5; #%0 => replace to 0,10 => max width,d? => decimal integer printf "Left-justified the number is | %-10d? | n",100;?? #left aligning and 10 maximum printf "The number in octal is %on",15;???? #17? ==> 8+7=15 printf "The number in hexadecimal is %x n",15;????? #f? ==> 16-1=15? hexadecimal? printf "The formatted floating point number is | %8.2f | n",14.3456;?? #14.35 printf "The floating point number is | %8f | n",15;? # 15.000000 printf "The character is %cn",65;?? #A? ascii(65) ==> A ######sprintf for var $string = sprintf("The name is: %10sn The number is: %8.2f n","Ellie",33); print "$string"; #The name is:????? Ellie # The number is:??? 33.00 #####like shell text compution $price=1000; #enable var quotes? print <<EOF; The consumer commented,"As I look over my budget,I'd say the price of $price is right. I'll give you $500 to start."n EOF #disable var quotes. print <<'FINIS'; The consumer commented,I'd say the price of $price is too much.n I'll settle for $500." FINIS #run the os commands use backquotes. print "nLet's execute some commands.n"; print <<`END`; echo "Today is" date END

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读