while (<>) {
# do something with $_ here
}
####
unshift(@ARGV, '-') unless @ARGV;
while ($ARGV = shift) {
open(ARGV, $ARGV);
while ($_ = readline()) {
# do something with $_
}
}
####
%hash = ();
{
my @keys = qw ( a, b, c);
my @values = 1..3;
for ( my $c = 0; $c <= $#keys; $c++ ) {
$hash { $keys [$c] } = $values [ $c ];
}
}
####
@hash { qw (a, b, c) } = 1..3;
####
{ # block for local
local $/ = ''; # paragraph mode
path( $dhcpcdfile )->edit_lines(
sub {
if( m/ # match this:
^\s* # zero or more whitespace chars at line begin
profile # followed by the word "profile"
\s+ # one or more whitespace
static_ # then "static_"
$ip_params{interface} # the value for key "interface" in %ip_params
\b # a word boundary
.* # zero or more following chars
\n # and a newline
/mx # in a multiline block
) {
# alter this section
s/ # match and substitute
^\s* # zero or more whitespace chars at line begin
static # word "static"
\s+ # one or more whitespace chars
(\w+) # a word (see perlre) captured in $1
= # equal sign
\K # but keep what was matched so far
.* # any following chars
/ # against
$ip_params{$1} # the value of key $1 (see above) in hash %ip_params
/gmx; # globally in a multiline block (for "x" see perlre)
} # endif
} # end of sub
);
} # end of "local $/" block