if($filename ne "." && $filename ne ".." && substr($filename,length($filename)-4,4) eq ".jpg")

1) Is there such a thing as a file which ends ".jpg" and also equals "."? No, so you don't need those clauses, just the ".jpg" one. Nor do you need the length in order to do a negative substring. But as noted above, checking whether it matches /\.jpg$/i is a better test.

2) You're having trouble figuring out the URL? We can't help you because we don't know your server. It could be anything. If your server is "metlelite.com" and the images are in "public_html/foo/bar/images/" then the URL is probably "metlelite.com/foo/bar/images/filename.jpg". Trial and error should sort that out!

3)

print FIL "<pic$t name=\"$nfile\"></pic$t>\n";
would be a lot easier on the eye if you used the qq() function, as in
print FIL qq(<pic$t name="$nfile"></pic$t>\n)";

4) It would probably be better to use an XML module, in the long run. Your output is technically XML but all kinds of errors and incompatibilities could creep in and you'd never know because you're rolling it by hand.



($_='kkvvttuu bbooppuuiiffss qqffssmm iibbddllffss')
=~y~b-v~a-z~s; print

In reply to Re: creating an xml file from perl by Cody Pendant
in thread creating an xml file from perl by decerebrate

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.