smanicka has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: weird error when using substring function
by ysth (Canon) on Dec 22, 2008 at 19:08 UTC | |
|
Re: weird error when using substring function
by ikegami (Patriarch) on Dec 22, 2008 at 19:12 UTC | |
|
Re: weird error when using substring function
by Tanktalus (Canon) on Dec 22, 2008 at 19:06 UTC | |
|
Re: weird error when using substring function
by gube (Parson) on Dec 23, 2008 at 00:43 UTC |