in reply to Re: convert date format from YYYY-MM-DD to YYYYMMDD
in thread convert date format from YYYY-MM-DD to YYYYMMDD

Hi Experts,

Thanks all for the valuable inputs

I am using $date =~ s/-//g;

because I want to do conversion without using any perl modules

Thank once again.
  • Comment on Re^2: convert date format from YYYY-MM-DD to YYYYMMDD

Replies are listed 'Best First'.
Re^3: convert date format from YYYY-MM-DD to YYYYMMDD
by Your Mother (Archbishop) on May 16, 2014 at 17:36 UTC

    That is a perfectly good approach if you’re certain the data will always match expectations. This is a poor assumption if you don’t know it for a fact though.

    The tr///d option is faster than s///g but it would only be something to really care about for huge datasets where the very small difference would add up.

    Lastly, I want to X without using any perl modules sounds like a good conclusion in this case but it’s one that you shouldn’t make in the general case unless this is pure hobby work you don’t care much about. Learning to use modules—there are good date ones in the core and plenty more available on the CPAN—and understanding the greater Perl ecosphere is what will make your future tasks easier, even trivial, and future employment and salary growth much more likely.