Hello Monks, I have a file name and path which i am trying to parse. The $file contains the full path of the file.So i split based on \. Taking the second argument(file resides in a folder under root), i want to strip the extension. This is what I am doin.

foreach my $file (@files){ my @arr=split(/\//,$file); print "\n $arr[2];"; }

Now this is what I am trying to do to remove the extension for the file. "system%abc%123%.txt" which is the valule in $arr2.

my $length_arr=length($arr[2]); my $fname=sub($arr[2],0,($length_arr-4)); print $fname;

It gives me a weird error."Perl Command Line Interpreter has encountered a problem and needs to close.We are sorry for the inconvinience.

The error signature looks like this. AppName:perl.exe AppVer:5.6.1.635 ModName:perl56.dll ModVer: 5.6.1.635 Offset: 0001c6d9 Can anyone help me figure what could be wrong? Thanks Sandy (smanicka) Sorry, I feel soo stupid.Its substr as pointed out by ysth.Thanks


In reply to weird error when using substring function by smanicka

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.