[30273] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1516 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 7 16:10:23 2008

Date: Wed, 7 May 2008 13:09:20 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 7 May 2008     Volume: 11 Number: 1516

Today's topics:
        2 simple questions <amirovic@googlemail.com>
    Re: 2 simple questions <simon.chao@fmr.com>
    Re: 2 simple questions <amirovic@googlemail.com>
    Re: Identification of which line causing regex problem <jurgenex@hotmail.com>
    Re: Net::SMTP fails <smallpond@juno.com>
    Re: Net::SMTP fails hendedav@gmail.com
    Re: Net::SMTP fails hendedav@gmail.com
    Re: Net::SMTP fails <1usa@llenroc.ude.invalid>
    Re: Net::SMTP fails <1usa@llenroc.ude.invalid>
    Re: perl PNG image searching <mazzawi@gmail.com>
    Re: perl PNG image searching <mazzawi@gmail.com>
    Re: perl PNG image searching <1usa@llenroc.ude.invalid>
    Re: perl PNG image searching sheinrich@my-deja.com
    Re: perl PNG image searching <ben@morrow.me.uk>
    Re: Why doesn't Perl complain about this bareword? <1usa@llenroc.ude.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 7 May 2008 11:08:27 -0700 (PDT)
From: "amirovic@googlemail.com" <amirovic@googlemail.com>
Subject: 2 simple questions
Message-Id: <a4069f6b-9eba-405f-af35-5e3629d7436a@f36g2000hsa.googlegroups.com>

Hi,

I got two simple question where I don't know the answer and would
appreciate any help.

1) my $sting = "afdsf,sdgj,sdgjkgd,"
How can I find out how many commas are in this string. I think that
there should be a very simple perl solution to this without find it
out in a very wild way.

2) my $no = 0.00001;
print $no; // Output 1e-05
How can get 0.00001 and not an e-number?

Thanks for your help.
Regards,
Amir


------------------------------

Date: Wed, 7 May 2008 11:25:01 -0700 (PDT)
From: nolo contendere <simon.chao@fmr.com>
Subject: Re: 2 simple questions
Message-Id: <b0ebded0-f8b9-4893-a488-f62e5b779e65@25g2000hsx.googlegroups.com>

On May 7, 2:08=A0pm, "amiro...@googlemail.com" <amiro...@googlemail.com>
wrote:
> Hi,
>
> I got two simple question where I don't know the answer and would
> appreciate any help.
>
> 1) my $sting =3D "afdsf,sdgj,sdgjkgd,"
> How can I find out how many commas are in this string. I think that
> there should be a very simple perl solution to this without find it
> out in a very wild way.

This is a FAQ:

$ perldoc -q count
     H7JEWENMJ3(1)       perl v5.8.3 (2008-05-07)        H7JEWENMJ3(1)

     Found in /usr/local/pkgs/perl-5.8.3/lib/5.8.3/pod/perlfaq4.pod
          How can I count the number of occurrences of a substring
          within a string?

          There are a number of ways, with varying efficiency.  If you
          want a count of a certain single character (X) within a
          string, you can use the "tr///" function like so:

              $string =3D "ThisXlineXhasXsomeXx'sXinXit";
              $count =3D ($string =3D~ tr/X//);
              print "There are $count X characters in the string";

so for you, that would be:

$ perl -e 'my $string =3D "afdsf,sdgj,sdgjkgd,"; $count =3D ($string =3D~
tr/,//); print "$count commas\n"'
$ 3 commas


>
> 2) my $no =3D 0.00001;
> print $no; // Output 1e-05
> How can get 0.00001 and not an e-number?
>

try printf:

perl -e 'my $num =3D 0.00001; printf "%f", $num'


------------------------------

Date: Wed, 7 May 2008 12:21:45 -0700 (PDT)
From: "amirovic@googlemail.com" <amirovic@googlemail.com>
Subject: Re: 2 simple questions
Message-Id: <3e5e440b-43e5-4506-be30-f7891371fe8c@q27g2000prf.googlegroups.com>

