Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Regex (find an * after a digit)

by The Mad Hatter (Priest)
on Feb 06, 2004 at 02:56 UTC ( #326972=note: print w/replies, xml ) Need Help??

in reply to Regex (find an * after a digit)

Though I know little in the way of Unicode, it seems to me that somewhere Perl thinks something in your regex is trying to specify a UTF-8 character when you aren't; are you using UTF-8 other places in the script? What version of perl are you using?

Just as a side note, {1,} can be written more succintly as +, like thus: /\d+\*/

Replies are listed 'Best First'.
Re: Re: Regex (find an * after a digit)
by Anonymous Monk on Feb 06, 2004 at 03:08 UTC
    It thinks so, but I'm not using Unicode anywhere. Here's the whole script.
    #!/usr/bin/perl # # use strict; use warnings; my $file = "input.txt"; open ( FILE, $file ) || die "Can't open $file $!"; while ( <FILE> ) { chomp; if ( $_ = /\d+\*/ ) { print "$_\n"; } }
    As for the \d{1,} -- I was actually going to put an upper limit on it at one point, so just wrote it that way. For now the + will do though.

    Update - I tried on another machine, and it works, so it's definitely machine related. Both machines are running Perl v5.8.0 Cheers
      Do you get the same error if you use =~ instead of = ?
      From perl581delta:
      =head2 UTF-8 On Filehandles No Longer Activated By Locale In Perl 5.8.0 all filehandles, including the standard filehandles, were implicitly set to be in Unicode UTF-8 if the locale settings indicated the use of UTF-8. This feature caused too many problems, so the feature was turned off and redesigned: see L</"Core Enhancement +s">.
      Consider upgrading, or switch to a non-UTF8 locale, or binmode FILE.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://326972]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2018-02-21 00:31 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (274 votes). Check out past polls.