CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Win32 Programming Help:
How to modify this perl script and make it running in Linux , solaris and windowXP?

 



wxfjordan
Novice

Jun 26, 2006, 12:31 AM

Post #1 of 5 (3700 views)
How to modify this perl script and make it running in Linux , solaris and windowXP? Can't Post

Hello All:

I want this perl script to run in Linux, solaris and windowXP. How to modify this script and make it running in different OS.

Hope some Perl senior help me.

Thanks!!!!

#!/usr/bin/perl -w

use Win32:: DriveInfo;

if ( $^O =~ /^(MS)?Win/ )
{

$TotalNumberOfFreeBytes = (Win32:: DriveInfo:: DriveSpace('c:'))[6];
$TotalNumberOfBytes = (Win32:: DriveInfo:: DriveSpace('c:'))[5];

print "This is $^O \n";
print "Total Free: $TotalNumberOfFreeBytes\tTotal size: $TotalNumberOfBytes\n";

}
elsif ( $^O =~ /^linux/ )
{
print "This is Linux OS!!!\n";
}


wxfjordan
Novice

Jun 26, 2006, 8:21 PM

Post #2 of 5 (3693 views)
Re: [wxfjordan] How to modify this perl script and make it running in Linux , solaris and windowXP? [In reply to] Can't Post

 I have modified like this:

#!/usr/bin/perl -w

if ( $^O =~ /^(MS)?Win/ )
{
eval{
require Win32:: DriveInfo;

$TotalNumberOfFreeBytes = (Win32:: DriveInfo:: DriveSpace('c:'))[6];
$TotalNumberOfBytes = (Win32:: DriveInfo:: DriveSpace('c:'))[5];

print "This is $^O \n";
print "Total Free: $TotalNumberOfFreeBytes\tTotal size: $TotalNumberOfBytes\n";
};
print $@,"\ndone!";
}
elsif ( $^O =~ /^linux/ )
{
print "This is Linux OS!!!\n";
}

This modified perl script can execute successful in linux,
but print out a message when I execute this Perl script in windoowXP.

Too late to run INIT block at C:/Perl/site/lib/Win32/API/Type.pm line 71.

This is MSWin32
Total Free: 26845294592 Total size: 31461662720

done!


How to solve the first message in windowXP :

Too late to run INIT block at C:/Perl/site/lib/Win32/API/Type.pm line 71.


wxfjordan
Novice

Jun 27, 2006, 6:42 PM

Post #3 of 5 (3686 views)
Re: [wxfjordan] How to modify this perl script and make it running in Linux , solaris and windowXP? [In reply to] Can't Post

 
Heck!!! I am Perl beginner. Why nobody answer me? Man!!!

FrownFrownFrown


davorg
Thaumaturge / Moderator

Jun 28, 2006, 2:10 AM

Post #4 of 5 (3684 views)
Re: [wxfjordan] How to modify this perl script and make it running in Linux , solaris and windowXP? [In reply to] Can't Post


In Reply To
Heck!!! I am Perl beginner. Why nobody answer me? Man!!!


I can't speak for everyone, but the reason that I haven't answered you is because I have no knowledge at all of the Win32 modules that you are using. Sorry about that.

If you want access to a larger set of Perl experts then you might like to try Perl Monks.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


wxfjordan
Novice

Jun 28, 2006, 9:32 PM

Post #5 of 5 (3675 views)
Re: [davorg] How to modify this perl script and make it running in Linux , solaris and windowXP? [In reply to] Can't Post

 
Thank you!!!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives