Oh wise Monks,
I have a script below which i wish to play around but I cant even get it to open! When execute I recieve the following error
"Can't open /path/of/file/filename.ext! at ./modi.pl line 11."
now is it the case that the path has to be entered inside the script. I much rather have the user enter the path at the terminal. How would I do this?
As always Monks your advise is really appreciated.
#!/usr/bin/perl use File::stat; # Declare variables my $filename; my $FILE_HANDLE; my $file_stat; my $current_time; my $diff_seconds; $filename = '/path/of/file/filename.ext'; # Open the file open ($FILE_HANDLE, $filename) or die "Can't open $filename!"; # Get the file status structure $file_stat = stat($FILE_HANDLE); # Get the current time $current_time = time; # Get the elapsed time in seconds $diff_seconds = time - $file_stat->mtime; # Do whatever you want with the $diff_seconds print "\n$filename was modified $diff_seconds seconds back.\n"; # All done

In reply to Error executing by Nathan_84

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.