Hi,

Thank you very much for your great and fast response. For the second
question I needed to save the number without the 'e' in a further
variable which later was converted to a sting. But after your hint I
used sprintf which was made for this purpose.

Thanks again and regards,
Amir


------------------------------

Date: Wed, 07 May 2008 15:24:38 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Identification of which line causing regex problem
Message-Id: <vdh324dpuo0gvlqtq2l36hpubgku60kqqt@4ax.com>

"Ela" <ela@yantai.org> wrote:
>I'm modifying a system (totally more than 100000-lines for tens of files) 
>written by others and would like to identify which line leads to the 
>following problem.
>
>Invalid [] range "l-c" in regex; marked by <-- HERE in m/^3-oxoacyl-[acyl-c 
><-- HERE arrier protein] reductase fabg1$/

Well, the character set 
	[acyl-carrier protein]
does contain the range 'l-c' which is empty. Obviously that is what perl
is complaining about. Solution: just escape the dash with a leading
backslash. 
However, I doubt that will produce the effect you are looking for. Are
you really, really sure you want that character set there? To me it
looks much more like you want a literal match of the text 'acyl-carrier
protein'.

>Unfortunately the error message does not tell me which line of which file 
>leads to the problem. 

First I didn't believe you but a quick test confirms that you are right.
The perl interpreter does not print a file/line information (tried it on
5.6.1). Wierd!

>Could anybody advise?

Just grep your files for the offending m/// instruction. Something
similar to 	
	grep "acyl-carrier protein" *.pl

jue






------------------------------

Date: Wed, 07 May 2008 15:00:20 -0400
From: smallpond <smallpond@juno.com>
Subject: Re: Net::SMTP fails
Message-Id: <a5946$4821fc53$31890@news.teranews.com>

hendedav@gmail.com wrote:
> Gang,
> 
>      I am trying to use Net::SMTP to send email from a computer and it
> fails to send (debug info below).  I can take this same script and put
> it on another computer and it works just fine.  That would tell me
> some piece of software isn't installed on the non-working computer,
> but I have no idea as to what it may be.  I have made sure the files
> are the same on both computers that are listed in the "use" statements
> at the top of the Net::SMTP module.  I am using Debian 3.1 on the one
> that works and 4.0 on the one that doesn't work.  Any help would
> greatly be appreciated.
> 
> Thanks,
> 
> Dave
> 
> 
> 
> Net::SMTP>>> Net::SMTP(2.29)
> Net::SMTP>>>   Net::Cmd(2.26)
> Net::SMTP>>>     Exporter(5.58)
> Net::SMTP>>>   IO::Socket::INET(1.29)
> Net::SMTP>>>     IO::Socket(1.29)
> Net::SMTP>>>       IO::Handle(1.25)
> Net::SMTP=GLOB(0x82cd2dc)<<< 220 smtp106.biz.mail.re2.yahoo.com ESMTP
> Net::SMTP=GLOB(0x82cd2dc)>>> EHLO digital-pipe.com
> Net::SMTP=GLOB(0x82cd2dc)<<< 250-smtp106.biz.mail.re2.yahoo.com
> Net::SMTP=GLOB(0x82cd2dc)<<< 250-AUTH LOGIN PLAIN XYMCOOKIE
> Net::SMTP=GLOB(0x82cd2dc)<<< 250-PIPELINING
> Net::SMTP=GLOB(0x82cd2dc)<<< 250 8BITMIME


220 says that yahoo will accept mail using ESMTP, so you sent EHLO.
250 says OK, here's what I accept.
There's no error shown here, the next thing that you should do is
send MAIL FROM:, which you didn't.
--S


** Posted from http://www.teranews.com **


------------------------------

