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

Discussion in 'Perl Misc' started by Buteo Lagopus, Jun 25, 2003.

  1. 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
    Buteo Lagopus, Jun 25, 2003
    #1
    1. Advertising

  2. Buteo Lagopus

    Keith Keller Guest

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

    - --
    -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-----
    Keith Keller, Jun 25, 2003
    #2
    1. Advertising

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



    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
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Jun 25, 2003
    #3
  4. Buteo Lagopus

    Cat Guest

    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");
    Cat, Jul 17, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TS
    Replies:
    1
    Views:
    2,193
    Steven Cheng[MSFT]
    Jan 25, 2006
  2. Victor Bazarov
    Replies:
    0
    Views:
    721
    Victor Bazarov
    Jun 24, 2003
  3. mp
    Replies:
    24
    Views:
    813
    Floyd L. Davidson
    May 3, 2006
  4. Dennis van Oosterhout

    Re: os.system('cls')

    Dennis van Oosterhout, Dec 25, 2008, in forum: Python
    Replies:
    0
    Views:
    514
    Dennis van Oosterhout
    Dec 25, 2008
  5. J Peyret
    Replies:
    10
    Views:
    423
    Steven D'Aprano
    Mar 19, 2011
Loading...

Share This Page