sub adjusttype {
my ($record) = @_;
SWITCH: {
(
$y[0] =~ /Local/
or $y[0] =~ /Announc/
) && do { $record->{type} = 'Talk'; last SWITCH; };
( $y[0] =~ /and answers/ )
&& do { $record->{type} = 'Question and answers'; last SWITCH; };
( $y[0] )
&& do { # strip the type from the title (if exists)
$record->{title} =~ s/$y[0]//g;
$record->{type} = $y[0];
last SWITCH;
};
}
Rants and ravings of a semi-autistic developer who has a hard time remembering idiotic nonsense details. Why remember it, when you know where to find it.
Wednesday, November 16, 2011
Switch/case with regular expressions in Perl
Creating a switch/case in perl with regular expressions are the input, similar to bash' wildcarding.
Labels:
perl
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment