Re: Printing directory sizes

2009-03-05 Thread Gunnar Hjalmarsson
Gunnar Hjalmarsson wrote: Dermot wrote: This will only give you the top level of directories: 07/02/2009 14:00 . 07/02/2009 14:00 .. 07/02/2009 14:00 bin 15/03/2006 22:14 eg 07/02/2009 14:00 html 15/03/2006 22:15

Re: Printing directory sizes

2009-03-05 Thread Gunnar Hjalmarsson
Dermot wrote: This will only give you the top level of directories: 07/02/2009 14:00 . 07/02/2009 14:00 .. 07/02/2009 14:00 bin 15/03/2006 22:14 eg 07/02/2009 14:00 html 15/03/2006 22:15 lib 27/04/2005 21:32

Re: Copy file recursively

2009-03-05 Thread Octavian Râşniţă
Hi, Use File::Copy::Recursive: NAME File::Copy::Recursive - Perl extension for recursively copying files and directories SYNOPSIS use File::Copy::Recursive qw(fcopy rcopy dircopy fmove rmove dirmove); fcopy($orig,$new[,$buf]) or die $!; rcopy($orig,$new[,$buf]) or die $!;

Re: Printing directory sizes

2009-03-05 Thread Lauri Nikkinen
I had to add $total_size_of_files_in_dir = 0; because it was accumulating. Now it does what is should do and I get the correct results!!! ---code--- #!/bin/perl use warnings; use strict; use File::Find; my $path = $ARGV[0]; die "You must supply a full directory path" unless (-e $path && -d $pa

Re: Printing directory sizes

2009-03-05 Thread Dermot
2009/3/5 Lauri Nikkinen : > Thanks, although is does not change the differences between dir sizes from > this script and Win Explorer folder properties. This e.g. shows that one of > my folders has 88 mb size although in fact it is empty. Thank you all, I'll > give up... > > -L > You have to be do

Re: Printing directory sizes

2009-03-05 Thread Lauri Nikkinen
Thanks, although is does not change the differences between dir sizes from this script and Win Explorer folder properties. This e.g. shows that one of my folders has 88 mb size although in fact it is empty. Thank you all, I'll give up... -L 2009/3/5 Dermot > 2009/3/5 Gunnar Hjalmarsson : > > La

Re: Printing directory sizes

