Like this
#!/usr/bin/perl -- use strict; use warnings; use Test::More qw' no_plan '; Main( @ARGV ); exit( 0 ); sub Main { Happy(\&pichi_nakodadaka, 'pichi_nakodadaka' ); Happy(\&pichi_nakodadaka2, 'pichi_nakodadaka2' ); } sub Happy { my( $ref, $name ) = @_; my @arg = ( [ '#include "string.h"', 'string.h' ], [ '#include <stdlib.h>', 'stdlib.h' ], [ '#include <sys/dispatch.h>', 'dispatch.h' ], ); for my $arg( @arg ){ my( $in, $expect ) = @$arg; my $got = $ref->($in); is($got, $expect , $name); } } sub pichi_nakodadaka { my( $in ) = @_; return $1 if $in =~ /#include [<"](\S+\.h)[>"]/ ; } sub pichi_nakodadaka2 { my( $in ) = @_; if( $in =~ /#include [<"](\S+\.h)[>"]/ ){ my $pichi_nakodadaka = $1; $pichi_nakodadaka =~ s!^.*?/!!g; return $pichi_nakodadaka; } } __END__ $ perl pm.894302.pl ok 1 - pichi_nakodadaka ok 2 - pichi_nakodadaka not ok 3 - pichi_nakodadaka # Failed test 'pichi_nakodadaka' # at pm.894302.pl line 33. # got: 'sys/dispatch.h' # expected: 'dispatch.h' ok 4 - pichi_nakodadaka2 ok 5 - pichi_nakodadaka2 ok 6 - pichi_nakodadaka2 1..6 # Looks like you failed 1 test of 6.

In reply to Re^2: Printing just the file name for all the cases by Anonymous Monk
in thread Printing just the file name for all the cases by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.