Perl Special Variables (some)

 Posted by at 2:52 pm  Coding & Scripting, Perl  Comments Off on Perl Special Variables (some)
May 032010
 

# a few of the most common special variables
# $_ default input
# $.  line numbers
# $1, $2, $3, etc. Pattern results
# $! System error number or string
# $@ eval() error
# $$  Process ID (PID)
# $0  Program name
# @_  List of arguments for subroutine
# @ARGV  List of command-line arguments
# @INC  List of paths Perl searches for libraries and modules
# %ENV  List of environment variables

Use Perl to display a file with line numbers

 Posted by at 2:45 pm  Coding & Scripting, Perl  Comments Off on Use Perl to display a file with line numbers
May 032010
 

I’m not sure how a Perl code snippet will react in a CMS posting so I’ve commented it out; if you have use for this simple script remove the “#” comment characters.  The code could be named anything, I call it readme.pl and it is run from the command prompt as ‘perl readme.pl filename‘. The file utilizes the default file handle within the “while()” to open the file referred to by @ARGV (a special variable) and two common special variables “$.” and “$_” for line numbers and default input respectively.

#!/usr/bin/perl
#
# use strict;
# use warnings;
#
# main(@ARGV);
#
# sub main
# {
# while() {# using the special file handle to read lines from the command line
# print “$. $_”;
#  }
#}

JAVA Reserved Words

 Posted by at 7:31 pm  Coding & Scripting, JAVA  Comments Off on JAVA Reserved Words
Aug 222009
 

JAVA identifiers should be meaningful, but they cannot include the following reserved words (if you don’t rust me ask the Oracle):

  1. abstract
  2. assert
  3. boolean
  4. break
  5. byte
  6. case
  7. catch
  8. char
  9. class
  10. const
  11. continue
  12. default
  13. do
  14. double
  15. else
  16. enum
  17. extends
  18. false*
  19. final
  20. finally
  21. float
  22. for
  23. goto
  24. if
  25. implements
  26. import
  27. instanceof
  28. int
  29. interface
  30. long
  31. native
  32. new
  33. null*
  34. package
  35. private
  36. protected
  37. public
  38. return
  39. short
  40. static
  41. strictfp
  42. super
  43. switch
  44. synchronized
  45. this
  46. throw
  47. throws
  48. transient
  49. true*
  50. try
  51. void
  52. volatile
  53. while

* Predefined literals that cannot be used as identifiers