For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > June 2007 > Re: nevermind









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: nevermind
Mathew Snyder

2007-06-23, 3:59 am

You'll notice in the section that creates the filehandle I have a statement that
says "next if $address =~ m/^#/gmx;". I had to escape the "#". Can anyone tell
me why that is? It isn't a special character for regexes that I've ever seen used.

Thanks,
Mathew
--
Keep up with me and what I'm up to: http://theillien.blogspot.com

Dr.Ruud

2007-06-23, 7:58 am

Mathew Snyder schreef:
> You'll notice in the section that creates the filehandle I have a
> statement that says "next if $address =~ m/^#/gmx;". I had to escape
> the "#". Can anyone tell me why that is? It isn't a special
> character for regexes that I've ever seen used.


Check out what the x-modifier means (read perlre).

--
Affijn, Ruud

"Gewoon is een tijger."
Mumia W.

2007-06-23, 7:58 am

On 06/23/2007 03:18 AM, Mathew Snyder wrote:
> You'll notice in the section that creates the filehandle I have a statement that
> says "next if $address =~ m/^#/gmx;". I had to escape the "#". Can anyone tell
> me why that is? It isn't a special character for regexes that I've ever seen used.
>
> Thanks,
> Mathew


Why did you change the subject to "nevermind"? The subject didn't change.

You used the /x modifier which allows for comments within regular
expressions. Remove /x, and the old regex will work as expected.

Read "perldoc perlre" too.

You also could have written it this way:

open AUTHFILE, "</home/customercare/authorized_users.txt"
or die "Can't open file: $!";
@email_list = grep !/^#/, <AUTHFILE>;
close AUTHFILE;



Mumia W.

2007-06-23, 7:58 am

On 06/23/2007 04:30 AM, Mumia W. wrote:
> [...]
> You also could have written it this way:
>
> open AUTHFILE, "</home/customercare/authorized_users.txt"
> or die "Can't open file: $!";
> @email_list = grep !/^#/, <AUTHFILE>;


chomp @email_list;

> close AUTHFILE;
>


:-)


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com