binmode PHOTO_IN; #Set filemode to bin for good measure $/= "\x42\x49\x4D\x03"; #Input Record Delimeter. $cnt=0; #We want 1st of 2 records. while (<PHOTO_IN>) { #Read Photo... if ("$cnt"<1) { # Have Photo Header... $photo_header="$_"; # Save Photo Header... ++$cnt; # Bump count to skip photo. } } $photo_header =~ s/\x1C\x02/XYZZY/g; # Replace hex markers with text. $photo_header =~ s/[\n\r]/\x20/g; # Replace newlines with space. @fields=split(/XYZ/,$photo_header); # Set array using text marker. $n=2; # Start at 2 to skip junk. ITEM: while ( "$fields[$n]" ne "" ) {# Process all array elements. $fields[$n] =~ s/ZY\x78../Caption : /; # Set Caption Text Marker. if ($fields[$n] =~ /^Caption/) { # Save Caption Text for database. $caption=""; $caption=substr($fields[$n],10); #Apply the filters to the caption $caption =~ s/(\s*)$//g; $caption =~ s/'/''/g; $caption =~ s/\n//g; $caption =~ tr/a-zA-Z0-9\`\~\!\@\#\$\%\^\&\*\(\)\_\+\-\=\{\}\|\[\ +]\\\:\"\;\'\<\>\?\,\.\/ \t//cd; $caption =~ s/8BIM.*$//g; } $n++; }#endofwhile
In reply to Grabbing Jpeg Captions by devmage
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |