Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Ok, I went through the replies just now, and did some google also. For my need I actually do not need to use any modules. I have a very simple requirement! Here is the code I wrote. In this I have put incrtime as 1 sec, but I can put any number of seconds I want, so no issues there!
#!/usr/bin/perl use strict; my $lat = 23.438; my $slon= 68.000; my $elon= 90.000; my $clon = $slon; my $incrlon= 0.01; my $time = time; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($ +time) ; my $incrtime=1; my $printmon; my $printyear; open OUTFILE,">tropic_of_cancer.gpx" or die \"Cannot open file for wri +ting\n"; print \"Printing Header...\n"; print OUTFILE "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"n +o\"?>\n"; print OUTFILE "<gpx version=\"1.1\" creator=\"MakeTropic\" xmlns=\"htt +p://www.topografix.com/GPX/1/1\" xmlns:xsi=\"http://www.w3.org/2001/X +MLSchema-instance\" xsi:schemaLocation=\"http://www.topografix.com/GP +X/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">\n"; print OUTFILE "<trk>\n"; print OUTFILE " <name>Tropic of Cancer</name>\n"; while ($clon < $elon) { $printmon = $mon+1; $printyear = $year+1900; print OUTFILE " <trkseg>\n"; printf OUTFILE (" <trkpt lat=\"%.3f\" lon=\"%.3f\">\n", +$lat,$clon); print OUTFILE " <time>$printyear-$printmon-$mday"." +T"."$hour:$min:$sec"."Z"."</time>\n"; print OUTFILE " </trkpt>\n"; $clon=$clon+$incrlon; $time=$time+$incrtime; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime( +$time) ; } print OUTFILE " </trkseg>\n"; print OUTFILE " </trk>\n"; print OUTFILE "</gpx>"; close OUTFILE;
It works fast and is tiny.

In reply to Solution found! by tsk1979
in thread Simple date and time manipulation by tsk1979

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-24 05:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found