Date: Wed, 7 May 2008 12:31:33 -0700 (PDT)
From: hendedav@gmail.com
Subject: Re: Net::SMTP fails
Message-Id: <cd99f1aa-feba-48fd-aba0-f29c46f40147@b9g2000prh.googlegroups.com>

On May 7, 3:00 pm, smallpond <smallp...@juno.com> wrote:
> hende...@gmail.com wrote:
> > Gang,
>
> >      I am trying to use Net::SMTP to send email from a computer and it
> > fails to send (debug info below).  I can take this same script and put
> > it on another computer and it works just fine.  That would tell me
> > some piece of software isn't installed on the non-working computer,
> > but I have no idea as to what it may be.  I have made sure the files
> > are the same on both computers that are listed in the "use" statements
> > at the top of the Net::SMTP module.  I am using Debian 3.1 on the one
> > that works and 4.0 on the one that doesn't work.  Any help would
> > greatly be appreciated.
>
> > Thanks,
>
> > Dave
>
> > Net::SMTP>>> Net::SMTP(2.29)
> > Net::SMTP>>>   Net::Cmd(2.26)
> > Net::SMTP>>>     Exporter(5.58)
> > Net::SMTP>>>   IO::Socket::INET(1.29)
> > Net::SMTP>>>     IO::Socket(1.29)
> > Net::SMTP>>>       IO::Handle(1.25)
> > Net::SMTP=GLOB(0x82cd2dc)<<< 220 smtp106.biz.mail.re2.yahoo.com ESMTP
> > Net::SMTP=GLOB(0x82cd2dc)>>> EHLO digital-pipe.com
> > Net::SMTP=GLOB(0x82cd2dc)<<< 250-smtp106.biz.mail.re2.yahoo.com
> > Net::SMTP=GLOB(0x82cd2dc)<<< 250-AUTH LOGIN PLAIN XYMCOOKIE
> > Net::SMTP=GLOB(0x82cd2dc)<<< 250-PIPELINING
> > Net::SMTP=GLOB(0x82cd2dc)<<< 250 8BITMIME
>
> 220 says that yahoo will accept mail using ESMTP, so you sent EHLO.
> 250 says OK, here's what I accept.
> There's no error shown here, the next thing that you should do is
> send MAIL FROM:, which you didn't.
> --S
>
> ** Posted fromhttp://www.teranews.com**

Thanks for the reply.  Why would this script work just fine on one
computer and then stop at the above point on the other?

Dave


------------------------------

Date: Wed, 7 May 2008 12:42:31 -0700 (PDT)
From: hendedav@gmail.com
Subject: Re: Net::SMTP fails
Message-Id: <349ecbfd-844d-440b-a4f1-2f30fc66ae49@l28g2000prd.googlegroups.com>

On May 7, 3:31 pm, hende...@gmail.com wrote:
> On May 7, 3:00 pm, smallpond <smallp...@juno.com> wrote:
>
>
>
> > hende...@gmail.com wrote:
> > > Gang,
>
> > >      I am trying to use Net::SMTP to send email from a computer and it
> > > fails to send (debug info below).  I can take this same script and put
> > > it on another computer and it works just fine.  That would tell me
> > > some piece of software isn't installed on the non-working computer,
> > > but I have no idea as to what it may be.  I have made sure the files
> > > are the same on both computers that are listed in the "use" statements
> > > at the top of the Net::SMTP module.  I am using Debian 3.1 on the one
> > > that works and 4.0 on the one that doesn't work.  Any help would
> > > greatly be appreciated.
>
> > > Thanks,
>
> > > Dave
>
> > > Net::SMTP>>> Net::SMTP(2.29)
> > > Net::SMTP>>>   Net::Cmd(2.26)
> > > Net::SMTP>>>     Exporter(5.58)
> > > Net::SMTP>>>   IO::Socket::INET(1.29)
> > > Net::SMTP>>>     IO::Socket(1.29)
> > > Net::SMTP>>>       IO::Handle(1.25)
> > > Net::SMTP=GLOB(0x82cd2dc)<<< 220 smtp106.biz.mail.re2.yahoo.com ESMTP
> > > Net::SMTP=GLOB(0x82cd2dc)>>> EHLO digital-pipe.com
> > > Net::SMTP=GLOB(0x82cd2dc)<<< 250-smtp106.biz.mail.re2.yahoo.com
> > > Net::SMTP=GLOB(0x82cd2dc)<<< 250-AUTH LOGIN PLAIN XYMCOOKIE
> > > Net::SMTP=GLOB(0x82cd2dc)<<< 250-PIPELINING
> > > Net::SMTP=GLOB(0x82cd2dc)<<< 250 8BITMIME
>
> > 220 says that yahoo will accept mail using ESMTP, so you sent EHLO.
> > 250 says OK, here's what I accept.
> > There's no error shown here, the next thing that you should do is
> > send MAIL FROM:, which you didn't.
> > --S
>
> > ** Posted fromhttp://www.teranews.com**
>
> Thanks for the reply.  Why would this script work just fine on one
> computer and then stop at the above point on the other?
>
> Dave

I removed the authentication checking and just had the rest of the
script processed and here is the response I received:

Net::SMTP>>> Net::SMTP(2.29)
Net::SMTP>>>   Net::Cmd(2.26)
Net::SMTP>>>     Exporter(5.58)
Net::SMTP>>>   IO::Socket::INET(1.29)
Net::SMTP>>>     IO::Socket(1.29)
Net::SMTP>>>       IO::Handle(1.25)
Net::SMTP=GLOB(0x82ccfac)<<< 220 smtp107.biz.mail.re2.yahoo.com ESMTP
Net::SMTP=GLOB(0x82ccfac)>>> EHLO digital-pipe.com
Net::SMTP=GLOB(0x82ccfac)<<< 250-smtp107.biz.mail.re2.yahoo.com
Net::SMTP=GLOB(0x82ccfac)<<< 250-AUTH LOGIN PLAIN XYMCOOKIE
Net::SMTP=GLOB(0x82ccfac)<<< 250-PIPELINING
Net::SMTP=GLOB(0x82ccfac)<<< 250 8BITMIME
Net::SMTP=GLOB(0x82ccfac)>>> MAIL FROM:<noreply@netbud.local>
Net::SMTP=GLOB(0x82ccfac)<<< 530 authentication required - for help go
to http://help.yahoo.com/help/us/bizmail/pop/pop-11.html
Net::SMTP=GLOB(0x82ccfac)>>> RCPT TO:<d...@digital-pipe.com>
Net::SMTP: Unexpected EOF on command channel at /usr/lib/perl/5.8/
libemail.pm line 66


The only reason there is an error in the script at line 66 is because
all the lines were processed even though the auth failed (which the
script normally wouldn't come to if the auth section that I commented
out, failed).

Dave


------------------------------

Date: Wed, 07 May 2008 19:54:47 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Net::SMTP fails
Message-Id: <Xns9A97A1DF16A58asu1cornelledu@127.0.0.1>

hendedav@gmail.com wrote in news:cd99f1aa-feba-48fd-aba0-f29c46f40147@b9g2000prh.googlegroups.com:

>> > Net::SMTP>>> Net::SMTP(2.29)
>> > Net::SMTP>>>   Net::Cmd(2.26)
>> > Net::SMTP>>>     Exporter(5.58)
>> > Net::SMTP>>>   IO::Socket::INET(1.29)
>> > Net::SMTP>>>     IO::Socket(1.29)
>> > Net::SMTP>>>       IO::Handle(1.25)
>> > Net::SMTP=GLOB(0x82cd2dc)<<< 220 smtp106.biz.mail.re2.yahoo.com ESMTP
>> > Net::SMTP=GLOB(0x82cd2dc)>>> EHLO digital-pipe.com
>> > Net::SMTP=GLOB(0x82cd2dc)<<< 250-smtp106.biz.mail.re2.yahoo.com
>> > Net::SMTP=GLOB(0x82cd2dc)<<< 250-AUTH LOGIN PLAIN XYMCOOKIE
>> > Net::SMTP=GLOB(0x82cd2dc)<<< 250-PIPELINING
>> > Net::SMTP=GLOB(0x82cd2dc)<<< 250 8BITMIME
 ...

> Thanks for the reply.  Why would this script work just fine on one
> computer and then stop at the above point on the other?

What script are you talking about? I haven't seen any code in the
messages you have posted so far.

Sinan
-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


------------------------------

Date: Wed, 07 May 2008 19:56:05 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Net::SMTP fails
Message-Id: <Xns9A97A21727E0Basu1cornelledu@127.0.0.1>

hendedav@gmail.com wrote in
news:349ecbfd-844d-440b-a4f1-2f30fc66ae49@l28g2000prd.googlegroups.com: 

[ Posted no code, just error logs ... ]

> The only reason there is an error in the script at line 66 is because
> all the lines were processed even though the auth failed (which the
> script normally wouldn't come to if the auth section that I commented
> out, failed).

So what? 

Maybe it was line 666 and that's why it failed.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


------------------------------

Date: Wed, 7 May 2008 11:46:24 -0700 (PDT)
From: elie <mazzawi@gmail.com>
Subject: Re: perl PNG image searching
Message-Id: <91f0c1cb-f644-44d2-a724-628db6766b9b@b64g2000hsa.googlegroups.com>


I've been playing around with perlMagick (which is a perl interface to
Image-Magic), I think it can decompress the PNG into some binary, but
its way too complex, I get some binary, but I can't tell what it is,
the number of bytes doesn't match the number of pixels, and is not a
multiple. I've been using the perlmagik function getPixels() but I
don't know what the binary its returning is yet.

I'm going to try to match part of the binary from the sub image in the
big image, but its still not making sence.



On May 7, 10:41 am, "Ben Bullock" <benkasminbull...@gmail.com> wrote:
> "zentara" <zent...@highstream.net> wrote in message
>
> news:blb324t9ilinko2ct7qf3f6qpc87mruet6@4ax.com...
>
> > This is just a brainstorm, :-)
> > but you might be able to do some sort
> > of binary regex search of the larger images. You would have to strip
> > off the png header of the smaller image.
>
> As far as I know, PNG is a compressed format, so it's not possible to access
> the actual pixel data just by "stripping off the png header".



------------------------------

Date: Wed, 7 May 2008 11:47:46 -0700 (PDT)
From: elie <mazzawi@gmail.com>
Subject: Re: perl PNG image searching
Message-Id: <85000587-bac7-4060-a29c-029140cf1cd3@e39g2000hsf.googlegroups.com>

thanks ben,
I think perlMagik is the right library to use, I'm going to find an
imageMagic newsgroup to ask around in, I'll post my findings later.


------------------------------

Date: Wed, 07 May 2008 19:36:41 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: perl PNG image searching
Message-Id: <Xns9A979ECD32E13asu1cornelledu@127.0.0.1>

elie <mazzawi@gmail.com> wrote in
news:91f0c1cb-f644-44d2-a724-628db6766b9b@b64g2000hsa.googlegroups.com: 

[ Don't top post here ]

> I've been playing around with perlMagick (which is a perl interface to
> Image-Magic), I think it can decompress the PNG into some binary, but
> its way too complex, I get some binary, but I can't tell what it is,
> the number of bytes doesn't match the number of pixels, and is not a
> multiple. I've been using the perlmagik function getPixels() but I
> don't know what the binary its returning is yet.
> 
> I'm going to try to match part of the binary from the sub image in the
> big image, but its still not making sence.

I don't know what size images you are playing with, how much CPU 
and RAM are available. However, the naive implementation of this 
functionality is really not that hard.

Below, for convenience, I used the GD library. The code looks for 
a 32x32 pattern in a 2816x2112 photo with the pattern pasted in to 
roughly the center of the larger image.

perl takes about 4Mb memory when the program below is running. 
First, the results:

E:\img> timethis fi

TimeThis :  Command Line :  fi
TimeThis :    Start Time :  Wed May 07 15:29:14 2008

Possible match at 1393 1041
Matched line: 0
Matched line: 1
Matched line: 2
Matched line: 3
Matched line: 4
Matched line: 5
Matched line: 6
Matched line: 7
Matched line: 8
Matched line: 9
Matched line: 10
Matched line: 11
Matched line: 12
Matched line: 13
Matched line: 14
Matched line: 15
Matched line: 16
Matched line: 17
Matched line: 18
Matched line: 19
Matched line: 20
Matched line: 21
Matched line: 22
Matched line: 23
Matched line: 24
Matched line: 25
Matched line: 26
Matched line: 27
Matched line: 28
Matched line: 29
Matched line: 30
Matched line: 31
Definite match at 1393 1041 ( 32 x 32 )

TimeThis :  Command Line :  fi
TimeThis :    Start Time :  Wed May 07 15:29:14 2008
TimeThis :      End Time :  Wed May 07 15:29:29 2008
TimeThis :  Elapsed Time :  00:00:15.015

That took 15 seconds to find the 32x32 pattern in the larger 
image. That is probably not fast enough, but it is a starting 
point.

Of course, it might be easier just to convert both images to 
binary or ASCII encoded PPM and do the matching from there 
(in that case, the regex approach is almost trivial) and I 
would guess would be faster than dealing with the repeated 
rgb and getPixel calls.

#!/usr/bin/perl

use strict;
use warnings;

use GD;
GD::Image->trueColor(1);

use constant FIND_MULTIPLE => 0;

my ($source, $pattern) = qw( source.png pattern.png );

my $sgd = GD::Image->new( $source );
my $pgd = GD::Image->new( $pattern );

my ( $start_x, $start_y ) = (0, 0);

COORD:
while ( my @coord = find_first_match( $sgd, $pgd, $start_x, $start_y ) ) {
    warn "Possible match at @coord\n";

    my ( $pw, $ph ) = $pgd->getBounds;

    SCAN:
    for ( my $py = 0; $py < $ph; $py += 1 ) {
        if ( match_hscanline($sgd, $pgd, @coord, $py) ) {
            warn "Matched line: $py\n";
        }
        else {
            warn "Failed to match line: $py\n";
            $start_x = $coord[0] + 1;
            $start_y = $coord[1];
            next COORD;
        }
    }

    warn "Definite match at @coord ( $pw x $ph )\n";
    last unless FIND_MULTIPLE;

    $start_x = $coord[0] + $pw;
    $start_y = $coord[1];
}

sub find_first_match {
    my ( $sgd, $pgd, $start_x, $start_y ) = @_;

    my ( $sw, $sh ) = $sgd->getBounds;
    my ( $pw, $ph ) = $pgd->getBounds;

    my $lookfor = make_rgb( $pgd->rgb( $pgd->getPixel(0, 0) ) );

    for ( my $y = $start_y; $y < $sh - $ph; $y += 1 ) {
        for ( my $x = $start_x; $x < $sw - $pw; $x += 1 ) {
            if ( $lookfor == make_rgb(
                    $sgd->rgb( $sgd->getPixel( $x, $y ) ) ) ) {
                return my @r = ($x, $y);
            }
        }
    }
    return;
}

sub match_hscanline {
    my ( $sgd, $pgd, $sx, $sy, $py ) = @_;
    my ( $pw, $ph ) = $pgd->getBounds;

    for ( my $px = 0; $px < $pw; $px += 1 ) {
        return if make_rgb($pgd->rgb( $pgd->getPixel($px, $py)))
               != make_rgb($sgd->rgb( $sgd->getPixel($sx + $px, $sy + $py)));
    }

    return 1;
}

# memoizing this function does not speed things up
sub make_rgb {
    my ( $r, $g, $b ) = @_;
    return ( $r << 16 ) | ( $g << 8 ) | $b;
}


__END__



-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


------------------------------

Date: Wed, 7 May 2008 12:40:51 -0700 (PDT)
From: sheinrich@my-deja.com
Subject: Re: perl PNG image searching
Message-Id: <d251f959-90e4-4d12-81a1-f3e3fbbf5c6c@25g2000hsx.googlegroups.com>

On May 7, 8:46 pm, elie <mazz...@gmail.com> wrote:
> I've been playing around with perlMagick (which is a perl interface to
> Image-Magic), I think it can decompress the PNG into some binary, but
> its way too complex, I get some binary, but I can't tell what it is,
> the number of bytes doesn't match the number of pixels, and is not a
> multiple. I've been using the perlmagik function getPixels() but I
> don't know what the binary its returning is yet.
>
> I'm going to try to match part of the binary from the sub image in the
> big image, but its still not making sence.
>

By means of ImageMagick or any other library, I'd first turn both
images into some sort of bitmap format, preferably monochrome, and
reduce their sizes below the threshold of any pixel errors caused by
the transformation.
It should then be poossible to slide the smaller image over the bigger
one and apply some bitwise logic (XOR) to the corresponding pixels.

Cheers, Steffen


------------------------------

Date: Wed, 7 May 2008 20:36:28 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: perl PNG image searching
Message-Id: <suc9f5-8bi1.ln1@osiris.mauzo.dyndns.org>


Quoth "Ben Bullock" <benkasminbullock@gmail.com>:
> "zentara" <zentara@highstream.net> wrote in message 
> news:blb324t9ilinko2ct7qf3f6qpc87mruet6@4ax.com...
> 
> > This is just a brainstorm, :-)
> > but you might be able to do some sort
> > of binary regex search of the larger images. You would have to strip
> > off the png header of the smaller image.
> 
> As far as I know, PNG is a compressed format, so it's not possible to access 
> the actual pixel data just by "stripping off the png header". 

A good way around this is to run the PNG through pngtopnm |
pnmtoplainpnm. ASCII pnm format is very simple (that's the point).

Ben

-- 
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else ** ben@morrow.me.uk


------------------------------

Date: Wed, 07 May 2008 19:21:24 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Why doesn't Perl complain about this bareword?
Message-Id: <Xns9A979C35FF57Dasu1cornelledu@127.0.0.1>

sheinrich@my-deja.com wrote in news:41f43d75-d4cb-4633-95a9-
e5b76af6a97c@c58g2000hsc.googlegroups.com:

> On May 7, 1:45 pm, "A. Sinan Unur" <1...@llenroc.ude.invalid> wrote:
> 
> ...
>> Note the following cases:
>>
>> C:\t> perl -w -Mstrict -e "print Does,Not,Exist, qq{\n}"
>> No comma allowed after filehandle at -e line 1.
>>
>>     In this case, Does has a valid interpretation as a
>>     bareword filehandle. Thus, strict does not kick in.
>>
> But why is the first argument being taken here for a filehandle, in
> spite of the comma, and not considered as namespace, as in your other
> example?

Well, it is a bareword. The most natural use of a bareword found 
following print is to specify a filehandle in the current package.

The alternative to giving an error message would have been to print Does 
which is not what the programmer wanted in 99.9999% of cases of a 
bareword following a print followed by a comma.

> It seems like only Strings containing :: (or ' ) qualify as possible
> package names.

No. DoESnoTExiST is also a valid package name. However, only ' and :: 
can be used as separators in a package name.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 1516
***************************************


home help back first fref pref prev next nref lref last post