sub fetch_time { Other variables declarations ... my($cur_ts); <-- variable in which I am going to receive the epoch Other variables declarations ... # get the current timestamp $cur_ts = time(); <-- fetching current epoch print "$cur_ts;\n"; Other operations ... } Samples sample 1: system epoch - 1234867548 epoch printed - 1234871946 sample 2: system epoch - 1234868856 epoch printed - 1234873254 sample 3: system epoch - 1234928039 epoch printed - 1234932437