Good day Monks! I guess work's just got my head so clouded now that I can't read between the lines of what the tutorials are trying to tell me so forgive me if this is a dumb question.

I'm using XML::Simple 2.18 with Perl 5.8.8.

I'm trying to read a conf file, perform some stuff, and then in the conf file keep track of the last time I executed my code.

My XML looks like
<conf> <box1> <username>me</username> <password>secret</password> </box1> <box2> <username>me</username> <password>secret</password> </box2> <lastRun>DATE</lastRun> </conf>
DATE above should be epoch time. my simplified perl is
#!/usr/bin/perl use strict; use XML::Simple; use Data::Dumper; my $xmlConf = "file.xml"; my $conf = new XML::Simple(NoAttr => 1, KeyAttr => [], ForceArray => [ +qw(box1 box2)], KeepRoot => 1, SearchPath => "." ); my $confIn = $conf->XMLin("$xmlConf"); my $confOut = $conf->XMLout($confIn, OutputFile => $xmlConf); print "Box 1: Username - $confIn->{conf}->{Box1}[0]->{username}, Passw +ord - $confIn->{conf}->{Box1}[0]->{password}\n"; print "Box 2: Username - $confIn->{conf}->{Box2}[0]->{username}, Passw +ord - $confIn->{conf}->{Box2}[0]->{password}\n"; my $epoch = time(); $confOut->{conf}->{lastRun} = $epoch;
My code runs fine up till I try to write out the update. I get
Can't use string ("1") as a HASH ref while "strict refs" in use at line foo

Thanks in advance for the forthcoming enlightenment!

Kevin

In reply to Yet another xml::simple question by sandcrawler

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.