interactive mode ` ` in perl script

Discussion in 'Perl' started by DGG, Mar 2, 2005.

  1. DGG

    DGG Guest

    I have got a question arsing from my perl program.

    Basically, I want to get the machine date and time, and display it on a
    Tk label.

    I am using ActivePerl, and running on DOS/Windows.
    So I would use `date` to get the current date.

    Though "date" has a silent mode. I am thinking in general, if assume
    "date" only has an interactive mode. So after typing in "date", after
    displaying the current date, the program also awaits an input (new date
    setting or an ENTER) to complete.

    As we are running inside a perl script, how can one imitate an
    interactive input to feed into the program input?

    Thanks guys
     
    DGG, Mar 2, 2005
    #1
    1. Advertising

  2. DGG

    Jim Gibson Guest

    In article <>, DGG
    <> wrote:

    > I have got a question arsing from my perl program.
    >
    > Basically, I want to get the machine date and time, and display it on a
    > Tk label.
    >
    > I am using ActivePerl, and running on DOS/Windows.
    > So I would use `date` to get the current date.
    >
    > Though "date" has a silent mode. I am thinking in general, if assume
    > "date" only has an interactive mode. So after typing in "date", after
    > displaying the current date, the program also awaits an input (new date
    > setting or an ENTER) to complete.
    >
    > As we are running inside a perl script, how can one imitate an
    > interactive input to feed into the program input?


    There is no need to use an external command to get the date and time.
    Use the Perl function localtime and perhaps one of the many
    time-manipulation modules available from CPAN (like DateTime), or the
    POSIX strftime function.

    FYI: this newsgroup is defunct. Try comp.lang.perl.misc in the future,
    and comp.lang.perl.tk for questions about Perl/TK.


    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= East/West-Coast Server Farms - Total Privacy via Encryption =---
     
    Jim Gibson, Mar 2, 2005
    #2
    1. Advertising

  3. DGG

    Joe Smith Guest

    DGG wrote:

    > I am using ActivePerl, and running on DOS/Windows.
    > So I would use `date` to get the current date.


    I take it that you haven't tried using localtime() in scalar mode.
    $date_as_a_string = localtime;

    You should learn the difference between
    print localtime(),"\n";
    and
    print localtime()."\n";
     
    Joe Smith, Mar 3, 2005
    #3
  4. DGG

    DGG Guest

    Thanks. I would never know this group is defunct now
     
    DGG, Mar 4, 2005
    #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. Alex
    Replies:
    1
    Views:
    334
    Peter Hansen
    Sep 9, 2005
  2. John J Lee
    Replies:
    3
    Views:
    524
    bruno at modulix
    Dec 1, 2005
  3. Pankaj
    Replies:
    3
    Views:
    650
    Sybren Stuvel
    Jan 23, 2006
  4. Edward Loper
    Replies:
    0
    Views:
    510
    Edward Loper
    Aug 7, 2007
  5. Himanshu
    Replies:
    0
    Views:
    958
    Himanshu
    Nov 18, 2009
Loading...

Share This Page