On 02/10/2013 20:44, Peter Holsberg wrote:
Shawn H Corey has written on 10/2/2013 2:29 PM:

my @files = grep { /^\d{6}\.htm$/i } glob( '*.htm' );

Well, I'm more of a beginner than I thought I was!

The /i to grep is to ignore case?

Why are you globbing *.htm?

Hi Peter

All that Shawn has shown you is how to get the list of files; although
not saying so seems very unhelpful to me.

Yes, the /i modifier on any regex makes it ignore the case of the text
it matches.

    glob( '*.htm' )

returns a list of the files in the files in the current directory that
end with `.htm`, while

    grep { /^\d{6}\.htm$/i }

filters that list to include only those that begin with six decimal digits.

When you say

The file's name is \d{6}.htm

do you mean that literal name, or do you want to include *.htm files
that start with six decimal digits? Jim Gibson has assumed the former,
while Shawn, the latter.

If you are modifying just a single file, then I would choose a text
editor to do the job, not Perl or any other language.

If you clarify your requirement then I will gladly help, but it would go
down much better if you showed the work you had done already.

Rob





--
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