Perl `chop` removes two characters instead of one -


I am using the command line to pass a string to a Perl program. For example, this is "stackOveflow" to the Hello

  Hello "Stack Overflow"  

I use the @ARGV

  cut ($ ARGV [$ # ARGV]) to remove the last character from the last element;  

and then print it

  says "$ ARGV [$ # ARGV]";  

I expect "stackOveflow in the output, but instead I can see stackOveflo

Tell me why?

Hello "Stack overflow" to execute the shell For the program Hello and pass it as a logic to the string stackOveflow (as my $ s = "stackOveflow"; Assigns the string stack overlove to $ x in Perl).

St Removes the last character of the string, hence the value varies with stackOveflow stack overflow .

$ perl -E'say $ ARGV [-1]; Cut ($ ARGV [-1]); $ ARGV [-1] "stack overflow" stack overflow stack overflow

Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -