Perl Script to check file date and size

That looks ok as well.

What's the output of the following command ?

od -bc file_check.pl

tyler_durden

This is what i get:

-bash-3.2$ od -bc file_check.pl

0000000 012 043 041 057 165 163 162 057 154 157 143 141 154 057 142 151

         \n   #   !   /   u   s   r   /   l   o   c   a   l   /   b   i

0000020 156 057 160 145 162 154 012 163 165 142 040 103 150 145 143 153

          n   /   p   e   r   l  \n   s   u   b       C   h   e   c   k

0000040 151 156 147 106 151 154 145 163 173 012 012 040 040 040 040 040

          i   n   g   F   i   l   e   s   {  \n  \n

0000060 040 044 164 157 144 141 171 040 075 040 164 151 155 145 073 012

              $   t   o   d   a   y       =       t   i   m   e   ;  \n

0000100 040 040 040 040 040 040 044 164 157 144 141 171 040 055 075 040

                                  $   t   o   d   a   y       -   =

0000120 044 164 157 144 141 171 040 045 040 070 066 064 060 060 073 040

          $   t   o   d   a   y       %       8   6   4   0   0   ;

0000140 040 012 040 040 040 040 040 040 044 162 145 164 165 162 156 137

             \n                           $   r   e   t   u   r   n   _

0000160 166 141 154 165 145 040 075 040 060 073 012 040 040 040 040 040

          v   a   l   u   e       =       0   ;  \n

0000200 040 040 040 040 040 040 040 040 040 040 040 040 040 040 040 040



0000220 040 040 040 040 040 040 040 040 040 040 040 040 040 040 040 043

                                                                      #

0000240 040 040 012 040 040 040 040 040 040 044 155 164 151 155 145 040

                 \n                           $   m   t   i   m   e

0000260 075 040 050 163 164 141 164 050 042 044 137 133 060 135 042 051

          =       (   s   t   a   t   (   "   $   _   [   0   ]   "   )

0000300 051 133 071 135 040 174 174 040 144 151 145 040 042 143 141 156

          )   [   9   ]       |   |       d   i   e       "   c   a   n

0000320 156 157 164 040 163 164 141 164 040 146 151 154 145 040 044 041

          n   o   t       s   t   a   t       f   i   l   e       $   !

0000340 042 073 040 040 012 040 040 040 040 040 040 044 163 151 172 145

          "   ;          \n                           $   s   i   z   e

0000360 040 075 040 040 050 163 164 141 164 050 042 044 137 133 060 135

              =           (   s   t   a   t   (   "   $   _   [   0   ]

0000400 042 051 051 133 067 135 073 040 040 043 040 163 151 172 145 040

          "   )   )   [   7   ]   ;           #       s   i   z   e

0000420 151 156 040 142 171 164 145 163 012 040 040 040 040 040 040 044

          i   n       b   y   t   e   s  \n                           $

0000440 157 153 040 075 040 042 156 157 164 040 157 153 042 073 012 040

          o   k       =       "   n   o   t       o   k   "   ;  \n

0000460 040 040 040 040 040 012 040 040 040 040 040 040 151 146 050 040

                             \n                           i   f   (

0000500 044 163 151 172 145 040 076 040 060 040 046 046 040 044 155 164

          $   s   i   z   e       >       0       &   &       $   m   t

0000520 151 155 145 040 076 075 040 044 164 157 144 141 171 040 051 012

          i   m   e       >   =       $   t   o   d   a   y       )  \n

0000540 040 040 040 040 040 040 173 012 040 040 040 040 040 040 040 040

                                  {  \n

0000560 040 040 040 040 044 157 153 040 075 040 042 157 153 042 073 040

                          $   o   k       =       "   o   k   "   ;

0000600 012 040 040 040 040 040 040 040 040 040 040 040 040 044 162 145

         \n                                                   $   r   e

0000620 164 165 162 156 137 166 141 154 165 145 040 075 040 061 073 040

          t   u   r   n   _   v   a   l   u   e       =       1   ;

0000640 040 040 040 040 040 040 040 040 040 040 012 040 040 040 040 040

                                                 \n

0000660 040 175 012 040 040 040 040 040 040 160 162 151 156 164 040 042

              }  \n                           p   r   i   n   t       "

0000700 044 137 133 060 135 040 151 163 040 044 157 153 134 156 042 073

          $   _   [   0   ]       i   s       $   o   k   \   n   "   ;

0000720 012 040 040 040 040 040 040 162 145 164 165 162 156 040 044 162

         \n                           r   e   t   u   r   n       $   r

0000740 145 164 165 162 156 137 166 141 154 165 145 073 012 175 012 012

          e   t   u   r   n   _   v   a   l   u   e   ;  \n   }  \n  \n

0000760 044 146 157 165 156 144 040 075 040 060 073 012 157 160 145 156

          $   f   o   u   n   d       =       0   ;  \n   o   p   e   n

0001000 144 151 162 040 050 104 111 122 110 116 104 114 054 040 042 057

          d   i   r       (   D   I   R   H   N   D   L   ,       "   /

0001020 163 155 142 057 143 145 156 164 055 142 162 153 055 160 157 163

          s   m   b   /   c   e   n   t   -   b   r   k   -   p   o   s

0001040 071 056 160 141 170 143 150 151 057 160 157 163 151 164 151 157

          9   .   p   a   x   c   h   i   /   p   o   s   i   t   i   o

0001060 156 163 145 162 166 145 162 062 042 051 040 174 174 040 040 144

          n   s   e   r   v   e   r   2   "   )       |   |           d

0001100 151 145 040 042 103 141 156 156 157 164 040 157 160 145 156 040

          i   e       "   C   a   n   n   o   t       o   p   e   n

0001120 144 151 162 145 143 164 157 162 171 040 044 041 042 073 012 100

          d   i   r   e   c   t   o   r   y       $   !   "   ;  \n   @

0001140 146 151 154 145 154 151 163 164 040 075 040 162 145 141 144 144

          f   i   l   e   l   i   s   t       =       r   e   a   d   d

0001160 151 162 040 050 104 111 122 110 116 104 114 051 073 012 143 154

          i   r       (   D   I   R   H   N   D   L   )   ;  \n   c   l

0001200 157 163 145 144 151 162 040 050 104 111 122 110 116 104 114 051

          o   s   e   d   i   r       (   D   I   R   H   N   D   L   )

0001220 073 012 012 146 157 162 145 141 143 150 040 044 146 151 154 145

          ;  \n  \n   f   o   r   e   a   c   h       $   f   i   l   e

0001240 156 141 155 145 040 050 040 100 146 151 154 145 154 151 163 164

          n   a   m   e       (       @   f   i   l   e   l   i   s   t

0001260 040 051 012 173 012 040 040 040 151 146 040 050 044 146 151 154

              )  \n   {  \n               i   f       (   $   f   i   l

0001300 145 156 141 155 145 040 075 176 040 057 164 170 164 044 057 051

          e   n   a   m   e       =   ~       /   t   x   t   $   /   )

0001320 012 040 040 040 173 012 040 040 040 040 040 044 146 157 165 156

         \n               {  \n                       $   f   o   u   n

0001340 144 040 174 075 040 103 150 145 143 153 151 156 147 106 151 154

          d       |   =       C   h   e   c   k   i   n   g   F   i   l

0001360 145 163 040 044 146 151 154 145 156 141 155 145 073 012 040 040

          e   s       $   f   i   l   e   n   a   m   e   ;  \n

0001400 040 175 012 175 012 160 162 151 156 164 040 042 162 145 164 165

              }  \n   }  \n   p   r   i   n   t       "   r   e   t   u

0001420 162 156 040 163 164 141 164 165 163 040 075 040 044 146 157 165

          r   n       s   t   a   t   u   s       =       $   f   o   u

0001440 156 144 134 156 042 073 012 012 145 170 151 164 040 060 073 012

          n   d   \   n   "   ;  \n  \n   e   x   i   t       0   ;  \n

0001460 012 012 012

         \n  \n  \n

0001463

-bash-3.2$

Hmm... doesn't seem to be out of place. Your error messages point towards a mangled program file.

I'd suggest you to perform incremental testing.
1) fire up a 2nd terminal window (assuming you have one open already),
2) create a new Perl file in vim,
3) add just one command or line of code,
4) save the file in unix format,
5) run the Perl program from the 1st terminal window.

Repeat 3), 4), 5) till you encounter a problem or execute the entire program successfully.

tyler_durden

Could this be related to wrong path or permissions?

No.

tyler_durden

Has it worked for you on your host?

Yes it has. Although I don't quite understand why you'd want to know that. The problem is in your system, not mine. Because it is working on my system won't make it work on your system automatically.

You gotta find the problem on your system; not cross-check if it works on the systems other than yours!

tyler_durden