Skip to content

Instantly share code, notes, and snippets.

@paveljurca
Last active August 29, 2015 14:08
Show Gist options
  • Save paveljurca/5b58a48526fd98a9d733 to your computer and use it in GitHub Desktop.
Save paveljurca/5b58a48526fd98a9d733 to your computer and use it in GitHub Desktop.
$> echo "Zanzibar, zambeZi" | perl -le "@_= <STDIN> =~ m/z/g; print scalar(@_);"
$> echo "Zanzibar, zambeZi" | perl -le "print (scalar(split /z/, <STDIN>) - 1);"
--
#!/usr/bin/env perl
use strict;
use warnings;
use feature q{say};
my $z;
chomp(my $input = <STDIN>);
for (split /\s*/, $input) {$z++ if $_ eq 'z'}
say $z;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment