while( ) { print; if( m/^([a-z_]\w+)=(\d{1,9}|[a-z_]\w*)$/ ) { print "($1)($2)\n"; } my( $key, $value ); ( $key, $value )= m{ ^ ( [a-z_] # Key name must start with a letter or '_' \w # Subsequent characters can also be digits + # Key names must be at least 2 characters ) = ( # The value can be: \d # If it starts with a digit, it is an integer {1,9} # Only up to 9-digit values are allowed. | # or, the value can be: [a-z_] # An identifier must start with a letter or '_' \w # Subsequent characters can also be digits * # No length limit on IDs ) $ }x && do { print "# ($1)($2)\n"; print "# ($key)($value)\n"; }; ( $key, $value )= m{ ^ ( [a-z_] (?# Key name must start with a letter or '_') \w (?# Subsequent characters can also be digits) + (?# Key names must be at least 2 characters) ) = ( (?# The value can be:) \d (?# If it starts with a digit, it is an integer) {1,9} (?# Only up to 9-digit values are allowed.) | (?# or, the value can be:) [a-z_] (?# An identifier must start with a letter or '_') \w (?# Subsequent characters can also be digits) * (?# No length limit on IDs) ) $ }x && do { print "(?# ($1)($2) )\n"; print "(?# ($key)($value) )\n"; }; print $/; } __END__ this=that one=12