in reply to creating an xml file from perl

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

Replies are listed 'Best First'.
Re^2: creating an xml file from perl
by decerebrate (Initiate) on Apr 14, 2005 at 00:00 UTC

    greetings

    i apologize if i have been unlear

    what i do not know how to do is to have perl insert the path of the file into the xml document as an attribute ie

    <imageURL="/images/image1.jpg" />

    i have never laid eyes upon perl before today

      You just stick the literal "/images/" in there. A-like so:
      print qq(<item id="$t" imageURL="/images/$filename" /> \n);
      And if you really meant to chop off the extension, you'd do
      print qq(<item id="$t" imageURL="/images/$nfile" /> \n);