Re: Printing directory sizes

2009-03-05 Thread Lauri Nikkinen
wanted { if (-f $_) { $total_size_of_files_in_dir += -s; } } sub size_in_mb { my $size_in_bytes = shift; return $size_in_bytes / (1024 * 1024); } ---code--- 2009/3/5 Dermot > 2009/3/5 Lauri Nikkinen : > > Thanks, although is does not change the differences between dir sizes &g

Re: Printing directory sizes

2009-03-05 Thread Lauri Nikkinen
lmarsson : > > 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 Explore

Re: Printing directory sizes

2009-03-05 Thread Lauri Nikkinen
my $size_in_bytes = shift; return $size_in_bytes / (1024 * 1024); } ...snip... same results and I can't figure out what would be the bug here. -L 2009/3/5 Gunnar Hjalmarsson > Lauri Nikkinen wrote: > >> ... from this script I get >> >> The total size of the file in etc

Re: Printing directory sizes

2009-03-05 Thread Lauri Nikkinen
ot;, ($total_size_of_files_in_dir * 0.0009765625)) . "\n"; print "The total size of the file in $dir is " . sprintf("%.2f Mb", ($total_size_of_files_in_dir * 9.5367431641e-7)) . "\n" } sub wanted { if (-f $_) { $total_size_of_files_in_dir +

Re: Printing directory sizes

2009-03-04 Thread Lauri Nikkinen
directory; find(\&wanted, $dir); print "The total size of the file in $directory is $total_size_of_files_in_dir bytes\n"; } sub wanted { if (-f $_) { $total_size_of_files_in_dir += -s; } } ---code--- -L 2009/3/4 Dermot > 2009/3/4 Lauri Nikkinen : > > Tha

Re: Printing directory sizes

2009-03-04 Thread Lauri Nikkinen
also. -L 2009/3/4 Dermot > 2009/3/3 Wagner, David --- Senior Programmer Analyst --- CFS > : > >> -Original Message- > >> From: lauri.nikki...@gmail.com > >> [mailto:lauri.nikki...@gmail.com] On Behalf Of Lauri Nikkinen > >> Sent: Tuesday, Ma

Re: Printing directory sizes

2009-03-03 Thread Lauri Nikkinen
Ok, thanks. Now I notice that I did not understand correctly what this script does. I was trying to print sizes of all directories in the directory tree. But anyway, I appreciate your kind help! -L 2009/3/3 Chas. Owens > On Tue, Mar 3, 2009 at 14:59, Lauri Nikkinen > wrote: > sn

Re: Printing directory sizes

2009-03-03 Thread Lauri Nikkinen
- > *From:* lauri.nikki...@gmail.com [mailto:lauri.nikki...@gmail.com] *On > Behalf Of *Lauri Nikkinen > *Sent:* Tuesday, March 03, 2009 13:00 > *To:* Chas. Owens > *Cc:* Wagner, David --- Senior Programmer Analyst --- CFS; Perl Beginners > *Subject:* Re: Printing directory siz

Re: Printing directory sizes

2009-03-03 Thread Lauri Nikkinen
and ( $size += -s _ ) }, $dir ); ~ > perl Print_directory_sizes.pl ~ > or ~ > perl Print_directory_sizes.pl Documents/ ~ > Do you know why? -L 2009/3/3 Chas. Owens > On Tue, Mar 3, 2009 at 14:47, Lauri Nikkinen > wrote: > > I uninstalled ActiveState Perl via Add/Remove Programs and i

Re: Printing directory sizes

2009-03-03 Thread Lauri Nikkinen
t; > From: lauri.nikki...@gmail.com > > [mailto:lauri.nikki...@gmail.com] On Behalf Of Lauri Nikkinen > > Sent: Tuesday, March 03, 2009 12:10 > > To: Wagner, David --- Senior Programmer Analyst --- CFS > > Cc: Perl Beginners > > Subject: Re: Printing directory sizes > > > >

Re: Printing directory sizes

2009-03-03 Thread Lauri Nikkinen
; my $size; find( sub { -f and ( $size += -s _ ) }, $dir ); ~ > perl Print_directory_sizes.pl invalid top directory at /System/Library/Perl/5.8.8/File/Find.pm line 592. So, something is wrong here also... Thank you for your help anyway... -L 2009/3/3 Chas. Owens > On Tue, Mar 3, 2009 at 1

Re: Printing directory sizes

2009-03-03 Thread Lauri Nikkinen
Ok, I typed C:\Perl>ppm query File to see that there is no File::Find module installed. It seems that ActiveState does not offer it via ppm, am I right? 2009/3/3 Lauri Nikkinen > Thanks, how can I check if the module File::find is installed on my system? > I can't locate i

Re: Printing directory sizes

2009-03-03 Thread Lauri Nikkinen
auri.nikki...@gmail.com > > [mailto:lauri.nikki...@gmail.com] On Behalf Of Lauri Nikkinen > > Sent: Tuesday, March 03, 2009 11:38 > > To: Perl Beginners > > Subject: Printing directory sizes > > > > Hi, > > > > I'm trying to print directory sizes using script

Printing directory sizes

2009-03-03 Thread Lauri Nikkinen
Hi, I'm trying to print directory sizes using script from http://coding.derkeiler.com/Archive/Perl/perl.beginners/2005-08/msg00693.html and when I try it from the cmd.exe C:\Perl>perl Print_directory_sizes.pl "C:/Temp" but I get an error message saying use of uninitialized value etc. Whe

Re: module to work with csv files

2009-03-01 Thread Lauri Nikkinen
Hi, Try these use Text::CSV; use Text::CSV_XS; use Tie::Handle::CSV; -L 2009/3/1 monnappa appaiah : > Hi all, > >         can somebody please suggest me a module to work with csv > files...majority of the function i use manually is sort, unique, pivot > table and also i shud be able to read

Re: Simplify a script which copies files

2009-02-26 Thread Lauri Nikkinen
Thank you for your reply. Yes, I was also thinking that, thanks. -L 2009/2/26 Yogesh Sawant : > > On Wed, Feb 25, 2009 at 6:14 PM, Lauri Nikkinen > wrote: >> >> Hi, >> >> I wrote a script which copies files in directory to an another >> directory based on

Simplify a script which copies files

2009-02-25 Thread Lauri Nikkinen
Hi, I wrote a script which copies files in directory to an another directory based on user input. Any suggestions to simplify or shorten this? I'm using Win XP. -L code - #!/bin/perl use warnings; use strict; use File::Copy; my $dire; my $destinatio

Re: Problem with parsing csv file and writing into two separate files

2008-11-18 Thread Lauri Nikkinen
f ($csv_line->{'Company'} =~ m/Middle./) { print OUTFILE2 $csv_line->{'Surname'} . ": " . $csv_line->{'Company'} . "\n"; } } close OUTFILE; close OUTFILE2; close $fh; #== 2008/11/18 Raymond Wan <[EMA

Problem with parsing csv file and writing into two separate files

2008-11-18 Thread Lauri Nikkinen
Hello, I would like to parse a .csv file and write certain records into two separate files. The program below writes the records easily into the csvtmp.csv but the second file is only created with no records written. I cannot see the problem here, the second file is produced easily if the first lo

Problem with parsing csv file and writing into two separate files

2008-11-17 Thread Lauri Nikkinen
Hello, I would like to parse a .csv file and write certain records into two separate files. The program below writes the records easily into the csvtmp.csv but the second file is only created with no records written. I cannot see the problem here, the second file is produced easily if the first lo

Re: Retrieve data via DBI and write into a file

2008-11-09 Thread Lauri Nikkinen
;; open OUTFILE, '>', $outfile or die "Unable to open $outfile: $!"; while(my @re = $sth->fetchrow_array) { print OUTFILE @re,"\n"; } close OUTFILE; $sth->finish(); $dbh->disconnect(); -L 2008/11/8 Rob Dixon <[EMAIL PROTECTED]&

Re: Retrieve data via DBI and write into a file

2008-11-07 Thread Lauri Nikkinen
open open OUTFILE, ">", $outfile or die "..."; # read the records line by line,and write them to the file while(my @re = $sth->fetchrow_array) { print OUTFILE @re,"\n"; } close OUTFILE; $sth->finish(); $dbh->disconnect(); 2008/11/7 Jeff P. <[EMAI

Retrieve data via DBI and write into a file

2008-11-07 Thread Lauri Nikkinen
Hello, First post to this forum. I'm trying to retrieve data via DBI and write it into a text file. Everything works fine with DBI but I don't know how to write query results into my text file. My code is here: ## #!/bin/perl use warnings; use strict; use DBI; my $dbs =