#!/usr/bin/perl

use warnings;
use strict;

my ($x, $y);

$x = "57 s";

# the following statements fail:
$x =~ /^(\s*)(\d+)(\.)?(\d*)(\s*)(s|S)/;
$y = $1.$2.$3;
# FAILS with "Use of uninitialized value in concatenation (.) or string"
# because $3 is undefined

# whereas these statements pass:
$x =~ /^(\s*)(\d+)(\.?)(\d*)(\s*)(s|S)/;
$y = $1.$2.$3;
# PASSES, $3 is defined and equal to the null string

Could someone explain why the first case fails?

Regards,
Gavin Bowlby



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to