I don't know if the webmail use POP3 orIMAP .I feel POP3
Just to clarify: the term "webmail" is typically used when mail is
being accessed via the HTTP(S) protocol, in combination with some
special web frontend software that "runs in the browser"...
As to the attachments: mail messages with attachments usually come
in so-called "multipart MIME" format. Once you have fetched the
message from the mail server (e.g. via POP3), you'll have to decompose
it into its individual components. There are several CPAN modules for
handling MIME stuff, for example the MIME-tools package, which
also includes examples. (but this isn't the only one...)