Subject: | make it pass warnings |
diff -urP Email-Simple-1.2/Simple.pm Email-Simple-new/Simple.pm
--- Email-Simple-1.2/Simple.pm 2003-04-03 16:24:33.000000000 +0100
+++ Email-Simple-new/Simple.pm 2003-04-04 15:09:35.000000000 +0100
@@ -7,8 +7,8 @@
use vars qw($VERSION $GROUCHY);
$VERSION = '1.2';
-my $crlf = qr/\xa\xd|\xd\xa|\xa|\xd/; # We are liberal in what we accept.
- # But then, so is a six dollar whore.
+my $crlf = qr/\x0a\x0d|\x0d\x0a|\x0a|\x0d/; # We are liberal in what we accept.
+ # But then, so is a six dollar whore.
$GROUCHY = 0;
@@ -73,8 +73,8 @@
# follows the header and is separated from the header by an empty
# line (i.e., a line with nothing preceding the CRLF).
# - RFC 2822, section 2.1
- if ($text =~ /(.*?)^$crlf(.*)/sm) {
- return ($1, $2);
+ if ($text =~ /(.*?($crlf))\2(.*)/sm) {
+ return ($1, $3);
} else { # The body is, of course, optional.
return ($text, "");
}
@@ -213,9 +213,10 @@
sub _header_as_string {
my ($field, $data) = @_;
+ my @stuff = @$data;
return join "", map { $_ = "$field: $_\n";
length > 78 ? _fold($_) : $_ }
- @$data;
+ @stuff;
}
my $wrapper;
diff -urP Email-Simple-1.2/t/1.t Email-Simple-new/t/1.t
--- Email-Simple-1.2/t/1.t 2003-03-17 15:34:57.000000000 +0000
+++ Email-Simple-new/t/1.t 2003-04-04 15:13:08.000000000 +0100
@@ -1,4 +1,6 @@
-#!/usr/bin/perl
+#!perl -w
+
+use strict;
use Test::More tests => 9;
@@ -11,7 +13,7 @@
like($mail->{head}->{From}->[0], qr/Andrew/, "Andrew's in the header");
-is($old_from = $mail->header("From"),
+is(my $old_from = $mail->header("From"),
'Andrew Josey <ajosey@rdg.opengroup.org>',
"We can get a header");
my $sc = 'Simon Cozens <simon@cpan.org>';
@@ -21,7 +23,7 @@
# Put andrew back:
$mail->header_set("From", $old_from);
-like($body = $mail->body, qr/Austin Group Chair/, "Body has sane stuff in it");
+like(my $body = $mail->body, qr/Austin Group Chair/, "Body has sane stuff in it");
my $old_body;
my $hi = "Hi there!\n";
diff -urP Email-Simple-1.2/t/2.t Email-Simple-new/t/2.t
--- Email-Simple-1.2/t/2.t 2003-04-03 16:24:22.000000000 +0100
+++ Email-Simple-new/t/2.t 2003-04-04 15:13:40.000000000 +0100
@@ -1,4 +1,7 @@
-use Test::More no_plan;
+#!perl -w
+
+use strict;
+use Test::More qw/no_plan/;
# This time, with folding!
diff -urP Email-Simple-1.2/t/unit.t Email-Simple-new/t/unit.t
--- Email-Simple-1.2/t/unit.t 2003-03-17 15:34:57.000000000 +0000
+++ Email-Simple-new/t/unit.t 2003-04-04 15:15:41.000000000 +0100
@@ -1,6 +1,8 @@
-#!/usr/bin/perl
+#!perl -w
+
# This is a series of unit tests to ensure that things do what I think
# they do.
+use strict;
use Email::Simple;
package Email::Simple;
@@ -15,21 +17,24 @@
# Simple "email", properly formed
-my $text = "a\n\nb\n";
-my ($h, $b) = _split_head_from_body($text);
+$text = "a\n\nb\n";
+($h, $b) = ();
+($h, $b) = _split_head_from_body($text);
is($h, "a\n", "Simple mail, head OK");
is($b, "b\n", "Simple mail, body OK");
# Simple "email" with blank lines
-my $text = "a\n\nb\nc\n";
-my ($h, $b) = _split_head_from_body($text);
+$text = "a\n\nb\nc\n";
+($h, $b) = ();
+($h, $b) = _split_head_from_body($text);
is($h, "a\n", "Simple mail, head OK");
is($b, "b\nc\n", "Simple mail, body OK");
# Blank line as first line in email
-my $text = "a\n\n\nb\nc\n";
-my ($h, $b) = _split_head_from_body($text);
+$text = "a\n\n\nb\nc\n";
+($h, $b) = ();
+($h, $b) = _split_head_from_body($text);
is($h, "a\n", "Simple mail, head OK");
is($b, "\nb\nc\n", "Simple mail, body OK");
@@ -41,12 +46,15 @@
is_deeply($ord, ["From"], "Order is correct" );
$head = "From: foo\nBar: baz\n";
-my ($hh, $ord) = _read_headers($head);
+
+($hh, $ord) = ();
+($hh, $ord) = _read_headers($head);
is($hh->{From}->[0], "foo", "Header 2.1");
is($hh->{Bar}->[0], "baz", "Header 2.2");
is_deeply($ord, ["From", "Bar"], "Order is correct" );
# Folding!
$head = "From: foo\n baz\n";
-my ($hh, $ord) = _read_headers($head);
+($hh, $ord) = ();
+($hh, $ord) = _read_headers($head);
is($hh->{From}->[0], "foo baz", "Header 3.1");
is_deeply($ord, ["From"], "Order is correct" );