2009-03-05 Thread Lauri Nikkinen
Well, I tried also this, ...snip... foreach my $dir (@directories) { find(\&wanted, $dir); ### Not sure how that worked as you called it $directory print "The total size of the file in $dir is " . sprintf("%.2f Kb", ($total_size_of_files_in_dir * 0.0009765625)) . "\n";

Re: Printing directory sizes

2009-03-05 Thread Dermot
2009/3/5 Gunnar Hjalmarsson : > Lauri Nikkinen wrote: >> >> ... from this script I get >> >> The total size of the file in etc is 15712.35 Kb >> The total size of the file in etc is 15.34 Mb >> >> and when I check this from Win XP Explorer (folder properties) window I >> get >> >> Size: 372 KB (380

Re: Copy file recursively

2009-03-05 Thread Jim Gibson
On 3/5/09 Thu Mar 5, 2009 1:48 AM, "Rock Lifestyle" scribbled: > Hi , >   > My directory structure is like >   [snipped] >   > I want to copy some subdirectory and files under it to another directory it > should exactly create similar directory structure Use the File::Find and File::Cop

Re: hashes + use constant - weird behavior

2009-03-05 Thread Gunnar Hjalmarsson
Stanisław T. Findeisen wrote: #!/usr/bin/perl use warnings; use strict; use constant { SOME_CONSTANT => 'some value' }; my $index = 'some value'; my %hash = (); $hash{SOME_CONSTANT} = 'value 1'; $hash{$index} = 'value 2'; print("The value is: " . $hash{SOME_CONSTANT} . '/' . $hash{$index

Re: hashes + use constant - weird behavior

2009-03-05 Thread Chas. Owens
On Thu, Mar 5, 2009 at 12:23, "Stanisław T. Findeisen" wrote: > #!/usr/bin/perl > > use warnings; > use strict; > > use constant { >    SOME_CONSTANT => 'some value' > }; > snip > print("The value is: " . $hash{SOME_CONSTANT} . '/' . $hash{$index} . "\n"); snip SOME_CONSTANT is being interpreted

hashes + use constant - weird behavior

2009-03-05 Thread Stanisław T. Findeisen
#!/usr/bin/perl use warnings; use strict; use constant { SOME_CONSTANT => 'some value' }; my $index = 'some value'; my %hash = (); $hash{SOME_CONSTANT} = 'value 1'; $hash{$index} = 'value 2'; print("The value is: " . $hash{SOME_CONSTANT} . '/' . $hash{$index} . "\n"); print("Comparison 1:

Re: Printing directory sizes

2009-03-05 Thread Gunnar Hjalmarsson
Lauri Nikkinen wrote: ... from this script I get The total size of the file in etc is 15712.35 Kb The total size of the file in etc is 15.34 Mb and when I check this from Win XP Explorer (folder properties) window I get Size: 372 KB (380 928 bytes) What is the reason for this difference? Pr

Re: Copy file recursively

2009-03-05 Thread Swayam
On Thu, Mar 5, 2009 at 6:06 PM, Swayam wrote: > Hi , > > My directory structure is like > > ls -R temp > temp: > 2.1 2.2 cleanup setup > > temp/2.1: > 2.1.1cleanup setup > > temp/2.1/2.1.1: > setup cleanup 2.1.1.01 2.1.1.02 2.1.1.03 2.1.1.04 2.1.1.05 2.1.1.06 > 2.1.1.0

Re: Printing directory sizes

2009-03-05 Thread Lauri Nikkinen
Thanks. I modified the script again based on your suggestions. E.g. from this script I get The total size of the file in etc is 15712.35 Kb The total size of the file in etc is 15.34 Mb and when I check this from Win XP Explorer (folder properties) window I get Size: 372 KB (380 928 bytes) What

Copy file recursively

2009-03-05 Thread Swayam
Hi , My directory structure is like ls -R temp temp: 2.1 2.2 cleanup setup temp/2.1: 2.1.1cleanup setup temp/2.1/2.1.1: setup cleanup 2.1.1.01 2.1.1.02 2.1.1.03 2.1.1.04 2.1.1.05 2.1.1.06 2.1.1.07 2.1.1.08 temp/2.1/2.1.1/2.1.1.01: cleanup setuptest temp/2.1/2

Copy file recursively

2009-03-05 Thread Swayam
Hi , My directory structure is like ls -R temp temp: 2.1 2.2 cleanup setup temp/2.1: 2.1.1cleanup setup temp/2.1/2.1.1: setup cleanup 2.1.1.01 2.1.1.02 2.1.1.03 2.1.1.04 2.1.1.05 2.1.1.06 2.1.1.07 2.1.1.08 temp/2.1/2.1.1/2.1.1.01: cleanup setuptest temp/2.1/2

Re: Strange problem with substr() function and right aligned fields

2009-03-05 Thread Jenda Krynicky
From: "Bill Harpley" > My Comment: this is an obvious approach, with numerous advantages. > However, it requires installation of the BD:Oracle module, which can be > very tricky. > Basically, I started to install and configure all of this (Perl, > DBI,DB:Oracle) on HP-UX 11.31 but after 4 days I

Copy file recursively

2009-03-05 Thread Rock Lifestyle
--- On Thu, 5/3/09, Rock Lifestyle wrote: From: Rock Lifestyle Subject: Copy file recursively To: beginners@perl.org Date: Thursday, 5 March, 2009, 9:48 AM Hi ,   My directory structure is like   ls -R temp temp: 2.1  2.2  cleanup  setup   temp/2.1: 2.1.1    cleanup  setup   t

Strange problem with substr() function and right aligned fields

2009-03-05 Thread Bill Harpley
Jenda, Thanks for questioning my method of approach: > I must process the output of an SQL query using Perl. > > I know the column position of the data in the output file, which means > that I am able to calculate the width of each field. > > All of the data in the file is left-aligned to the

Re: Strange problem with substr() function and right aligned fields

2009-03-05 Thread Jenda Krynicky
From: "Bill Harpley" > I must process the output of an SQL query using Perl. > > I know the column position of the data in the output file, which means > that I am able to calculate the width of each field. > > All of the data in the file is left-aligned to the field, except for one > column. >

Copy file recursively

2009-03-05 Thread Rock Lifestyle
Hi ,   My directory structure is like   ls -R temp temp: 2.1  2.2  cleanup  setup   temp/2.1: 2.1.1    cleanup  setup   temp/2.1/2.1.1:   setup cleanup 2.1.1.01  2.1.1.02  2.1.1.03  2.1.1.04  2.1.1.05  2.1.1.06  2.1.1.07  2.1.1.08   temp/2.1/2.1.1/2.1.1.01: cleanup  setup    test   t

Re: How to release memory?

2009-03-05 Thread Deviloper
Do you ever join your threads? Which Perl-Version do you use? Try update to the latest. Threads had memoryleaks and might till have some. Bye, B.

Re: Printing directory sizes

2009-03-05 Thread Dermot
2009/3/4 Lauri Nikkinen : > Ok, thanks, I wrote this based on your suggestions, and it seems to do what > I want. One further question, if you don't mind, how to format this so that > it prints sizes in megabytes, not in bits? I tend to use this for kilobytes sprintf("%.2f Kb", ($size_in_bytes *

How to release memory?

2009-03-05 Thread yyq
Hello, Everybody, I have code as below. What the code does is receive a connection and get a file from it, It works ok, but the problem is every time it receives some files, the memory it occupied augment, and accumulates every time till it killed by system. I am beginer of perl, I can't explain w