#!/usr/bin/env perl use warnings; use strict; check_int('55'); check_int(0xff); check_int(123); check_int('#123'); check_int('$123'); sub check_int { my $num = shift; if ($num =~ /\D/) { print "Not an integer: $num\n"; } else { print "An integer: $num\n"; } }
prints out:
An integer: 55 An integer: 255 An integer: 123 Not an integer: #123 Not an integer: $123
Can you show some examples of integers with $ and #, along with some code that you've tried?
In reply to Re: perl typecasting
by toolic
in thread perl typecasting
by perl_junkie
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |