On Mon, 23 Nov 2009 23:14:51 +1000, Shawn H Corey <shawnhco...@gmail.com> wrote:

shadow52 wrote:

[snip]

The number is 0000000000000111

I was just wanting to get the last 3 digits from this number to be
able to get an exact word phrase from my already loaded Hash table
that I have created for various numbers that I will get the last 3
numbers from. Oh yeah all I was doing was putting this number in a
file and then passing it to perl on the command line incase that is
needed.

[snip]

my $n = "0000000000000111";
my ( $last_3_digits ) = $n =~ m{ (\d\d\d) \z }msx;
print "$last_3_digits\n";

Hi Shawn et al.,

I am also intrigued by the \z anchor. I had a look at perldoc perlreref and found

\z  Match absolute string end

My question is what is the difference between \z and $? And when should I use \z rather than $ ? From the same documentation:

$   Matches at the end of the string (or line, if /m is used)

Cheers,

Dave


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to