PERL chop Function

Syntax

chomp VARIABLE
chomp( LIST )
chomp


Definition and Usage

Removes the last character from EXPR, each element of LIST, or $_ if no value is specified.

Return Value

  • The character removed from EXPR
  • In list context, The character removed from the last element of LIST

Example

#!/usr/bin/perl

$string1 = "This is test";
$retval = chop( $string1 );

print " Choped String is : $string1n";
print " Character removed : $retvaln";

This will produce following result
 Choped String is : This is tes
Number of characters removed : t
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s