]> git.nbdom.net Git - nb.git/commitdiff
Bed
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 2 Sep 2016 00:11:39 +0000 (01:11 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 2 Sep 2016 00:11:39 +0000 (01:11 +0100)
etc/profile.d/functions
lib/perl/NB/Functions.pm

index 2e94ff093c013cf96b231ac4221977d2d3194297..729c9ed5b29db7026b9cc88e594ab959b549cf34 100644 (file)
@@ -156,7 +156,10 @@ bytes2h() {
   in="cat"
   [ -z "$@" ] || in="echo $@"
 
-  $in | perl -pe 'BEGIN{
+  #use Number::Bytes::Human qw/&format_bytes/;
+  #s/$exp/bytes2h($1)/ge;
+  $in | perl -pe '
+BEGIN{
   use NB::Functions qw/&bytes2h/;
   $exp = "([\\d\\.]+)";
   if (@ARGV and $ARGV[0] =~ /regex=(\S+)/) {
@@ -164,7 +167,7 @@ bytes2h() {
     $exp = $1;
   }
 };
-s/$exp/bytes2h($1)/ge;
+0 and s/$exp/format_bytes($1)/ge
 ' $args
 }
 
index e89eda029c742f16eb4d08badc5c05a5eac9b3de..0ae50bc66b3a163f3f1585401b59ae8b0ff7282c 100644 (file)
@@ -280,9 +280,11 @@ sub bytes2h {
 
        if ($o >= 1099511627776) { return(sprintf('%.2fT',($o/1099511627776))); } # T
        elsif ($o >= 1073741824) { return(sprintf('%.2fG',($o/1073741824))); } # G
+       elsif ($o >= 1048576) { return(sprintf('%.1fM',($o/1048576))); } # M
        elsif ($o >= 1048576) { return(POSIX::ceil($o/1048576)."M"); } # M
        elsif ($o >= 1024) { return(POSIX::ceil($o/1024)."K"); } # K
-       else { return $o."bytes"; }
+# NB 02.09.16  else { return $o."bytes"; }
+       else { return $o; }
 
 }
 
@@ -436,9 +438,9 @@ sub db_connect {
 # NB 15.07.07 
 #------------------------------------------------------------------------------
 # Bug if delete - NB 24.02.12 my $opt = shift @_;
-my $opt = \%{$_[0]};
+my $opt = \%{$_[0]}; shift;
 my $iziopt;
-my @dbi = @NB::Globals::DBI;
+my @dbi = @_;
 
 require 'DBI.pm' unless $INC{'DBI.pm'};