in reply to Re^2: localtime function
in thread localtime function

These numbers are way bigger than the current timestamp what is 1422354181. The code below would solve the problem if the timestamps were valid.

my $res = 'startTime 1421744559358 1421744614728 1421744621032 1421724 +767767'; my @res = split(' ', $res); shift @res; foreach my $t (@res) { print localtime($t) . "\n"; }

Replies are listed 'Best First'.
Re^4: localtime function
by rsodhia (Novice) on Jan 27, 2015 at 10:55 UTC
    As per pme, I made the following changes but nothing worked.
    #!/usr/bin/perl use strict; use warnings; use XML::CSV; use Text::CSV; use Time::Local; my @d; my %ha; my $file = 'dDos_flows.csv'; my $file1 = 'dDos_flows1.csv'; open(my $fh,'<:encoding(UTF-8)',$file); open(my $fh1,'>:encoding(UTF-8)',$file1); while(my $f=<$fh>) { chomp $f; my @data=split ",",$f; my $res=$data[2]; #print "$res \n"; my @res= split(' ', $res); shift @res; foreach my $t (@res) { print localtime($t) . "\n"; } #my $conv=scalar(localtime($data[2])); #print "$conv \n"; }
    output
    Use of uninitialized value $res in split at D:\ddos.pl line 21, <$fh> +line 1. Use of uninitialized value $res in split at D:\ddos.pl line 21, <$fh> +line 2. Use of uninitialized value $res in split at D:\ddos.pl line 21, <$fh> +line 22. Use of uninitialized value $res in split at D:\ddos.pl line 21, <$fh> +line 23. Use of uninitialized value $res in split at D:\ddos.pl line 21, <$fh> +line 24.