I want to display the Tax Description of different countries for my new website in Perl. Based on the respective countries from the API I use, I get all the Tax Description in Uppercase letters.
I do not want single words VAT or SGST in array. I want the words of only multiple tax description words in array. Instead it should directly show what’s in the $word
Following is the code:
sub maybe_ucfirst {
my ($word) = @_;
my %ignore = map { $_ => undef } qw(GST AZ);
return exists $ignore{$word} ? $word : ucfirst Lc $word;
}
my @inputs = ('AUSTRALIA GST', 'AZ COUNTY TAX', 'NEW ZEALAND GST', 'VAT');
for my $s (@inputs) {
$s =~ s/(w+)/maybe_ucfirst($1)/eg;
say $s;
}
Here are the inputs and outputs:
1: Input: ‘AUSTRALIA GST’
Output: ‘Australia GST’
2. Input: ‘AZ COUNTY TAX’
Output: ‘AZ County Tax’
3. Input: ‘NEW ZEALAND GST’
Output: ‘New Zealand GST’
4. Input: ‘VAT’
Output: ‘Vat’
5. Input: ‘SGST’
Output: ‘Sgst’
I want the output for single tax description words as:
1. Input: ‘SGST’
Output: ‘SGST’
2. Input: ‘VAT’
Output: ‘VAT’
Can anyone please help as to how to fix this in Perl?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…