devmage has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Grabbing Jpeg Captions
by CombatSquirrel (Hermit) on Sep 30, 2003 at 16:15 UTC | |
by devmage (Initiate) on Sep 30, 2003 at 17:25 UTC | |
|
Re: Grabbing Jpeg Captions
by MidLifeXis (Monsignor) on Sep 30, 2003 at 15:51 UTC | |
by devmage (Initiate) on Sep 30, 2003 at 17:10 UTC | |
by MidLifeXis (Monsignor) on Sep 30, 2003 at 17:20 UTC | |
by devmage (Initiate) on Sep 30, 2003 at 17:46 UTC | |
|
Re: Grabbing Jpeg Captions
by menolly (Hermit) on Sep 30, 2003 at 22:52 UTC | |
by devmage (Initiate) on Oct 01, 2003 at 13:18 UTC |