MIME::Head a vstup z retezce

Honza Pazdziora adelton na informatics.muni.cz
Čtvrtek Srpen 12 18:40:34 MEST 1999


Jan Kasprzak se ve ctvrtek po seste odpoledne nadechl a jednim
bufferem ze sebe vysypal:

> 	potreboval bych pouzit MIME::Head, ale tu hlavicku nemam v souboru,
> ani v deskriptoru, ale v retezci. Podle dokumentace MIME::Head je mozno
> tento objekt konstruovat takto:
> 
>     # Parse a new header from a filehandle:
>     $head = MIME::Head->read(\*STDIN);
>     
>     # Parse a new header from a file, or a readable pipe:
>     $testhead = MIME::Head->from_file("/tmp/test.hdr");
>     $a_b_head = MIME::Head->from_file("cat a.hdr b.hdr |");
> 
> 	Lze nejak (pomoci IO::Scalar?) vytvorit MIME::Head bez
> docasneho souboru?

Tohle mi prijde jako kanon na vrabce. Normalne by melo fungovat
(a taky funguje)

	use Data::Dumper;
	use MIME::Head;
	$head = MIME::Head->new;
	$head->header(['Content-Type: jezek', 'URI: jezek']);
	print Dumper $head;
	__END__

a umi to ty radky i slozit

	use Data::Dumper;
	use MIME::Head;
	$head = MIME::Head->new;
	$head->header(['Content-Type: jezek', "\tURI: jezek"]);
	print Dumper $head;
	__END__

cili je mozno udelat

	use MIME::Head;
	$head = MIME::Head->new([ split /\n/, $ten_string ]);

Enjoy,

------------------------------------------------------------------------
 Honza Pazdziora | adelton na fi.muni.cz | http://www.fi.muni.cz/~adelton/
 make vmlinux.exe			-- SGI Visual Workstation Howto
Any spam sent to my email will be rewarded by complaint to your ISP abuse
  team and abuse teams of servers that relayed that message. It works.


Další informace o konferenci Perl