Re: date format search insdie the files

2008-11-29 Thread David Schmidt
You missed some parentheses #!/usr/bin/perl use strict; use warnings; open(DATA, '', data) || dieUnable to open the file; while(DATA) { #if($_=~/\d{2}-(\d{2}|\w{3})-\d{1,4}/) { if(/(\d{2}-(\d{2})|(\w{3})-\d{1,4})/) { print; } } close(DATA); exit 0; On

RE: date format search insdie the files

2008-11-29 Thread Sureshkumar M (HCL Financial Services)
-20009 15-10-2008 (C)/tmp/d$ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Schmidt Sent: Saturday, November 29, 2008 3:12 PM To: Sureshkumar M (HCL Financial Services); beginners@perl.org Subject: Re: date format search insdie

RE: date format search insdie the files

2008-11-29 Thread Sureshkumar M (HCL Financial Services)
Hi all , Can someone help me on this From: Sureshkumar M (HCL Financial Services) Sent: Saturday, November 29, 2008 4:21 PM To: 'David Schmidt' Cc: beginners@perl.org Subject: RE: date format search insdie the files Hi David, Thanks

Re: date format search insdie the files

2008-11-29 Thread Dr.Ruud
Sureshkumar M (HCL Financial Services) schreef: #/usr/bin/perl open(DATA,a1)||dieUnable to open the file; while(DATA) { if($_=~/\d{2}-(\d{2}|\w{3})-\d{1,4}/) { print $_; } } close(DATA); exit 0; #!/usr/bin/perl use strict; use warnings; my $in_name = data.in; { open my

RE: date format search insdie the files

2008-11-29 Thread Sureshkumar M (HCL Financial Services)
5:30 PM To: beginners@perl.org Subject: Re: date format search insdie the files Sureshkumar M (HCL Financial Services) schreef: #/usr/bin/perl open(DATA,a1)||dieUnable to open the file; while(DATA) { if($_=~/\d{2}-(\d{2}|\w{3})-\d{1,4}/) { print $_; } } close(DATA); exit 0; #!/usr

Re: date format search insdie the files

2008-11-29 Thread Dr.Ruud
Sureshkumar M (HCL Financial Services) schreef: Can you explain me this part how it's works? (?:\d{2}|\w{3}) ?: what this will do? Read perlre (and find out what (?:) means). And also, the output is like below (C)/tmp/d$ perl 1 10-11-81 20-NOV-2008 05-07-1981 15-110-2008

Re: date format search insdie the files

2008-11-29 Thread Dr.Ruud
Sureshkumar M (HCL Financial Services) schreef: Can someone help me on this Impossible. -- Affijn, Ruud Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Date format search in the file

2008-11-22 Thread Dermot
2008/11/22 Sureshkumar M (HCL Financial Services) [EMAIL PROTECTED]: Hi All, Hi #!/usr/bin/perl # Always use these, particularly when things aren't working as expected. use strict; use warnings; open(DATA,i)||die Unable to open the file; while(DATA) { if($_=~/(\d{2})([\W])\1\2\1]/)

Re: Date format search in the file

2008-11-22 Thread John W. Krahn
Sureshkumar M (HCL Financial Services) wrote: Hi All, Hello, I want to find the string which are having the date inside the file. Please help me how do I match it,below is my program and it's not returning anything. #!/usr/bin/perl use warnings; use strict; open(DATA,i)||die Unable to

Re: Date format search in the file

2008-11-22 Thread John W. Krahn
Dermot wrote: 2008/11/22 Sureshkumar M (HCL Financial Services) [EMAIL PROTECTED]: #!/usr/bin/perl # Always use these, particularly when things aren't working as expected. use strict; use warnings; open(DATA,i)||die Unable to open the file; while(DATA) { if($_=~/(\d{2})([\W])\1\2\1]/)

Re: Date format search in the file

2008-11-22 Thread sftriman
On Nov 22, 6:16 am, [EMAIL PROTECTED] (Dermot) wrote: 2008/11/22 Sureshkumar M (HCL Financial Services) [EMAIL PROTECTED]: Hi All, Hi #!/usr/bin/perl # Always use these, particularly when things aren't working as expected. use strict; use warnings; open(DATA,i)||die Unable to

Re: date format

2004-08-17 Thread Gunnar Hjalmarsson
[EMAIL PROTECTED] wrote: I have this code: my ($month, $day, $year) = (localtime)[4,3,5]; printf (%02d/%02d/%02d\n, $month+1,$day,$year+1900); which gives me 08/16/2004 what I want is 08/16/04. perldoc -f localtime describes very clearly how you get a two digit year. It's advisable to study the

RE: date format

2004-08-16 Thread Bob Showalter
[EMAIL PROTECTED] wrote: All, I have this code: my ($month, $day, $year) = (localtime)[4,3,5]; printf (%02d/%02d/%02d\n, $month+1,$day,$year+1900); which gives me 08/16/2004 what I want is 08/16/04. Should I just use Posix with strftime or is there a quicker way w/out having to

Re: date format

2004-08-16 Thread Chris Devers
On Mon, 16 Aug 2004 [EMAIL PROTECTED] wrote: I have this code: my ($month, $day, $year) = (localtime)[4,3,5]; printf (%02d/%02d/%02d\n, $month+1,$day,$year+1900); which gives me 08/16/2004 what I want is 08/16/04. Should I just use Posix with strftime or is there a quicker way w/out having to

RE: date format

2004-08-16 Thread Bob Showalter
Bob Showalter wrote: ($year + 1900) % 100 Actually just $year % 100 is valid. The former makes it clearer what you're doing, if you're into that :~) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: date format

2004-08-16 Thread Flemming Greve Skovengaard
[EMAIL PROTECTED] wrote: All, I have this code: my ($month, $day, $year) = (localtime)[4,3,5]; printf (%02d/%02d/%02d\n, $month+1,$day,$year+1900); which gives me 08/16/2004 what I want is 08/16/04. Should I just use Posix with strftime or is there a quicker way w/out having to load the

RE: date format

2004-08-16 Thread DBSMITH
], [EMAIL PROTECTED] cc: Subject:RE: date format Bob Showalter wrote: ($year + 1900) % 100 Actually just $year % 100 is valid. The former makes it clearer what you're doing, if you're into that :~)

RE: date format

2004-08-16 Thread Bob Showalter
Flemming Greve Skovengaard wrote: printf (%02d/%02d/%02d\n, $month + 1, $day, $year - 100); # Only works when $year 1999. And when $year = 2099 :~) Stick to $year % 100; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: date format

2004-08-16 Thread Flemming Greve Skovengaard
Bob Showalter wrote: Flemming Greve Skovengaard wrote: printf (%02d/%02d/%02d\n, $month + 1, $day, $year - 100); # Only works when $year 1999. And when $year = 2099 :~) Stick to $year % 100; Yes, you are correct. Your solution is fool proof. -- Flemming Greve Skovengaard FAITH, n.

Re: date format

2004-08-16 Thread DBSMITH
, $month + 1, $day, ($year %100)); } while (D) if ( $_ =~ $foodate) { . } Flemming Greve Skovengaard [EMAIL PROTECTED] 08/16/2004 02:58 PM To: [EMAIL PROTECTED] [EMAIL PROTECTED] cc: Bob Showalter [EMAIL PROTECTED] Subject:Re: date format Bob

Re: date format

2004-08-16 Thread Chris Devers
On Mon, 16 Aug 2004 [EMAIL PROTECTED] wrote: sub datemanip A name like that screams a need for the Date::Manip CPAN module: http://search.cpan.org/~sbeck/DateManip-5.42a/Manip.pod Look over the docs for that module, see if you can't use it to do what you need to do, and let the list know if you

Re: date format

2004-08-16 Thread Flemming Greve Skovengaard
[EMAIL PROTECTED] wrote: I have this value, from the date format solution emails, in a subroutine and I want to pass it to a if clause, how would I go about this? Can I assign a literal such as sub datemanip { my ( $month, $day, $year) = (localtime)[4,3,5]; my $foodate =

Re: date format using localtime()

2004-03-12 Thread Steve Mayer
Jeff, Check out http://www.users.voicenet.com/~corr/macsupt/macperl/localtime.html Steve On Fri, Mar 12, 2004 at 01:38:28PM -0800, Jeff Westman wrote: Is there a way in perl to get the month/day/year using localtime WITHOUT using 'use POSIX qw(strftime)' or a system date call.

Re: date format using localtime()

2004-03-12 Thread Owen Cook
On Fri, 12 Mar 2004, Jeff Westman wrote: Is there a way in perl to get the month/day/year using localtime WITHOUT using 'use POSIX qw(strftime)' or a system date call. Something using slices, maybe something like: print scalar ((localtime(time))[4,3,7]) expecting the result to

Re: Date format again

2002-03-03 Thread fliptop
Troy May wrote: Hello, this guy finally emailed his script to me. The problem he is having is with $year. Here's the dating part of the code: --- $date = `/bin/date`; chop($date); has this guy considered using Date::Calc?

Re: Date format again

2002-03-03 Thread Marcelo E. Magallon
[ Don't Cc: me, I read this mailing list, thank you ] Troy May [EMAIL PROTECTED] writes: ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime; $thisday = (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[(localtime) [6]]; $s = (localtime)[0]; $m = (localtime)[1]; $m = ($m + 35) ; Is

Re: Date format again

2002-03-03 Thread Alfred Wheeler
$year is a number. Numbers do not retain leading zeros. $year %= 100; does not return the string 02; it returns the number 2. Try something like this - $s_year = sprintf(%02u, $year); print $s_year; The sprintf function basically converts the number into a string. sprintf returns a string