split with regular expression
LIST = split REGEX, STRING;
examples/regex-perl/field_value_pairs.txt
fname = Foo lname = Bar email=foo@bar.com
examples/regex-perl/parse_field_value_pairs.pl
#!/usr/bin/perl use strict; use warnings; # data: field_value_pairs.txt my $filename = shift or die "Usage: $0 filename\n"; open(my $fh, "<", $filename) or die "Could not open '$filename'\n"; while (my $line = <$fh>) { chomp $line; my ($field, $value) = split /\s*=\s*/, $line; print "$value=$field\n"; }