Sponsored Content
Top Forums Shell Programming and Scripting PERL String to Date (Custom format yyyymmdd to dd-mon-yyyy) Post 302401186 by karthigayan on Friday 5th of March 2010 05:36:43 AM
Old 03-05-2010
Code:
use strict;

open FH , "<test";

my %hash=("01"=>"JAN","02"=>"FEB","03"=>"MAR","04"=>"APR","05"=>"MAY","06"=>"JUN","07"=>"JUL","08"=>"AUG","09"=>"SEP","10"=>"OCT","11"=>"NOV","12"=>"DEC");
while(<FH>)
{

     if(/([0-9]{4})([0-9]{2})([0-9]{2})/)
    {
    print $3."-".$hash{$2}."-".$1 ."\n";
    }
}

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to convert the string YYYYMMDD into YYYY.MM.DD

how to convert the string YYYYMMDD into YYYY.MM.DD Please advice (1 Reply)
Discussion started by: spatra
1 Replies

2. UNIX for Dummies Questions & Answers

Format date from MM/DD/YYYY to YYYYMMDD

I have a file with some date columns in MM/DD/YYYY format: SMPBR|DUP-DO NOT USE|NEW YORK||16105|BA5270715|6/6/2007 |MWERNER|109||||JOHN||SMITH|MD|72211118||||||74559|21 WILMINGTON RD||D|11/6/2003|SL# MD CONTACT-LIZ RICHARDS|||0|Y|N||1411458| And I want to convert the date format to: ... (5 Replies)
Discussion started by: ChicagoBlues
5 Replies

3. Shell Programming and Scripting

convert date format YYYYMMDD to MM/DD/YYYY

In my shell script i have a variable which stores date in the format of YYYYMMDD. Is there any way to format this value to MM/DD/YYYY. Thanks. (8 Replies)
Discussion started by: nasirgondal
8 Replies

4. Shell Programming and Scripting

Converting date DD MM YYYY to DD MON YYYY

Hello, I am writing a script that parses different logs and produces one. In the source files, the date is in DD MM YYYY HH24:MI:SS format. In the output, it should be in DD MON YYY HH24:MI:SS (ie 25 Jan 2010 16:10:10) To extract the dates, I am using shell substrings, i.e.: read line ... (4 Replies)
Discussion started by: Adamm
4 Replies

5. Shell Programming and Scripting

Converting Date from YYYYMMDD to DD-MON-YYYY

Hi , I need to convert date from YYYYMMDD to DD-MON-YYYY e.g 20111214 to 14-Dec-2011 Please help. (17 Replies)
Discussion started by: ady_koolz
17 Replies

6. Shell Programming and Scripting

Validating date in yyyymmdd format using PERL

Hi all, i had a code where in user will enter a date in yyyymmdd format.. i didnt use any validation for the date and now the problem is if a user enters date instead of month after year it is proceeding with the code.. like if the date is 20120426 and if the user enters 20122604 it... (4 Replies)
Discussion started by: smarty86
4 Replies

7. Shell Programming and Scripting

Date conversion help from dd/mm/yyyy to dd/Mon/yyyy i.e. 28/10/2012 to 28/Oct/2012

Hi I have a problem with Date format in my code. 1st I am trying to convert today's date to yesterday's using YESTERDAY3=`perl -e '@y=localtime(time()-86400); printf "%04d/%02d/%02d",$y+1900,$y+1,$y;$y;'` And once it is done I am trying to using the yesterday date in a grep command to... (3 Replies)
Discussion started by: nithinankam
3 Replies

8. Programming

Date format change from mm/dd/yyyy to yyyymmdd in comma seperate line in perl

Hi All, I have line ,A,FDRM0002,12/21/2017,,0.961751583,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, it contains date in mm/dd/yyyy format i want to change this to yyyymmdd format using perl. Use code tags, thanks. (8 Replies)
Discussion started by: vishal0746
8 Replies

9. Shell Programming and Scripting

Convert string (YYYYMMDD) format to date in Sun OS

Hi All I need help in converting a string of YYYYMMDD format to date in Sun OS and then find out if the day is a Wednesday or not. The "date -d" option is not working and your help is much appreciated. The date command usage from the operating system we use here is as follows: usage: ... (1 Reply)
Discussion started by: SK123
1 Replies

10. Solaris

Convert string (YYYYMMDD) format to date in Sun OS

Hi All I need help in converting a string of YYYYMMDD format to date in Sun OS and then find out if the day is a Wednesday or not. The "date -d" option is not working and your help is much appreciated. The date command usage from the operating system we use here is as follows: Thanks, SK (11 Replies)
Discussion started by: SK123
11 Replies
Perl::Critic::Policy::TestingAndDebugging::RequireUseStrUser3Contributed Perl DocuPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict(3pm)

NAME
Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict - Always "use strict". AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
Using strictures is probably the single most effective way to improve the quality of your code. This policy requires that the 'use strict' statement must come before any other statements except "package", "require", and other "use" statements. Thus, all the code in the entire package will be affected. There are special exemptions for Moose, Moose::Role, and Moose::Util::TypeConstraints because they enforces strictness; e.g. 'use Moose' is treated as equivalent to 'use strict'. The maximum number of violations per document for this policy defaults to 1. CONFIGURATION
If you take make use of things like Moose::Exporter, you can create your own modules that import the strict pragma into the code that is "use"ing them. There is an option to add to the default set of pragmata and modules in your .perlcriticrc: "equivalent_modules". [TestingAndDebugging::RequireUseStrict] equivalent_modules = MooseX::My::Sugar SEE ALSO
Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module perl v5.14.2 2012-06-07 Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict(3pm)
All times are GMT -4. The time now is 11:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy