Beginner wrote:
> On 11 Aug 2006 at 14:45, John W. Krahn wrote:
>>
>>use strict;
>>use warnings;
>>use XML::Simple;
>>use Data::Dumper;
>>
>>my $file = 'test2.tif';
>>
>>open my $FH, '<:raw', $file or die "Can't open $file: $!\n";
>>
>>my $data;
>>while ( <$FH> ) {
>> next unless s!.*?<x:xapmeta xmlns:x='adobe:ns:meta/!!;
>> $data = $_;
>>
>> $data .= <$FH> until $data =~ s!</x:xapmeta>.*!!s;
>> last;
>>}
>>
>>close $FH;
>>print Dumper $data;
>
>
> That's interesting, thanx John.
>
> It is leaner. You have eliminated all the seek/read stuff, nice.
>
> You haven't specified binmode, is it implied by the '<:raw' notation?
Yes.
perldoc PerlIO
> What is "s!." in line 12, "next unless s!...."
s/// is the substitution operator.
perldoc perlop
Because the pattern contains the '/' character I used the '!' character to
delimit it instead of using '/'.
> I haven't seen a filehandle made into a variable, is there some more
> reading I could be doing, perlI/O perhaps?
perldoc -f open
[snip]
If FILEHANDLE is an undefined scalar variable (or array or hash
element) the variable is assigned a reference to a new anonymous
filehandle,
perldoc perlopentut
[snip]
Indirect Filehandles
"open"’s first argument can be a reference to a filehandle. As of perl
5.6.0, if the argument is uninitialized, Perl will automatically create a
filehandle and put a reference to it in the first argument, like so:
> Here the output I get:
>
> $VAR1 = '\' x:xaptk=\'XMP toolkit 2.8.2-33, framework 1.5\'>
>
> I am missing a couple of characters at the beginning.
I am just going by the example you provided, I don't have the actual data to
test it on.
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>