diff options
| author | E7-87-83 <fungcheokyin@gmail.com> | 2021-04-12 05:44:12 +0800 |
|---|---|---|
| committer | E7-87-83 <fungcheokyin@gmail.com> | 2021-04-12 05:44:12 +0800 |
| commit | 92b1db1ea2aa726d870c8975427cf74e430f5d05 (patch) | |
| tree | 6e95266d9c35b978cc762321f88c639f4f0a43b2 | |
| parent | 8348771ff1bf6d20736cdbb07a17f02c7da19ecc (diff) | |
| download | perlweeklychallenge-club-92b1db1ea2aa726d870c8975427cf74e430f5d05.tar.gz perlweeklychallenge-club-92b1db1ea2aa726d870c8975427cf74e430f5d05.tar.bz2 perlweeklychallenge-club-92b1db1ea2aa726d870c8975427cf74e430f5d05.zip | |
submission for week 107
| -rw-r--r-- | challenge-107/cheok-yin-fung/perl/ch-2.pl | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/challenge-107/cheok-yin-fung/perl/ch-2.pl b/challenge-107/cheok-yin-fung/perl/ch-2.pl index da92d07e33..188059fcf2 100644 --- a/challenge-107/cheok-yin-fung/perl/ch-2.pl +++ b/challenge-107/cheok-yin-fung/perl/ch-2.pl @@ -8,15 +8,19 @@ # --- # Usage: ch-2.pl [complete name of the script] + die "Please input Perl scripts you want to check.\n" if !defined($ARGV[0]); my $program = $ARGV[0]; open(SCRIPT, $program) or die "Fail to read $program\n"; -while (<SCRIPT>) { - if ( /sub(\s+)(\&|\w)(\w*)/ ) { - print $2.$3 . "\n"; +my %hash; + +while (my $line = <SCRIPT>) { + while ( $line =~ /sub(\s+)(\&|\w)(\w*)/g ) { + print $2.$3."\n"; } } +#ref: https://stackoverflow.com/questions/9156149/perl-match-one-pattern-multiple-times-in-the-same-line-delimited-by-unknown-cha |
