#!/usr/bin/perl -w use strict; use Test::More 'no_plan'; # Test input and target output my %strings = ( '' => '', '""' => '<"">', '""""' => '<"""">', '""&""&""&""&""' => '<"">&<"">&<"">&<"">&<"">', '""""""""""' => '<"""""""""">', '""""&""""' => '<"""">&<"""">', '"""&"""' => '<"""&""">', '"foo"&"bar"' => '<"foo">&<"bar">', ' "foo" & "bar" ' => ' <"foo"> & <"bar"> ', '" "' => '<" ">', '" "" "' => '<" "" ">', '" """&" """' => '<" """>&<" """>' , '" "" "' => '<" "" ">', '" "" "&" "" "' => '<" "" ">&<" "" ">', '" "" & "" "' => '<" "" & "" ">', '""&""""' => '<"">&<"""">', ' "" ' => ' <""> ', ' """" ' => ' <""""> ', ' ""&""&""&""&"" ' => ' <"">&<"">&<"">&<"">&<""> ', ' """""""""" ' => ' <""""""""""> ', 'test("foo","bar")' => 'test(<"foo">,<"bar">)', ); # Add your code here sub find_quote { my $str = $_[0]; # Broken example $str =~ s/(".*?")/<$1>/g; return $str; } # Run the tests while (my($input, $result) = each %strings) { is(find_quote($input), $result, "for string:\t" . "'$input'"); }