Free Republic
Browse · Search
General/Chat
Topics · Post Article

To: John Robinson
why so many different symbols? All i use primarily is <% %> everything else is vbscript tightly wound into the OS. (good or bad, I love how powerful it is for what I want).
27 posted on 06/19/2002 8:51:16 PM PDT by smith288
[ Post Reply | Private Reply | To 26 | View Replies ]


To: smith288
Well, ya gotta have the sigils ($, @, %, *) to know what kinda data you're working with (scalars, arrays, hashes, or typeglobs.) You need a liberal dose of curly braces to designate blocks of code, hash lookups, 'type coercion'(because the built-ins are broken, IMHO, they should accept references), or to disambiguate expressions--particular those resolving to references to data. You need -> to dereference said data. You can't have regular expressions without !~ and the equally agreeable =~ or slashes. And with regular expressions you need lots of slashses, forward slashes, backward slashes, I'm sure Larry would work in sideways slashes if there were such a beast. Regular expressions rock! A whole microlanguage for the budding symbologist. You need + and * to greedily select atoms, or +? and *? if you're feeling stingy. Parens, lots of parens to group atoms, and you often want non-capturing parens (speed optimization) so be sure to use (?:) non-capturing parens. Often times we'll want to match wildcards, so use either the backslash letter character classes (ie: \w alphanumerics and underscores) or user-defined char classes (square brackets, characters, often using dashes to represent ranges, ie, hex: [0-9a-fA-F]), or dots for the ultimate wildcard (that unfortunately doesn't match newlines, so use .|\n, the pipe being an alternative--this or that. It's a C-like language, and thus requires all statements to end with semi-colons. Single and double quotes to represent strings (non-interpolating and interpolating) double-colons to reference other packages ($Focus::r -- a previous allocated reference to a request in the Focus package) uh... and being Perl, all special variables are sigil-symbol. $_ is the scalar representing the default "whatever" (The diamond operator by default assigns output to $_, foreach and map assign to $_, split reads $_ and splits into @_ by default, etc... etc...) There are probably just as many sigil-symbols as there are symbols. Nah, we can always find a spare sigil-symbol to store the odd tidbit. And of course, who couldn't love a language that uses a spaceship operator? <=> a strcmp for numbers, great for a sort. (strcmp for strings is the cmp operator, there are also gt, lt, ge, le, eq, and ne string operators.) String concatenation is the dot.

Comments start with a hash. And of course all Perl code written for Unix machines begins with the shebang (#!) which is actually a Unix kernel constuct to declare a script interpreter. IE: #!/usr/bin/perl -wT

Larry Wall either designed Perl as a joke or he's a crack addict. Or a very funny crack addict. But I love Perl.
30 posted on 06/19/2002 11:15:19 PM PDT by John Robinson
[ Post Reply | Private Reply | To 27 | View Replies ]

Free Republic
Browse · Search
General/Chat
Topics · Post Article


FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson