Friday, August 21, 2020

Using Perl Chr() and Ord() Functions

Utilizing Perl Chr() and Ord() Functions The Perl programming languagesâ chr() and ord() capacities are utilized to change over characters into their ASCII or Unicode qualities and the other way around. Chr() takes an ASCII or Unicode worth and returns the proportionate character, and ord() plays out the converse activity by changing over a character to its numericâ value.â Perl Chr() Function The chr() work restores the character spoke to by the number indicated. For instance: #!/usr/container/perl print chr (33) print/n; print chr (36) print/n; print chr (46) print/n; At the point when this code is executed, it delivers this outcome: ! $ Note: The characters from 128 to 255â are as a matter of course not encoded as UTF-8 for in reverse similarity reasons. Perls Ord() Function The ord() work does the inverse. It takes a character and changes over it into its ASCII or Unicode numeric worth. #!/usr/canister/perl print ord (A); print/n; print ordâ (a); print/n; print ord (B); print/n; At the point when executed, this profits: 65 97 66 You can affirm the outcomes are accurateâ by checking an ASCII Code Lookup Table on the web. About Perl Perl was made in the mid-80s, so it was a developed programming language well before sites detonated in ubiquity. Perlâ was initially intended for content handling, and it is good with HTML and other markup dialects, so it immediately got famous with site engineers. Perls quality lies in its capacity to cooperate with its condition and its cross-stage similarity. It can without much of a stretch open and control numerous documents inside a similar program.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.