please dont rip this site

Perl / Perl for Windows

...which in my experience is certainly the "Pathologically Eclectic Rubbish Lister"

Quickstart

Syntax:
http://perldoc.perl.org/perlsyn.html
Terminate all lines with semicolon (;) but not after blocks which are in {}'s.

One = is assignment two = (==) is comparison, but it compares the numerical value when used with strings (e.g."abc" is converted to 0, "123" is converted to 123), and eq is really string comparison. Same with <, >, and lt, gt and with <=, >= and le, ge. != (numbers) is ne (string values). Wait till you get to <=> and cmp!

Comment out a sequence of lines by starting one with =pod and end the comment with =cut. POD is "Plain Old Documentation"1. Comment out a single line with the pound sign (#). as in

print "hello"; # will print
#print "hello"; # will not print

Data:
http://perldoc.perl.org/perldata.html
References to variables start with $ if they are a single value of any type (called a scalar, $ does NOT mean string) or @ if they are an array (or a list) or % if they are a hash aka indexed array (% has nothing to do with integers). $#array is index of last entry or approx # of entries in an Array. keys(%hash) is count of keys in hash. No declarations are required. Type casting is automatic. Preface the first reference to a variable with my if you want it to be local. Don't step on the predefined variables! Examples

Values are replaced in a string constant enclosed with double quotes but not in one with single quotes.

A scalar value is interpreted as TRUE in the Boolean sense if it is not the null string or the number 0 (or its string equivalent, ``0''). There are actually two varieties of null strings (sometimes referred to as ``empty'' strings), a defined one and an undefined one. The defined version is just a string of length zero, such as "". The undefined version is the value that indicates that there is no real value for something, such as when there was an error, or at end of file, or when you refer to an uninitialized variable or element of an array or hash.

Parameters are optional (or rather there are default parameters). You can say while (<*.c>) { print; } and the names of all the .c files in the current directory will be printed. These names got from <*.c> to print via a thing refferred to as $_ If you don't specify a variable to hold a return value or supply a parameter value, it uses $_

The array @ARGV contains the command-line arguments intended for the script. $#ARGV is generally the number of arguments minus one, because $ARGV[0] is the first argument, not the program's command name itself.

Half of everything in Perl is regular expressions. They look like gibberish. I have yet to find a concise, complete, and understandable reference.

Statements: Note that the subscriped numbers show the order of execution in cases were that might be confusing.

Note that if, while, for, foreach are apparently not considered functions but rather modifiers for statements. In fact, the "statements" in the language can be extended, overridden, and augemented with the because a block of statements (in {} or a single statement) can be passed to a sub as a parameter. Sort of like passing a function but without any name to the function.

Shell to the os with a command enclosed in backticks (grave accents). e.g. `dir` will return each line of output as an element of an array and the status of the command as a scaler.

Functions: http://perldoc.perl.org/index-functions.html

Encoding URLs (thanks to http://glennf.com/writing/hexadecimal.url.encoding.html )

sub URLEncode {
  my $theURL = $_[0];
  $theURL =~ s/([\W])/"%" . uc(sprintf("%2.2x",ord($1)))/eg;
  return $theURL;
  }

Functions which can process a list of parameters seperated by commas can be completely fooled by parenta

Win32 stuff, Web Services

A sample mailto.pl script

A sample http get script

a sample bbs_forum.pl script

See also:

Questions:


file: /Techref/language/perl/index.htm, 15KB, , updated: 2021/3/27 02:21, local time: 2024/12/22 22:33,
TOP NEW HELP FIND: 
3.148.105.152:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://sxlist.com/Techref/language/perl/index.htm"> PERL</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 
Quick, Easy and CHEAP! RCL-1 RS232 Level Converter in a DB9 backshell
Ashley Roll has put together a really nice little unit here. Leave off the MAX232 and keep these handy for the few times you need true RS232!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .