mirror of
				https://codeberg.org/h3xx/simplify_static_dir
				synced 2024-08-14 23:57:24 +00:00 
			
		
		
		
	Add thousands separator commas to output
This commit is contained in:
		
							parent
							
								
									93561ca90a
								
							
						
					
					
						commit
						8059dc4455
					
				
					 2 changed files with 15 additions and 2 deletions
				
			
		|  | @ -12,6 +12,7 @@ All notable changes to this project will be documented in this file. | ||||||
| 
 | 
 | ||||||
| - Limit "Skipped" output to only summary | - Limit "Skipped" output to only summary | ||||||
| - Omit output of progress bar unless -v flag is present | - Omit output of progress bar unless -v flag is present | ||||||
|  | - Add thousands separator commas to output | ||||||
| 
 | 
 | ||||||
| ## [3.0.0] | ## [3.0.0] | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -238,8 +238,8 @@ MAIN: { | ||||||
|         $freed_bytes += $inst->bytes_freed; |         $freed_bytes += $inst->bytes_freed; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     printf STDERR "freed %d bytes (%0.4G %s)\n", |     printf STDERR "freed %s bytes (%0.4G %s)\n", | ||||||
|         $freed_bytes, |         Directory::Simplify::Utils::addcommas($freed_bytes), | ||||||
|         Directory::Simplify::Utils::hr_size($freed_bytes) |         Directory::Simplify::Utils::hr_size($freed_bytes) | ||||||
|             if $print_freed or $verbose; |             if $print_freed or $verbose; | ||||||
| } | } | ||||||
|  | @ -248,6 +248,18 @@ package Directory::Simplify::Utils; | ||||||
| use strict; | use strict; | ||||||
| use warnings; | use warnings; | ||||||
| 
 | 
 | ||||||
|  | sub addcommas { | ||||||
|  |     my @added; | ||||||
|  |     foreach my $num (@_) { | ||||||
|  |         # don't split anything after the decimal | ||||||
|  |         my @parts = split /\./, $num; | ||||||
|  |         while ($parts[0] =~ s/(\d)(\d{3}(?:\D|$))/$1,$2/) { | ||||||
|  |         } | ||||||
|  |         push @added, (join '.', @parts); | ||||||
|  |     } | ||||||
|  |     wantarray ? @added : $added[0] | ||||||
|  | } | ||||||
|  | 
 | ||||||
| sub hr_size { | sub hr_size { | ||||||
|     my $sz = shift; |     my $sz = shift; | ||||||
|     my @sizes = qw/ B KB MB GB TB PB EB ZB YB /; |     my @sizes = qw/ B KB MB GB TB PB EB ZB YB /; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue