suniln has asked for the wisdom of the Perl Monks concerning the following question:

Hi All, I I have following piece of code to fetch intermediate and last node of a string. some of input lines are as follows.
C:\abc\dfg C:\abc\dfg\#@$#@$@ $key="C:\abc\dfg"; if( $line =~ /$key\\\S+\\/){ # if this is not end node ($pat)=$line=~/$key\\(\S+)\\/; }else{ # if end node ($last_node)=$line=~/$key\\(.*)/; }
What is wrong in this reg exp... Thanks, Sunil
  • Comment on unable chec whether the word is intermediate or last word in a sentence
  • Download Code

Replies are listed 'Best First'.
Re: unable chec whether the word is intermediate or last word in a sentence
by ikegami (Patriarch) on Sep 08, 2010 at 02:11 UTC
    You're complicating things.
    use Path::Class qw( file dir ); my $base = dir('c:\\abc\\def'); my $node = file('c:\\abc\\def\\ghi\\jkl'); # or dir() print $node->relative($base), "\n";

    Path::Class

Re: unable chec whether the word is intermediate or last word in a sentence
by kennethk (Abbot) on Sep 07, 2010 at 22:34 UTC
Re: unable chec whether the word is intermediate or last word in a sentence
by dasgar (Priest) on Sep 07, 2010 at 22:38 UTC
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: unable chec whether the word is intermediate or last word in a sentence
by roboticus (Chancellor) on Sep 07, 2010 at 22:40 UTC