Hi Chris, Thanks for your detailed email and for your time. I think my second email crossed your email. The book I read on Perl did not mention anything about first and second half, and that didnt explain, me that we were replacing all upsto last / by nothing. I thought it is replacing with / itself.
anyway I will look into the tutorial, you have mentioned in your email, before asking basic questions like this. if you know, any additional good book/tutorial let me know. thanks once again, meena, --- Chris Devers <[EMAIL PROTECTED]> wrote: > On Sun, 19 Jun 2005, MEENA SELVAM wrote: > > > can anyone please explain? > > See `perldoc perlre`, or `man perlre`, or a book > like _Learning Perl_ or > _Mastering Regular Expressions_ for this kind of > thing. > > It's really an introductory question that any decent > introductory text > should be able to cover for you. > > But, that said... > > > In the following code snippet, what is the meaning > of > > the pattern match > > s/^.*\/// > > The s/// is the substitution operator. It takes > whatever is in the first > half and replaces it with whatever is in the second > half. > > In this case, the first half is the following > pattern: > > /^.*\// > > Or, stripped of the forward-slashes that delimit the > pattern: > > ^.*\/ > > This means to match... > > ^ the start of the textt > . a single character (basically, see references > above for details) > * zero or more of that which precedes > \ an escape character; nullifies the special > meaning of that which > comes immediately afterward > / a forward-slash > > Thus, it matches from the start of the string, > matching anything at all > (including nothing) from there to a '/' character. > Because the match is > being done greedily, if there are several '/' > characters, it will match > from the beginning up until the last foward-slash. > > The second half of the substitution is: > > // > > Or, stripped of the forward-slashes that delimit the > pattern: > > > > That is, nothing at all. > > Thus, whenever the pattern in the first half is > detected, it is deleted. > > Thus, since you're dealing with the program name > (from $0), this code > strips out the path information, leaving only the > name of the program > itself. Something like "/usr/local/bin/my_script.pl" > will be reduced to > simply "my_script.pl". > > > Beyond this though, you really ought to be looking > over some tutorials > such as _Learning Perl_. They can do a very good job > of answering all > kinds of questions like this. > > > > -- > Chris Devers > ____________________________________________________ Yahoo! Sports Rekindle the Rivalries. Sign up for Fantasy Football http://football.fantasysports.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>