Re: [Arsperl-users] Performance problems
Brought to you by:
jeffmurphy
|
From: Priddy, T. <tim...@in...> - 2007-08-02 21:30:31
|
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) =3D =
localtime ( $entry{$field_id[3]} ); =
=20
my $timestamp_a =3D sprintf "%02d/%02d/%04d %02d.%02d.%02d", $mday, $mon =
+ 1, $year + 1900, $hour, $min, $sec;
=20
I'd recommend that you also start using:
=20
use warnings;
use strict;
=20
-----Original Message-----
From: ars...@ar... =
[mailto:ars...@ar...] On Behalf Of Thilo Stapff
Sent: Thursday, August 02, 2007 8:50 AM
To: ARSperl User Discussion
Subject: Re: [Arsperl-users] Performance problems
=20
$field_ids[3] contains just the field id itself.
=20
The value of the field is in $entry{$field_id[3]}}.
=20
You should also note that gmtime returns the month as numbers 0..11=20
instead of 1..12.
Anyway, an easier (and problably more reliable) method for date=20
formatting would be to use a module from CPAN (e.g. Date::Format).
=20
=20
Regards,
Thilo
=20
=20
Paizo wrote:
> i tried the following:
>=20
>=20
> foreach my $entry_id (sort keys %entries) {
> my %entry =3D ars_GetEntry($ctrl, $ARSschema, $entry_id, =
@field_ids);
>=20
> print "$field_ids[3]\n";# test: print number 3 the first clicle =
then=20
> nothing
>=20
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =3D=20
> gmtime($field_ids[3]); =20
> =20
> $year +=3D 1900;
> $mon +=3D 1;
> =20
> if ($mday < 10) {
> $timestamp_a =3D "0".$mday.q{/};
> } else {
> $timestamp_a =3D $mday.q{/};
> }
> =20
> if ($mon < 10) {
> $timestamp_a .=3D "0".$mon.q{/}.$year." ";
> } else {
> $timestamp_a .=3D $mon.q{/}.$year." ";
> }
> =20
> if ($hour < 10) {
> $timestamp_a .=3D "0".$hour.".";
> } else {
> $timestamp_a .=3D $hour.".";
> } =20
>=20
> if ($min < 10) {
> $timestamp_a .=3D "0".$min.".";
> } else {
> $timestamp_a .=3D $min.".";
> } =20
>=20
> if ($sec < 10) {
> $timestamp_a .=3D "0".$sec;
> } else {
> $timestamp_a .=3D $sec;
> }
>=20
> print "$timestamp_a\n\n"; #test: print 01/01/1970 00.00.03 in the =
> first cile then always 01/01/1970 00.00.00
>=20
> $field_ids[3] =3D $timestamp_a;
> print datafile join("|", @entry{@field_ids} ) . "\n";
>=20
> }
>=20
>=20
> hope its more clear.
>=20
>=20
>=20
> 2007/8/2, Clayton Scott <cla...@gm...=20
> <mailto:cla...@gm...>>:
>=20
> On 8/2/07, Paizo <pai...@gm...
> <mailto:pai...@gm...>> wrote:
> > i have another ( stupid question, still new to perl :| ) , if
> inside the the
> > loop:
> > [ loop snipped ]
> > i want to convert some dates that are in seconds since 1970 to
> something
> > like dd/mm/yyyy hh.mm.ss
> > if i try to read $field_ids[3] and always get "3" instead of =
the real
> > content :/
> > what i miss?
>=20
> Without more code, and data I really can't tell.
>=20
> If you want the value for a field in the form you more likely want =
to
> use the entry hash:
>=20
> $entry{'field_id'}
>=20
> If you want to inspect these data structures you can use the
> Data::Dumper module.
>=20
> use Data::Dumper;
> ....
>=20
> print Dumper \@field_ids;
>=20
> foreach my $entry_id (sort keys %entries) {
> my %entry =3D ars_GetEntry($ctrl, $ARSschema, $entry_id, =
@field_ids);
> print Dumper \%entry;
> print datafile join("|", @entry{@field_ids} ) . "\n";
> }
>=20
> --
>=20
> Clayton Scott
> cla...@gm... <mailto:cla...@gm...>
>=20
> =
-------------------------------------------------------------------------=
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a =
browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Arsperl-users mailing list
> Ars...@ar... <mailto:Ars...@ar...>
> https://lists.sourceforge.net/lists/listinfo/arsperl-users
>=20
>=20
>=20
>=20
> --=20
> --------------------
> A me cugin na volta xe nd=E0 dal geataro e el ga domand=E0 na coppetta =
> trigusto co i gusti seegheta, sarexe e schie co na fettina de poenta.
> El geataro pena sentio che=E0 goduriosa scelta, el se ga messo subito =
el=20
> pigiama de banane e el ghe ga messo in testa a corona de poegge medie =
e=20
> lo ga fatto diventare Re dei Gelati Biricchini.
> -----------------------
> Confezione trigusto seegheta/sarexe/chie co pratico contenitore par e=20
> fete de poenta, stile estat=E8 o quea dea ciocoeata
> Altri gusti poe essere bigadini/kiwi/lasonil co socoi de vacca da=20
> tociare o erbagatta/straciatella/calsina co coe de sorxe da tociare
> ------------
> Rileggendo a firma diria che se poe puntare al mercato dei ghiaccioli=20
> col el gusto crema al diserbo e parafl=F9 ricoperta da una soffice =
crosta=20
> de pus co al posto del bacheto un termometro anale pratico pa =
misurarse=20
> a freve dopo aver magn=E0 el geato (chi xe che no lo fa al giorno=20
> d'oggi?!?!). Garantite scorese bitonali e solfeggi anali.
>=20
>=20
> =
------------------------------------------------------------------------
>=20
> =
-------------------------------------------------------------------------=
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a =
browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
>=20
>=20
> =
------------------------------------------------------------------------
>=20
> _______________________________________________
> Arsperl-users mailing list
> Ars...@ar...
> https://lists.sourceforge.net/lists/listinfo/arsperl-users
=20
=20
-------------------------------------------------------------------------=
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Arsperl-users mailing list
Ars...@ar...
https://lists.sourceforge.net/lists/listinfo/arsperl-users
|