Wednesday, June 10, 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 comparable 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 determined. For instance: #!/usr/canister/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 creates this outcome: ! $ Note: The characters from 128 to 255â are 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 an experienced programming language some time before sites detonated in prominence. Perlâ was initially intended for content preparing, and it is good with HTML and other markup dialects, so it immediately got well known with site designers. Perls quality lies in its capacity to associate 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.