Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

split with regular expression

LIST = split REGEX, STRING;
fname    =    Foo
lname    = Bar
email=foo@bar.com
#!/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";
}