Help for this page

Select Code to Download


  1. or download this
    my $x = 'abc12345';
    my ($y) = $x =~ /(\d+)$/;
    my $length = length($y);
    
  2. or download this
    my $x = 'abc12345';
    my $length = length ($x =~ /(\d+)$/);
    # returns 1, the length of the number in the number of elements
    
  3. or download this
    my $x = 'abc12345';
    my $length = map { length } ($x =~ /(\d+)$/);
    
  4. or download this
    my $x = 'abc12345';
    my $length = map { length } ($x =~ /(\d+)$/)[0];
    
  5. or download this
    my $x = 'abc12345';
    my $length = length (($x =~ /(\d+)$/)[0]);
    # returns 5