in reply to Style and warnings

my ($num)= $seqnum=~/^(\d+)/; my $bigseqnum = $num + 10000000 ...

This naturally only works if the number in $seqnum always conforms to that regex (for example no negative number) and there are no spaces etc. before the number. Otherwise the regex has to be adapted to work in all those cases

The other possibility is to turn of warnings at that point:

no warnings; my $bigseqnum = int($seqnum) + 10000000 ... use warnings;

Replies are listed 'Best First'.
Re^2: Style and warnings
by Tanktalus (Canon) on Aug 18, 2009 at 15:29 UTC
    I generally prefer do blocks for making it really, really obvious that I'm doing silly things, and what the scope of that silliness actually is:
    my $bigseqnum = do { no warnings; int($seqnum) + 10000000 };
    Or, to be more explicit, no warnings 'numeric';
Re^2: Style and warnings
by JavaFan (Canon) on Aug 18, 2009 at 15:35 UTC
    You know that this still may give the warning?

    An example where you still can get the warning: "๑๒๓" ("123" in Thai digits). \d is such a poor substitute for [0-9].

      Ah, the pitfalls of UTF. Did not know that and don't like it at all, I used \d as shorthand for 0-9 a lot. My old camel book still says "\d - A digit, same as [0-9]"

      I think I would have prefered a new character for this class to a break of backwards compatibility. The other solution that the internal number conversion also recognizes thai and other numbers would be even better theoretically, but that may not be easy with UTF

Re^2: Style and warnings
by rovf (Priest) on Aug 19, 2009 at 07:53 UTC
    my ($num)= $seqnum=~/^(\d+)/;
    This would extract the first string of digits inside the string $seqnum. I'm not sure whether this is what the OP wanted. Giving the call to the write-function in the posting, I rather think the OP would like to catch those cases where the string does not evaluate to an integral number. I think one portable solution would be

    use Scalar::Util qw(looks_like_number); if(looks_like_number($seqnum) && int($seqnum)==$seqnum) { # $seqnum is arithmetically an integral number }

    -- 
    Ronald Fischer <ynnor@mm.st>