Hi Thanks for the solution. Problem resolved.
regards Sreedhar -----Original Message----- From: Zeus Odin [mailto:[EMAIL PROTECTED] Sent: 23 October 2004 13:20 To: Kalkunte-Venkatachala, Sreedhar; [EMAIL PROTECTED] Subject: RE: how the print the first 7 letter of file name Please reply to the group so that others may answer also. :-) Your solution will return only the first 7 characters of the filename. My solution solution returns all characters after the last slash (first you used \ now you are using /) and before the first _ (underscore). Just keep this in mind. You can break my solution up into three steps: 1) split the original filename on the directory separator into a list 2) take the last item in the list and split it on the underscore into another list 3) return the first item of the last list If that still didn't make sense, here's the code again: 1) (split /\\/, $FILENAME)[-1] Starting with the expression within the parentheses -- split /\\/, $FILENAME. This says split $FILENAME into a list. Every time you see a slash add to the list. 2) This turns "C:\Developer\view_local\local_nt\FDAFDSAFDSASDFA\ASDFDAFSASDF\NewProcess_da te_22-oct-2004.log" into a list containing the strings C: Developer view_local local_nt FDAFDSAFDSASDFA ASDFDAFSASDF NewProcess_date_22-oct-2004.log 3) Going back to the expression: (split /\\/, $FILENAME)[-1] The () reinforce that fact that the split is returning a list of items. [-1] says go to the last item. In this case that item is "NewProcess_date_22-oct-2004.log" 4) Which brings us to: (split /_/, (split /\\/, $FILENAME)[-1])[0] I just described what the inner split does, so we can simplify. That gives us: (split /_/, "NewProcess_date_22-oct-2004.log")[0] 5) This split does the same thing except now it is splitting on _. This turns "NewProcess_date_22-oct-2004.log" into: NewProcess date 22-oct-2004.log 6) The [0] says go to the first item in the list from 5). This happens to be "NewProcess". You're done! Please read: perldoc -f split perldoc -q "What is the difference between a list and an array?" Good luck, ZO -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Saturday, October 23, 2004 7:41 AM To: [EMAIL PROTECTED] Subject: RE: how the print the first 7 letter of file name Hi The problem resolved. I have confirmed my self ---------------------------------------- use File::Basename; $FILENAME="/Developer/view_local/local_nt/FDAFDSAFDSASDFA/ASDFDAFSASDF/NewPr ocess_date_22-oct-2004.log"; my $name = basename($FILENAME,'.log'); $name= substr($name, 0, 7); print $name ============================================= Thanks for info. by the way can you explain the meaning of this line my $file = (split /_/, (split /\\/, $FILENAME)[-1])[0]; I am not clear. Kindly Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>