Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Perl Programming/Keywords/cmp

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Perl closedir connect Keywords The cmp keyword cmp is a binary function that returns -1, 0, or 1 depending on whether the left argument is stringwise less than, equal to, or greater than the right argument. In other words, cmp does the same textually what the binary function <=> does. Syntax EXPRESSION cmp EXPRESSION Examples The code use strict; use warnings; my @array = ("Hotel", "Alpha", "Foxtrott", "Bravo", "India", "Charlie", "10", "-10", "9", "-9", "Echo", "Delta"); my @sorted_array = (sort { $a cmp $b } @array); print join(",", @sorted_array), "\n"; returns array contents sorted alphabetically: -10, 10, Alpha, Bravo, Charlie, Delta, Echo, Foxtrott, Hotel, India See also sort Perl closedir connect Keywords