Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > system("clear"); vs. system("cls");

Reply
Thread Tools

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

 
 
Buteo Lagopus
Guest
Posts: n/a
 
      06-25-2003
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
 
Reply With Quote
 
 
 
 
Keith Keller
Guest
Posts: n/a
 
      06-25-2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In article <Xns93A5B9537156Ayoycomcastnet@206.127.4.25>, Buteo Lagopus wrote:
> 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

- --
http://www.velocityreviews.com/forums/(E-Mail 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

iEYEARECAAYFAj76IicACgkQhVcNCxZ5ID8NzwCgmgp6KoKCOu bYaRWjTmwztbSc
zfUAoI3Cr9O7Cq1yW/KFAmLte7wtb50E
=MV3d
-----END PGP SIGNATURE-----
 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      06-25-2003
Buteo Lagopus <(E-Mail Removed)> wrote:

> 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.


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Cat
Guest
Posts: n/a
 
      07-17-2003
Buteo Lagopus wrote:
>
> 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");
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments