How to get yesterday"s date in Perl

How to get yesterday"s date in Perl

am 03.12.2008 13:04:30 von zilore mumba

--===============1294046017==
Content-Type: multipart/alternative; boundary="0-1991246789-1228305870=:92784"

--0-1991246789-1228305870=:92784
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable


After brouwsing=A0a lot ofdocumentation I cannot find how to get yesterday'=
s or tomorrow's date in Perl, like `date --date "-1 day" "+%Y%m%d"` in bash=
.. Is this possible in Perl?
I am making date directories, like 20081203. If I add, I get a problem at t=
he end/begining of the month, I get like 20081131 or 20081200.
Thanks for any assistance.
Zilore
=0A
--0-1991246789-1228305870=:92784
Content-Type: text/html; charset=us-ascii


After brouwsing a lot ofdocumentation I cannot find how to get yesterday's or tomorrow's date in Perl, like `date --date "-1 day" "+%Y%m%d"` in bash. Is this possible in Perl?

I am making date directories, like 20081203. If I add, I get a problem at the end/begining of the month, I get like 20081131 or 20081200.

Thanks for any assistance.

Zilore




--0-1991246789-1228305870=:92784--

--===============1294046017==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1294046017==--

Re: How to get yesterday"s date in Perl

am 03.12.2008 13:17:50 von Jenda Krynicky

From: zilore mumba
> After brouwsing=A0a lot ofdocumentation I cannot find how to get
> yesterday's or tomorrow's date in Perl, like `date --date "-1 day"
> "+%Y%m%d"` in bash. Is this possible in Perl? =

>
> I am making date directories, like 20081203. If I add, I get a problem
> at the end/begining of the month, I get like 20081131 or 20081200. =

>
> Thanks for any assistance.
> Zilore

time() returns the number of seconds since some date. localtime() =

formats or returns the individual parts of a date and does so either =

for the current date&time or for some date in the format of the =

number of seconds since the same date as time(). So in this =

particular case (and if you do not mind summer/winter-time changes) =

all you have to do is to pass time()+dayload_of_seconds to =

localtime(). And since you do not use the hour and minute you do not =

mind summer/winter-time.

If you need something more complex have a look at the DateTime module =

(http://search.cpan.org/search?query=3DDateTime&mode=3Dall)

Jenda
=====3D Jenda@Krynicky.cz ===3D http://Jenda.Krynicky.cz ===
===3D
When it comes to wine, women and song, wizards are allowed =

to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: How to get yesterday"s date in Perl

am 03.12.2008 13:56:00 von Angelos Karageorgiou

This is a multi-part message in MIME format.
--------------080204050504080502000900
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

time - 24*60*60 is a quick guess

zilore mumba wrote:
>
> After brouwsing a lot ofdocumentation I cannot find how to get
> yesterday's or tomorrow's date in Perl, like `date --date "-1 day"
> "+%Y%m%d"` in bash. Is this possible in Perl?
> I am making date directories, like 20081203. If I add, I get a problem
> at the end/begining of the month, I get like 20081131 or 20081200.
> Thanks for any assistance.

--------------080204050504080502000900
Content-Type: text/x-vcard; charset=utf-8;
name="angelos.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="angelos.vcf"

begin:vcard
fn:Angelos Karageorgiou
n:Karageorgiou;Angelos
org:Vivodi Telecommunications S.A.
email;internet:angelos@unix.gr
title:Technology Manager
tel;work:+30 211 7503 893
tel;fax:+30 211 7503 701
tel;cell:+30 6949120773
note;quoted-printable: =
=
Linkedin Profile =
=
http://www.linkedin.com/in/unixgr =
=
=
=
Personal Web Site =
http://www.unix.gr =
=
=
Blog Site =
http://angelos-proverbs.blogspot.com
x-mozilla-html:FALSE
url:http://www.linkedin.com/in/unixgr
version:2.1
end:vcard


--------------080204050504080502000900
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--------------080204050504080502000900--

RE: How to get yesterday"s date in Perl

am 03.12.2008 15:03:02 von Erich.Singer

This is a multi-part message in MIME format.

--===============0358820505==
Content-class: urn:content-classes:message
Content-Type: multipart/alternative;
boundary="----_=_NextPart_001_01C9554F.C75B0427"

This is a multi-part message in MIME format.

------_=_NextPart_001_01C9554F.C75B0427
Content-Type: text/plain;
charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

Hello
=20
use Date::Calc qw(Add_Delta_Days)
=20
Erich

________________________________

From: activeperl-bounces@listserv.ActiveState.com
[mailto:activeperl-bounces@listserv.ActiveState.com] On Behalf Of zilore
mumba
Sent: Wednesday, December 03, 2008 7:05 AM
To: activeperl@listserv.activestate.com
Subject: How to get yesterday's date in Perl



After brouwsing a lot ofdocumentation I cannot find how to get
yesterday's or tomorrow's date in Perl, like `date --date "-1 day"
"+%Y%m%d"` in bash. Is this possible in Perl?
I am making date directories, like 20081203. If I add, I get a problem
at the end/begining of the month, I get like 20081131 or 20081200.
Thanks for any assistance.
Zilore



------_=_NextPart_001_01C9554F.C75B0427
Content-Type: text/html;
charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable



charset=3Dus-ascii">


face=3DArial=20
color=3D#0000ff size=3D2>Hello

face=3DArial=20
color=3D#0000ff size=3D2>
 

face=3DArial=20
color=3D#0000ff size=3D2>use Date::Calc =
qw(Add_Delta_Days)

face=3DArial=20
color=3D#0000ff size=3D2>
 

face=3DArial=20
color=3D#0000ff size=3D2>Erich





From:=20
activeperl-bounces@listserv.ActiveState.com=20
[mailto:activeperl-bounces@listserv.ActiveState.com] On Behalf Of =
zilore=20
mumba
Sent: Wednesday, December 03, 2008 7:05 AM
To: =

activeperl@listserv.activestate.com
Subject: How to get =
yesterday's=20
date in Perl








After brouwsing a lot ofdocumentation I cannot find =
how to=20
get yesterday's or tomorrow's date in Perl, like `date --date "-1 =
day"=20
"+%Y%m%d"` in bash. Is this possible in Perl?

I am making date directories, like 20081203. If I add, I get =
a=20
problem at the end/begining of the month, I get like 20081131 or=20
20081200.

Thanks for any assistance.

Zilore



------_=_NextPart_001_01C9554F.C75B0427--

--===============0358820505==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============0358820505==--

RE: How to get yesterday"s date in Perl

am 03.12.2008 16:09:07 von zilore mumba

--===============0017052296==
Content-Type: multipart/alternative; boundary="0-2108951000-1228316947=:11747"

--0-2108951000-1228316947=:11747
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

thanks for the response, but it is still not clear to me. What do I put in =
qw(Add_Delta_Days)?
Thanks
Zilore



--- On Wed, 12/3/08, Singer, Erich wrote:

From: Singer, Erich
Subject: RE: How to get yesterday's date in Perl
To: zmumba@yahoo.com, activeperl@listserv.activestate.com
Date: Wednesday, December 3, 2008, 4:03 PM



Hello
=A0
use Date::Calc qw(Add_Delta_Days)
=A0
Erich



From: activeperl-bounces@listserv.ActiveState.com [mailto:activeperl-bounce=
s@listserv.ActiveState.com] On Behalf Of zilore mumba
Sent: Wednesday, December 03, 2008 7:05 AM
To: activeperl@listserv.activestate.com
Subject: How to get yesterday's date in Perl








After brouwsing=A0a lot ofdocumentation I cannot find how to get yesterday'=
s or tomorrow's date in Perl, like `date --date "-1 day" "+%Y%m%d"` in bash=
.. Is this possible in Perl?
I am making date directories, like 20081203. If I add, I get a problem at t=
he end/begining of the month, I get like 20081131 or 20081200.
Thanks for any assistance.
Zilore

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs =0A =

--0-2108951000-1228316947=:11747
Content-Type: text/html; charset=us-ascii

thanks for the response, but it is still not clear to me. What do I put in qw(Add_Delta_Days)?

Thanks

Zilore



--- On Wed, 12/3/08, Singer, Erich <Erich.Singer@starcompliance.com> wrote:

From: Singer, Erich <Erich.Singer@starcompliance.com>
Subject: RE: How to get yesterday's date in Perl
To: zmumba@yahoo.com, activeperl@listserv.activestate.com
Date: Wednesday, December 3, 2008, 4:03 PM



Hello

 

use Date::Calc qw(Add_Delta_Days)

 

Erich





From: activeperl-bounces@listserv.ActiveState.com [mailto:activeperl-bounces@listserv.ActiveState.com] On Behalf Of zilore mumba
Sent: Wednesday, December 03, 2008 7:05 AM
To: activeperl@listserv.activestate.com
Subject: How to get yesterday's date in Perl








After brouwsing a lot ofdocumentation I cannot find how to get yesterday's or tomorrow's date in Perl, like `date --date "-1 day" "+%Y%m%d"` in bash. Is this possible in Perl?

I am making date directories, like 20081203. If I add, I get a problem at the end/begining of the month, I get like 20081131 or 20081200.

Thanks for any assistance.

Zilore

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs




--0-2108951000-1228316947=:11747--

--===============0017052296==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============0017052296==--

RE: How to get yesterday"s date in Perl

am 03.12.2008 17:18:38 von Henry Hartley

--===============0723490091==
Content-Language: en-US
Content-Type: multipart/alternative;
boundary="_000_62432006F5965C42BAEC4EA29286EE0507B180EDF7EXC MS01westat_"

--_000_62432006F5965C42BAEC4EA29286EE0507B180EDF7EXCMS01west at_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

#!/usr/bin/perl -w

use strict ;
use Date::Calc qw(Add_Delta_Days) ;

my ( $todayd, $todaym, $todayy ) =3D (localtime)[3..5] ;
$todaym +=3D 1 ;
$todayy +=3D 1900 ;

my ($yesty,$yestm,$yestd) =3D Add_Delta_Days($todayy,$todaym,$todayd, -1) ;

print "Today:\t\t$todaym/$todayd/$todayy\nYesterday:\t$yestm/$yest d/$yesty\=
n" ;

--
Henry

-----Original Message-----
From: activeperl-bounces@listserv.ActiveState.com [mailto:activeperl-bounce=
s@listserv.ActiveState.com] On Behalf Of zilore mumba
Sent: Wednesday, December 03, 2008 10:09 AM
To: activeperl@listserv.activestate.com
Subject: RE: How to get yesterday's date in Perl

thanks for the response, but it is still not clear to me. What do I put in =
qw(Add_Delta_Days)?
Thanks
Zilore



--- On Wed, 12/3/08, Singer, Erich wrote:
From: Singer, Erich
Subject: RE: How to get yesterday's date in Perl
To: zmumba@yahoo.com, activeperl@listserv.activestate.com
Date: Wednesday, December 3, 2008, 4:03 PM

Hello

use Date::Calc qw(Add_Delta_Days)

Erich

________________________________
From: activeperl-bounces@listserv.ActiveState.com [mailto:activeperl-bounce=
s@listserv.ActiveState.com] On Behalf Of zilore mumba
Sent: Wednesday, December 03, 2008 7:05 AM
To: activeperl@listserv.activestate.com
Subject: How to get yesterday's date in Perl


After brouwsing a lot ofdocumentation I cannot find how to get yesterday's =
or tomorrow's date in Perl, like `date --date "-1 day" "+%Y%m%d"` in bash. =
Is this possible in Perl?
I am making date directories, like 20081203. If I add, I get a problem at t=
he end/begining of the month, I get like 20081131 or 20081200.
Thanks for any assistance.
Zilore



_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



--_000_62432006F5965C42BAEC4EA29286EE0507B180EDF7EXCMS01west at_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable


Message



#!/usr/bin/perl -w<=
/DIV>
 

use strict ;
use Date::=
Calc=20
qw(Add_Delta_Days) ;

 

my ( $ class=3D546271616-03122008>todayd, $ class=3D546271616-03122008>todaym, $ class=3D546271616-03122008>todayy ) =3D (localtime)[3..5] ;
$ N=20
class=3D546271616-03122008>todaym +=3D 1 ;
$ class=3D546271616-03122008>todayy  +=3D 1900 ;

 

my ($ class=3D546271616-03122008>yesty,$ class=3D546271616-03122008>yestm,$ class=3D546271616-03122008>yestd) =3D Add_Delta_Days($ class=3D546271616-03122008>todayy,$ class=3D546271616-03122008>todaym,$ class=3D546271616-03122008>todayd, -1) ;

 

print "Today:\t\t$ class=3D546271616-03122008>todaym/$ class=3D546271616-03122008>todayd/$ class=3D546271616-03122008>todayy\nYesterday:\t$ class=3D546271616-03122008>yestm/$ class=3D546271616-03122008>yestd/$ class=3D546271616-03122008>yesty\n" ;

 

--
Henry

 


face=3DTahoma=20
size=3D2>-----Original Message-----
From:=20
activeperl-bounces@listserv.ActiveState.com=20
[mailto:activeperl-bounces@listserv.ActiveState.com] On Behalf Of zi=
lore=20
mumba
Sent: Wednesday, December 03, 2008 10:09 AM
To:=20
activeperl@listserv.activestate.com
Subject: RE: How to get=20
yesterday's date in Perl






thanks for the response, but it is still not clear to me. What d=
o I=20
put in qw(Add_Delta_Days)?

Thanks

Zilore



--- On Wed=
,=20
12/3/08, Singer, Erich <Erich.Singer@starcompliance.com>=
=20
wrote:

style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(16,16,=
255) 2px solid">From:=20
Singer, Erich <Erich.Singer@starcompliance.com>
Subject: R=
E:=20
How to get yesterday's date in Perl
To: zmumba@yahoo.com,=20
activeperl@listserv.activestate.com
Date: Wednesday, December 3,=
=20
2008, 4:03 PM



face=3DArial=20
color=3D#0000ff size=3D2>Hello

face=3DArial=20
color=3D#0000ff size=3D2>
 

face=3DArial=20
color=3D#0000ff size=3D2>use Date::Calc=20
qw(Add_Delta_Days)

face=3DArial=20
color=3D#0000ff size=3D2>
 

face=3DArial=20
color=3D#0000ff size=3D2>Erich


ft>


From:=20
activeperl-bounces@listserv.ActiveState.com=20
[mailto:activeperl-bounces@listserv.ActiveState.com] On Behalf O=
f=20
zilore mumba
Sent: Wednesday, December 03, 2008 7:05=
=20
AM
To: activeperl@listserv.activestate.com
Subject:=
=20
How to get yesterday's date in Perl








After brouwsing a lot ofdocumentation I cannot =
find=20
how to get yesterday's or tomorrow's date in Perl, like `date=
=20
--date "-1 day" "+%Y%m%d"` in bash. Is this possible in=20
Perl?

I am making date directories, like 20081203. If I add, I=
get=20
a problem at the end/begining of the month, I get like 200811=
31 or=20
20081200.

Thanks for any assistance.

Zilore

>_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs QUOTE>



--_000_62432006F5965C42BAEC4EA29286EE0507B180EDF7EXCMS01west at_--

--===============0723490091==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============0723490091==--

RE: How to get yesterday"s date in Perl

am 03.12.2008 17:28:06 von Andy_Bach

> After browsing a lot of documentation I cannot find how to get
yesterday's or tomorrow's date in Perl, like `date --date "-1 day"
"+%Y%m%d"` in bash.

localtime() takes an epoc number (number of seconds from 1/1/1970) and
produces either the date data list (perldoc -f localtime)::
# 0 1 2 3 4 5 6 7 8
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =

localtime(time);

- where 'time()' produces the current epoch number ("1228321233" as I type)
or, in scalar context, a nicely formated date string:
$ perl -e 'print time() . "\n"'
1228321233
$ perl -e 'print localtime() . "\n"'
Wed Dec 3 10:21:23 2008

(by default, 'time()' is the param for localtime() ). So you can get the
values for yest by subtracting 1 day worth of seconds:
my ($mday, $mon, $year) = (localtime(time() - 60 * 60 * 24) ) [ 3,4,5];
printf("%d/%02d/%02d\n", $year + 1900, $mon + 1, $mday - 1);

- note, month is zero based (hence the +1) and year is given as of 1900
(that is, the value for 2008 is 108). If you want a 2 digit year, you need
to mod by 100.

Otherwise there's the core module POSIX which include strftime which lets
you use the full bash/unix 'date' command's format strings. See perldoc
POSIX for details.

a
-------------------
Andy Bach
Systems Mangler
Internet: andy_bach@wiwb.uscourts.gov
Voice: (608) 261-5738 Fax: 264-5932

If I have seen farther than others, it is because I was standing on the
shoulders of giants. -- Isaac Newton
In the sciences, we are now uniquely privileged to sit side by side
with the giants on whose shoulders we stand. -- Gerald
Holton
If I have not seen as far as others, it is because giants were standing
on my shoulders. -- Hal Abelson
In computer science, we stand on each other's feet. -- Brian
K. Reid

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

RE: How to get yesterday"s date in Perl

am 03.12.2008 17:34:16 von Henry Hartley

Andy_Bach@wiwb.uscourts.gov wrote:

>> (by default, 'time()' is the param for localtime() ). So you can
>> get the values for yest by subtracting 1 day worth of seconds:
>> my ($mday, $mon, $year) = (localtime(time() - 60 * 60 * 24) ) [ 3,4,5];
>> printf("%d/%02d/%02d\n", $year + 1900, $mon + 1, $mday - 1);

Will there be a time when that's wrong due to daylight saving time changes?

--
Henry
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: How to get yesterday"s date in Perl

am 03.12.2008 18:26:24 von Gisle Aas

On Dec 3, 2008, at 8:34 , Henry Hartley wrote:

> Andy_Bach@wiwb.uscourts.gov wrote:
>
>>> (by default, 'time()' is the param for localtime() ). So you can
>>> get the values for yest by subtracting 1 day worth of seconds:
>>> my ($mday, $mon, $year) = (localtime(time() - 60 * 60 * 24) )
>>> [ 3,4,5];
>>> printf("%d/%02d/%02d\n", $year + 1900, $mon + 1, $mday - 1);
>
> Will there be a time when that's wrong due to daylight saving time
> changes?

Yes. There are 2 hours each year when this formula is wrong.

--Gisle

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: How to get yesterday"s date in Perl

am 03.12.2008 19:25:57 von Deane.Rothenmaier

This is a multipart message in MIME format.
--===============1913075942==
Content-Type: multipart/alternative;
boundary="=_alternative 0065419D86257514_="

This is a multipart message in MIME format.
--=_alternative 0065419D86257514_=
Content-Type: text/plain; charset="US-ASCII"

>Yes. There are 2 hours each year when this formula is wrong.

I assume you're thinking of the switch from DST to CST and vice-versa,
yes? But since that change occurs at oh-dark-hundred (2:00AM), it's
already "today," and "yesterday" would be the same, wouldn't it? Or is it
a different pair of hours you're referring to?

More seriously, isn't this code subtracting a day twice?

>>>> my ($mday, $mon, $year) = (localtime(time() - 60 * 60 * 24) )[
3,4,5];
>>>> printf("%d/%02d/%02d\n", $year + 1900, $mon + 1, $mday - 1);

I would think that the first, subtracting from time() would be the correct
one--the one that would overcome changes in month, year, and time, while
the second, from $mday's value, is not just redundant, but at this point,
wrong, no? Not only that, it would introduce such curiosities as the
zero-th day of each month--the day before the first of a month.

On a picky note, wouldn't it be easier to just subtract 86400?

Deane Rothenmaier
Programmer/Analyst
Walgreens Corp.
224-542-5150

The chief cause of problems is solutions. - Eric Sevareid
--=_alternative 0065419D86257514_=
Content-Type: text/html; charset="US-ASCII"



>Yes.  There
are 2 hours each year when this formula is wrong.




I assume you're thinking of the switch
from DST to CST and vice-versa, yes?  But since that change occurs
at oh-dark-hundred (2:00AM), it's already "today," and "yesterday"
would be the same, wouldn't it? Or is it a different pair of hours you're
referring to?




More seriously, isn't this code subtracting
a day twice?




>>>> my ($mday, $mon, $year) = (localtime(time()
- 60 * 60 * 24) )[ 3,4,5];

>>>> printf("%d/%02d/%02d\n", $year + 1900, $mon
+ 1, $mday - 1);



I would think that the first, subtracting
from time() would be the correct one--the one that would overcome changes
in month, year, and time, while the second, from $mday's value, is not
just redundant, but at this point, wrong, no? Not only that, it would introduce
such curiosities as the zero-th day of each month--the day before the first
of a month.




On a picky note, wouldn't it be easier
to just subtract 86400?




Deane Rothenmaier

Programmer/Analyst

Walgreens Corp.

224-542-5150



The chief cause of problems is solutions. - Eric Sevareid

--=_alternative 0065419D86257514_=--


--===============1913075942==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1913075942==--

Re: How to get yesterday"s date in Perl

am 03.12.2008 19:43:59 von Andy_Bach

>Yes. There are 2 hours each year when this formula is wrong.

No, there are 2 hours each year where the 'time' fields wouldn't be exactly
24 hours earlier, but the date should be skookum

> More seriously, isn't this code subtracting a day twice?

>>>> my ($mday, $mon, $year) = (localtime(time() - 60 * 60 * 24) )[ 3,4,5];
>>>> printf("%d/%02d/%02d\n", $year + 1900, $mon + 1, $mday - 1);

> I would think that the first, subtracting from time() would be the
correct one--the one that would overcome changes in month, year, and time,
while the second, from $mday's value, is not just redundant, but at this
point, wrong, no?

Right, that's my typo-thinko - I was looking at trying to show the "$mday -
1" route and the attendant issues w/ first day of month etc. and then
compressed it to the better just sub the day's worth of seconds.

printf("%d/%02d/%02d\n", $year + 1900, $mon + 1, $mday);


> On a picky note, wouldn't it be easier to just subtract 86400?

Yes/no - 86400 isn't *that* meaningful to most normal folks (though I
should consider the audience) but 60*60*24 sort of documents where the
result comes from. Sort of.

a

-------------------
Andy Bach
Systems Mangler
Internet: andy_bach@wiwb.uscourts.gov
Voice: (608) 261-5738 Fax: 264-5932

When I retire, I'm going to spend my evenings by the fireplace, going
through those boxes. There are things in there that ought to be burned.
Richard Millhouse Nixon (Parade magazine)

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: How to get yesterday"s date in Perl

am 03.12.2008 19:55:23 von Gisle Aas

--===============1726264785==
Content-Type: multipart/alternative; boundary=Apple-Mail-2-915220281


--Apple-Mail-2-915220281
Content-Type: text/plain;
charset=US-ASCII;
format=flowed;
delsp=yes
Content-Transfer-Encoding: 7bit

On Dec 3, 2008, at 10:25 , Deane.Rothenmaier@walgreens.com wrote:

>
> >Yes. There are 2 hours each year when this formula is wrong.
>
> I assume you're thinking of the switch from DST to CST and vice-
> versa, yes? But since that change occurs at oh-dark-hundred
> (2:00AM), it's already "today," and "yesterday" would be the same,
> wouldn't it? Or is it a different pair of hours you're referring to?

This occurs on the 23th hour in the fall and the 0th hour in the
spring. This program shows a brute force way to find these that might
convince you:

------------------------
$h = 60 * 60;
$end = time + 366 * 24 * $h;

for ($t = time; $t < $end; $t += 0.5 * $h) {
print scalar(localtime($t)), "\n" if day($t) eq day($t + $h) &&
day($t - 24 * $h) ne day($t + $h - 24 * $h);
}

sub day {
my($y, $m, $d) = (localtime shift)[5,4,3];
$y += 1900;
$m += 1;
return sprintf "%04d-%02d-%02d", $y, $m, $d;
}
------------------------

> More seriously, isn't this code subtracting a day twice?

True. That's a bug.

>
>
> >>>> my ($mday, $mon, $year) = (localtime(time() - 60 * 60 * 24) )
> [ 3,4,5];
> >>>> printf("%d/%02d/%02d\n", $year + 1900, $mon + 1, $mday - 1);
>
> I would think that the first, subtracting from time() would be the
> correct one--the one that would overcome changes in month, year, and
> time, while the second, from $mday's value, is not just redundant,
> but at this point, wrong, no? Not only that, it would introduce such
> curiosities as the zero-th day of each month--the day before the
> first of a month.
>
> On a picky note, wouldn't it be easier to just subtract 86400?

Easier to type perhaps but possibly not easier to most people to
recognize as correct. For Perl it does not matter as it will fold
constants at compile time and execute exactly the same code. Try:

perl -MO=Deparse -e "print time + 24 * 60 * 60"

--Gisle


--Apple-Mail-2-915220281
Content-Type: text/html;
charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

-webkit-line-break: after-white-space; ">

On Dec 3, 2008, at =
10:25 , href=3D"mailto:Deane.Rothenmaier@walgreens.com">Deane.Rothen maier@walgreen=
s.com
wrote:

type=3D"cite">
> size=3D"2">Yes.  There are 2 hours each year when this formula is =
wrong.


I =
assume you're thinking of the switch from DST to CST and vice-versa, =
yes?  But since that change occurs at oh-dark-hundred (2:00AM), =
it's already "today," and "yesterday" would be the same, wouldn't it? Or =
is it a different pair of hours you're referring to?
=

This occurs on the 23th hour in the =
fall and the 0th hour in the spring.  This program shows a brute =
force way to find these that might convince =
you:

------------------------
$h&n=
bsp;=3D 60 * 60;
$end =3D time + 366 * 24 * =
$h;

for ($t =3D time; $t < $end; $t +=3D 0.5 =
* $h) {
    print scalar(localtime($t)), "\n" =
if day($t) eq day($t + $h) && day($t - 24 * $h) ne day($t + $h - =
24 * $h);
}

sub day =
{
    my($y, $m, $d) =3D (localtime =
shift)[5,4,3];
    $y +=3D =
1900;
    $m +=3D 1;
   =
 return sprintf "%04d-%02d-%02d", $y, $m, =
$d;
}
------------------------

ote type=3D"cite">More seriously, =
isn't this code subtracting a day =
twice?

True.  That's a =
bug.



>>>>=
my ($mday, $mon, $year) =3D (localtime(time() - 60 * 60 * 24) )[ =
3,4,5];
>>>> printf("%d/%02d/%02d\n", $year + 1900, $mon + 1, $mday =
- 1);

I would =
think that the first, subtracting from time() would be the correct =
one--the one that would overcome changes in month, year, and time, while =
the second, from $mday's value, is not just redundant, but at this =
point, wrong, no? Not only that, it would introduce such curiosities as =
the zero-th day of each month--the day before the first of a month. =


On a picky note, =
wouldn't it be easier to just subtract 86400?
=

Easier to type perhaps but possibly not =
easier to most people to recognize as correct.  For Perl it does =
not matter as it will fold constants at compile time and execute exactly =
the same code.  Try:

   =
 perl -MO=3DDeparse -e "print time + 24 * 60 * =
60"

--Gisle

ml>=

--Apple-Mail-2-915220281--

--===============1726264785==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1726264785==--

Re: How to get yesterday"s date in Perl

am 03.12.2008 20:46:23 von Andy_Bach

> This occurs on the 23th hour in the fall and the 0th hour in the spring.
This program shows a brute force way
> to find these that might convince you [1].


Slick! I'm convinced. Hmm, so if you need it to be ever accurate (and want
to stay w/ localtime() you need to track changes in the DST field,
something like:
my ($isdst) = ( localtime() ) [8];

my ($mday, $mon, $year, $prev_isdst) = (localtime(time - 60 * 60 * 24) )[
3,4,5, 8];
printf("%d/%02d/%02d\n", $year + 1900, $mon + 1,
$isdst == $prev_isdst ? $mday
: $isdst > $prev_isdst ? (localtime($t - 60 * 60 * 23) )[ 3]
: (localtime($t - 60 * 60 * 25) )[ 3]
);

Probably won't convince you [2] but ....

a

[1]
$h = 60 * 60;
$end = time + 366 * 24 * $h;

for ($t = time; $t < $end; $t += 0.5 * $h) {
print scalar(localtime($t)), "\n" if day($t) eq day($t + $h) && day($t
- 24 * $h) ne day($t + $h - 24 * $h);
}

sub day {
my($y, $m, $d) = (localtime shift)[5,4,3];
$y += 1900;
$m += 1;
return sprintf "%04d-%02d-%02d", $y, $m, $d;
}

[2]
#!/usr/bin/perl
my $h = 60 * 60;
my $end = time + 366 * 24 * $h;

my $cur_isdst;
for (my $t = time; $t < $end; $t += 0.1 * $h) {
# 0 1 2 3 4 5 6 7 8
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($t);

my ($mday, $mon, $year, $prev_isdst) = (localtime($t - 60 * 60 * 24) )[
3,4,5, 8];
printf("%d/%02d/%02d - cur: %s -24: %s -23: %s\n", $year + 1900, $mon + 1,
$isdst == $prev_isdst ? $mday
: $isdst > $prev_isdst ? (localtime($t - 60 * 60 * 23) )[ 3]
: (localtime($t - 60 * 60 * 25) )[ 3]
, scalar(localtime($t)) ,
day($t + $h) , day($t - 24 * $h), day($t + $h - 24 * $h) )
if day($t) eq day($t + $h) && day($t - 24 * $h) ne day($t + $h - 24 * $h);

# print scalar(localtime($t)), "\n" if day($t) eq day($t + $h) && day($t
- 24 * $h) ne day($t + $h - 24 * $h);
}

sub day {
my($y, $m, $d) = (localtime shift)[5,4,3];
$y += 1900;
$m += 1;
return sprintf "%04d-%02d-%02d", $y, $m, $d;
}
-------------------
Andy Bach
Systems Mangler
Internet: andy_bach@wiwb.uscourts.gov
Voice: (608) 261-5738 Fax: 264-5932

When I retire, I'm going to spend my evenings by the fireplace, going
through those boxes. There are things in there that ought to be burned.
Richard Millhouse Nixon (Parade magazine)

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

RE: How to get yesterday"s date in Perl

am 03.12.2008 20:58:31 von Henry Hartley

Andy_Bach@wiwb.uscourts.gov

>> > This occurs on the 23th hour in the fall and the 0th hour in the
>> > spring. This program shows a brute force way to find these that
>> > might convince you [1].
>> >
>> Slick! I'm convinced. Hmm, so if you need it to be ever accurate
>> (and want to stay w/ localtime() you need to track changes in the
>> DST field, something like:

I had a script that did something like this a while back and it ran every ten minutes. Caused no end of headaches that first time it came up to a Standard/Daylight Saving boundry. That's one of the best selling points of modules. These issues have usually been addressed so you don't have to worry about them. Just use Date::Calc and you can subtract one day. Easy as that.

--
Henry
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: How to get yesterday"s date in Perl

am 03.12.2008 21:20:38 von Andy_Bach

> now I'm confused ...

my ($isdst) = ( localtime() ) [8];

my ($mday, $mon, $year, $prev_isdst) = (localtime(time - 60 * 60 * 24) )[
3,4,5, 8];
printf("%d/%02d/%02d\n", $year + 1900, $mon + 1,
$isdst == $prev_isdst ? $mday
: $isdst > $prev_isdst ? (localtime($t - 60 * 60 * 23) )[ 3]
: (localtime($t - 60 * 60 * 25) )[ 3]
);


The idea is, when DST starts/stops, it'll be different than 24 hours ago.
Depending upon which way it changed (the values are 1 and zero) we either
need to subtract 23 hours or 25 hours to be correct. I think.

Yes, this is why modules are a better idea. There are places where, alas,
you can't get those modules (for instance, our production box) or are
otherwise limited.

a
-------------------
Andy Bach
Systems Mangler
Internet: andy_bach@wiwb.uscourts.gov
Voice: (608) 261-5738 Fax: 264-5932

When I retire, I'm going to spend my evenings by the fireplace, going
through those boxes. There are things in there that ought to be burned.
Richard Millhouse Nixon (Parade magazine)

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: How to get yesterday"s date in Perl

am 04.12.2008 00:49:03 von Bill Luebkert

Andy_Bach@wiwb.uscourts.gov wrote:
>> This occurs on the 23th hour in the fall and the 0th hour in the spring.
> This program shows a brute force way
>> to find these that might convince you [1].
>
>
> Slick! I'm convinced. Hmm, so if you need it to be ever accurate (and want
> to stay w/ localtime() you need to track changes in the DST field,
> something like:
> my ($isdst) = ( localtime() ) [8];
>
> my ($mday, $mon, $year, $prev_isdst) = (localtime(time - 60 * 60 * 24) )[
> 3,4,5, 8];
> printf("%d/%02d/%02d\n", $year + 1900, $mon + 1,
> $isdst == $prev_isdst ? $mday
> : $isdst > $prev_isdst ? (localtime($t - 60 * 60 * 23) )[ 3]
> : (localtime($t - 60 * 60 * 25) )[ 3]
> );
>

If he's only interested in the date and not the time, I would think
just using localtime and changing the hour field to noon and using
Time::Local::timelocal to reverse back to epoch time would ensure
that your next localtime call would produce the correct date no
matter what the time is.

use Time::Local;
my @t = localtime; # convert epoch time for today to fields
$t[2] = 12; # change hour to noonish
my $time = timelocal (@t); # convert back to epoch time
my @d = localtime $time; # @d now has the correct date for yesterday
# which you could also use with POSIX::strftime
# to format as you like
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

RE: How to get yesterday"s date in Perl

am 04.12.2008 08:32:04 von francois.bourgneuf

use Date::Calc qw(Today Add_Delta_Days);
$yesterday=3Dsprintf( "%04d/%02d/%02d", Add_Delta_Days( Today(), -1 ) );
print $yesterday

>>> 2008/12/03

Bour9

> -----Message d'origine-----
> De : activeperl-bounces@listserv.ActiveState.com =

> [mailto:activeperl-bounces@listserv.ActiveState.com] De la =

> part de Bill Luebkert
> Envoy=E9 : jeudi 4 d=E9cembre 2008 00:49
> =C0 : activeperl@listserv.activestate.com
> Objet : Re: How to get yesterday's date in Perl
> =

> Andy_Bach@wiwb.uscourts.gov wrote:
> >> This occurs on the 23th hour in the fall and the 0th hour =

> in the spring.
> > This program shows a brute force way
> >> to find these that might convince you [1].
> > =

> > =

> > Slick! I'm convinced. Hmm, so if you need it to be ever =

> accurate (and want
> > to stay w/ localtime() you need to track changes in the DST field,
> > something like:
> > my ($isdst) =3D ( localtime() ) [8];
> > =

> > my ($mday, $mon, $year, $prev_isdst) =3D (localtime(time - =

> 60 * 60 * 24) )[
> > 3,4,5, 8];
> > printf("%d/%02d/%02d\n", $year + 1900, $mon + 1,
> > $isdst == $prev_isdst ? $mday
> > : $isdst > $prev_isdst ? (localtime($t - 60 * 60 * 23) )[ 3]
> > : (localtime($t - 60 * 60 * 25) )[ 3]
> > );
> > =

> =

> If he's only interested in the date and not the time, I would think
> just using localtime and changing the hour field to noon and using
> Time::Local::timelocal to reverse back to epoch time would ensure
> that your next localtime call would produce the correct date no
> matter what the time is.
> =

> use Time::Local;
> my @t =3D localtime; # convert epoch time for today to fields
> $t[2] =3D 12; # change hour to noonish
> my $time =3D timelocal (@t); # convert back to epoch time
> my @d =3D localtime $time; # @d now has the correct date =

> for yesterday
> # which you could also use with =

> POSIX::strftime
> # to format as you like
> _______________________________________________
> ActivePerl mailing list
> ActivePerl@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> =

> =

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

RE: How to get yesterday"s date in Perl

am 05.12.2008 09:02:07 von zilore mumba

--===============0320514961==
Content-Type: multipart/alternative; boundary="0-418655998-1228464127=:21834"

--0-418655998-1228464127=:21834
Content-Type: text/plain; charset=us-ascii



Thank you to all who contributed to this discussion. Not only did this assist me in my problem, but I learnt a lot from the various contributions. Thanks so muchZilore



--0-418655998-1228464127=:21834
Content-Type: text/html; charset=us-ascii



Thank you to all who contributed to this discussion. Not only did this assist me in my problem, but I learnt a lot from the various contributions. Thanks so much
Zilore




--0-418655998-1228464127=:21834--

--===============0320514961==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============0320514961==--

escape some char

am 11.12.2008 12:06:17 von p sena

Hi,

Can someone pls shed me some light>>
I have a func --
sub get_formatStr {
my $formatStr = '"%xxxx#%yyyy#%zzzzz"';
return $formatStr;
}
where in above, %xxx, %yyy & %zzz are literals & all three being delimeted by '#' and the combination should always be enclosed by double quotes.
I have to use this string in a regex as below-
$cmd = "$prog -o $formatStr $queryStr"; ## first $cmd
But this cribs in cmd execution and o/p bangs!
However $cmd = "$prog -o \"%lxxxx#%yyyy#%zzzzz\" $queryStr"; ## second $cmd.
works fine & supplies expected o/p.no issues with $queryStr too. Now, problem arises when I use the first $cmd. Is there any way (built in funcs or tekniks) where in I can use the first $cmd and still get the good o/p as from second $cmd ?

TIA




_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: escape some char

am 11.12.2008 12:56:48 von p sena

Apologies, no regex being used here. Actu ally the question lies in why is the difference seen between when i use
$cmd_1 = "$prog -o $formatStr $queryStr";
and
$cmd_2 = "$prog -o \"%xxxx#%yyyy#%zzzzz\" $queryStr"; ## this is Ok.

In cmd 1 formatStr is equal to '"%xxxx#%yyyy#%zzzzz' (same as seen in cmd 2 except here dbl quotes exists as it is), and the single quotes are necessary.

Cheers.



--- On Thu, 12/11/08, Williamawalters@aol.com wrote:

> From: Williamawalters@aol.com
> Subject: Re: escape some char
> To: senapati2001@yahoo.com
> Date: Thursday, December 11, 2008, 5:03 PM
> hi --
>
> In a message dated 12/11/2008 6:06:45 A.M. Eastern Standard
> Time,
> senapati2001@yahoo.com writes:
>
> > Hi,
> >
> > Can someone pls shed me some light>>
> >
> > I have a func --
> >
> > sub get_formatStr {
> > my $formatStr =
> '"%xxxx#%yyyy#%zzzzz"';
> > return $formatStr;
> > }
> >
> > where in above, %xxx, %yyy & %zzz are literals
> > & all three being delimeted by '#'
> > and the combination should always be enclosed by
> double quotes.
> >
> > I have to use this string in a regex as below-
> > $cmd = "$prog -o $formatStr $queryStr";
> ## first $cmd
> > But this cribs in cmd execution and o/p bangs!
> > However
> > $cmd = "$prog -o
> \"%lxxxx#%yyyy#%zzzzz\" $queryStr";
> ## second $cmd.
> > works fine & supplies expected o/p.no issues with
> $queryStr too.
> > Now, problem arises when I use the first $cmd.
> > Is there any way (built in funcs or tekniks) where in
> I can
> > use the first $cmd and still get the good o/p as from
> second $cmd ?
> >
> > TIA
>
>
> i cannot see why the two strings should differ and hence
> why there should
> be any difference in their effect.
>
> i suspect you are not showing all relevant code.
>
> try this and see if the two strings are indeed exactly
> equal:
>
> my $fs = formatStr();
> my $cmd_1 = "$prog -o $fs $queryStr";
> my $cmd_2 = "$prog -o
> \"%xxxx#%yyyy#%zzzzz\" $queryStr";
> $cmd_1 eq $cmd_1 or die ":$cmd_1: not really
> :$cmd_2:";
>
> (btw -- although you do not show any such code, you mention
> using
> the format string returned from the function formatStr() in
> a regex.
> are you aware that the '#' character is a
> 'comment-to-end-of-line' when
> used in a regex with the regex //x switch?)
>
> hth -- bill walters
>
>
> **************Make your life easier with all your friends,
> email, and
> favorite sites in one place. Try it now.
> (http://www.aol.com/?optin=new-dp&icid=aolcom40vanity&ncid=e mlcntaolcom00000010)




_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

RE: escape some char

am 11.12.2008 13:02:37 von Brian Raven

p sena <> wrote:
> Hi,
>
> Can someone pls shed me some light>>
> I have a func --
> sub get_formatStr {
> my $formatStr = '"%xxxx#%yyyy#%zzzzz"';
> return $formatStr;
> }
> where in above, %xxx, %yyy & %zzz are literals & all three being
> delimeted by '#' and the combination should always be enclosed by
> double quotes.
> I have to use this string in a regex as below- $cmd = "$prog -o
> $formatStr $queryStr"; ## first $cmd But this cribs in cmd execution
> and o/p bangs!
> However $cmd = "$prog -o \"%lxxxx#%yyyy#%zzzzz\" $queryStr"; ##
> second $cmd.
> works fine & supplies expected o/p.no issues with $queryStr too. Now,
> problem arises when I use the first $cmd. Is there any way (built in
> funcs or tekniks) where in I can use the first $cmd and still get the
> good o/p as from second $cmd ?

Sorry, but I find it pretty difficult to work out what you are asking
from that. You refer to a "regex" but I see no sign of any regex, and
"this cribs in cmd execution and o/p bangs!" lost me completely. A
small, self contained example script (SSCE) that illustrated your
problem and that I could cut and paste, and run on my box might have
been more useful.

My best guess from reading your post several times is that you are
asking about quoting. If so, check out the quoting operators in 'perldoc
perlop', probably qq. If not, please feel free to try again, especially
with the SSCE.

HTH

--
Brian Raven

------------------------------------------------------------ -----------------------------------------------
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.


_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: escape some char

am 11.12.2008 13:08:26 von Bill Luebkert

p sena wrote:
> Hi,
>
> Can someone pls shed me some light>>
> I have a func --
> sub get_formatStr {
> my $formatStr = '"%xxxx#%yyyy#%zzzzz"';
> return $formatStr;
> }
> where in above, %xxx, %yyy & %zzz are literals & all three being delimeted by '#' and the combination should always be enclosed by double quotes.
> I have to use this string in a regex as below-
> $cmd = "$prog -o $formatStr $queryStr"; ## first $cmd
> But this cribs in cmd execution and o/p bangs!
> However $cmd = "$prog -o \"%lxxxx#%yyyy#%zzzzz\" $queryStr"; ## second $cmd.
> works fine & supplies expected o/p.no issues with $queryStr too. Now, problem arises when I use the first $cmd. Is there any way (built in funcs or tekniks) where in I can use the first $cmd and still get the good o/p as from second $cmd ?

Try: my $formatStr = '\\"%xxxx#%yyyy#%zzzzz\\"';
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: escape some char

am 11.12.2008 13:10:24 von Williamawalters

--===============1756718378==
Content-Type: multipart/alternative;
boundary="-----------------------------1228997424"


-------------------------------1228997424
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit


In a message dated 12/11/2008 6:57:14 A.M. Eastern Standard Time,
senapati2001@yahoo.com writes:

> the question lies in why is the difference seen
> between when i use
> $cmd_1 = "$prog -o $formatStr $queryStr";
> and
> $cmd_2 = "$prog -o \"%xxxx#%yyyy#%zzzzz\" $queryStr";


if $cmd_1 and $cmd_2 are indeed the same (i.e., if you include the
code fragment i listed in your code and the script does not die),
then any difference in behavior cannot be due to these strings
or to substrings of which they are composed.

the best thing to do is probably to start looking in some other
direction to find the reason for any differences in behavior.

hth -- bill


**************Make your life easier with all your friends, email, and
favorite sites in one place. Try it now.
(http://www.aol.com/?optin=new-dp&icid=aolcom40vanity&ncid=e mlcntaolcom00000010)

-------------------------------1228997424
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable





Arial"=20
bottomMargin=3D7 leftMargin=3D7 topMargin=3D7 rightMargin=3D7> e_document=20
face=3DArial color=3D#000000 size=3D2>


In a message dated 12/11/2008 6:57:14 A.M. Eastern Standard Time,=20
senapati2001@yahoo.com writes:

 

> the question lies in why is the difference seen
> between wh=
en i=20
use
> $cmd_1 =3D "$prog -o $formatStr $queryStr";
> and
>=20=
$cmd_2=20
=3D "$prog -o \"%xxxx#%yyyy#%zzzzz\" $queryStr";

 

 

if $cmd_1 and $cmd_2 are indeed the same (i.e., if you include the >
code fragment i listed in your code and the script does not die),

then any difference in behavior cannot be due to these strings

or to substrings of which they are composed.  

 

the best thing to do is probably to start looking in some other

direction to find the reason for any differences in behavior. &nbs=
p;=20

 

hth -- bill  

 



=3D"63b9f537f9e27ef62bb0a2805c2b99fb"> mal 10pt ARIAL, SAN-SERIF;">
Make your life ea=
sier with all your friends, email, and favorite sites in one place. =3D"http://www.aol.com/?optin=3Dnew-dp&icid=3Daolcom40vanity &ncid=3Demlcntao=
lcom00000010">Try it now
.


-------------------------------1228997424--

--===============1756718378==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1756718378==--