system("clear"); vs. system("cls");

B

Buteo Lagopus

Using ActiveState Perl 5.8.0, system("clear"); raises an error on Win2k
Pro: "clear is not recognized as an internal or external command, operable
program or batch file." but that's what perldoc says to use.

I tried system("cls"); and it worked correctly.

Is perldoc in error or is this an OS port issue? I'd hope this won't cause
cross-platform problems.

Any thoughts?

Thanks,

Andy
 
K

Keith Keller

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Using ActiveState Perl 5.8.0, system("clear"); raises an error on Win2k
Pro: "clear is not recognized as an internal or external command, operable
program or batch file." but that's what perldoc says to use.

perldoc -f system

which will refer you to

perldoc -f exec

the first line of which may be illuminating.
Is perldoc in error or is this an OS port issue? I'd hope this won't cause
cross-platform problems.

Using system() is one of the easier ways to cause cross-platform
problems, especially across unix-like and Win32-like systems.

- --keith

- --
(e-mail address removed)-francisco.ca.us
(try just my userid to email me)
alt.os.linux.slackware FAQ: http://wombat.san-francisco.ca.us/cgi-bin/fom

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAj76IicACgkQhVcNCxZ5ID8NzwCgmgp6KoKCOubYaRWjTmwztbSc
zfUAoI3Cr9O7Cq1yW/KFAmLte7wtb50E
=MV3d
-----END PGP SIGNATURE-----
 
T

Tad McClellan

Buteo Lagopus said:
Using ActiveState Perl 5.8.0, system("clear"); raises an error on Win2k
Pro: "clear is not recognized as an internal or external command, operable
program or batch file." but that's what perldoc says to use.


Because that is what you should use on unix.

I tried system("cls"); and it worked correctly.


Because that is what you should use on windows.

Is perldoc in error or is this an OS port issue?


It is an OS port issue.

I'd hope this won't cause
cross-platform problems.


It most certainly will cause cross-platform problems, the same
as system('ls') vs. system('dir')...

How to clear a display is going to depend a great deal on which
display it is that is doing the displaying. :)
 
C

Cat

Buteo said:
Using ActiveState Perl 5.8.0, system("clear"); raises an error on Win2k
Pro: "clear is not recognized as an internal or external command, operable
program or batch file." but that's what perldoc says to use.

I tried system("cls"); and it worked correctly.

Is perldoc in error or is this an OS port issue? I'd hope this won't cause
cross-platform problems.

Try this....

#!/bin/perl
use strict;
use warnings;
use diagnostics;

my ($screen_clear, $file_remove, $file_copy, $file_move);

if ($^O =~ /MSWin32/) {
#
# Set up Windows variables
#
$screen_clear = "cls";
$file_remove = "del";
$file_copy = "copy";
$file_move = "move";
}
else {
#
# Set up UNIX variables
#
$screen_clear = "clear";
$file_remove = "rm";
$file_copy = "cp";
$file_move = "rm";
}


system("$screen_clear");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,037
Latest member
MozzGuardBugs

Latest Threads

Top