Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8740547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:08:55+00:00 2026-06-13T11:08:55+00:00

(New to perl) I’m trying to update an existing perl script to store in

  • 0

(New to perl)

I’m trying to update an existing perl script to store in a file the last time that it was run, in order to do something “since” that date on the next run.

Is there a safe way to store this in a file that I can then read into a timestamp again?

I’ve found out how to write files

# Open for writing
open(MYFILE,">$filepath/$filename") || "> ERROR: Couldn't open file for writing\n";
print MYFILE $result;
close MYFILE;

And also how to get the time as a string

my ($sec, $min, $hour, $day, $mon, $year) = localtime();
$LAST_RUN_DATETIME=strftime( "%Y/%m/%d %T", $sec, $min, $hour, $day, $mon, $year);

Thanks for your time

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:08:56+00:00Added an answer on June 13, 2026 at 11:08 am

    I would write something like this probably:

    open(my $handle, ">", "$filepath/$filename") or die "Couldn't open $file";
    print $handle scalar(localtime());
    close($handle);
    

    and to read it in is just:

    open(my $handle, "$filepath/$filename") or die "Couldn't open $file";
    my $timestamp = <$handle>;
    

    That timestamp will be in this form: (day of the week) mmm (day of the month) hh:mm:ss yyyy

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Perl. I get the following error when I run a script:
What are the concepts that must be known by a new Perl developer for
New to Perl, I'm trying to define a subset of characters and then output
I'm very new to perl so I searched for some time but still get
Sorry im new in perl and cannot find a similar answer. html file <div
I am new to perl/html. This is from a perl file. This button is
I am relatively new to Perl.I have been trying to insert data to database
I'm new to Perl and regular expressions and I am having a hard time
I'm new to Perl and playing around screen scraping and regex. I'm trying to
I'm having a very strange error. I run a perl script which executes linux

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.