in reply to Re^2: How to extract the first elemnet from an integer type value ???
in thread How to extract the first elemnet from an integer type value ???

my $num = 100; my $digit = int ($num / ('1' . ('0' x int (length ($num) -1))));

DWIM is Perl's answer to Gödel
  • Comment on Re^3: How to extract the first elemnet from an integer type value ???
  • Download Code

Replies are listed 'Best First'.
Re^4: How to extract the first elemnet from an integer type value ???
by Not_a_Number (Prior) on Aug 31, 2006 at 10:08 UTC
    my $digit = chop ( my $mun = reverse $num );
      chop $num while $num > 9;

      DWIM is Perl's answer to Gödel
        chop $num until length $num == 1;
Re^4: How to extract the first elemnet from an integer type value ???
by Leviathan (Scribe) on Aug 31, 2006 at 10:11 UTC

    Okay :)

    my $num = 100; my $digit = int ($num / ('1' . ('0' x (@{[ $num =~ /(.)/g ]} - 1))));

    I don't know.. is this reverse golf?

    --
    Leviathan