Perl default defined variables – store and restore

This is a little Script to store all default defined variables from Perl(Linux) into an Scalar ant then to restore everything like it was before the store function.

Important to include my Data-Dumper !

If you want to store your data in the intern arrays, run this:

  • scalar for Regex and program course are stored in “@_Course”
  • scalar for environment are stored in “@_Environment”
  • hashes and arrays are not stored because they are global or lower scope

only variables that writeable are getting stored.

Then restore your saved variables:

you could see if you changed any default variable with(1=changed):

Or you could print all Stored Variables:

(Important to include my dumper.)

 


scalar for Regex and program course:

$_ – contains current value of a loop

$& – contains match of the current Regex
$` – contains the left side of the current Regex
$’– contains the right side of the current Regex

$1,$2,.. – contains matching groups of Regex
$+ – contains the last group match of an Regex

$. – contains the current line number of the input file

$/ – sets the input record separator

$\ – sets the output record separator, added to every print.

$, – sets the output field separator, added to ever coma separated element

$” – sets the output list separator, added to ever coma separated list

$| – output auto flush, disables the output buffer. 0=off, 1=on

 


Format:

$% – current page number
$= – number of lines per page
$- – number of lines left on the page
$~ – name of the current format
$^ – name of the current head format
$: – delimiter of multiple lines
$^L – delimiter of multiple pages
$^A – accumulator

 


scalar for environment are stored:
$? – contains the last status of a pipe or child process

$! – contains the error status of a pipe or child process.

$@ – contains an empty string if eval works, and if not it contains the error

$$ – process id
$< – real user id
$> – effective user id
$( – real group id
$) – effective group id

$0 – current program name

$] – current Perl version(is deprecated use $^V instead)

$^D – current debugging flag, run your program wit the -D parameter
$^F – highest file descriptor
$^H – contains the number of syntax checks from use strict and other checks
$^I – is defined or undefined if the Inplace flag is set
$^M – could save data if no more ram is available
$^O -contains the current operating system

$^P – contains the current debugging status
$^S – the status of the per interpreter, if eval is running its undefined
$^T – contains the start time of the script

$^V -current Perl interpreter version

$^W – contains warning from the -w parameter, 1 if set, else 0
$^X – contains the current Perl interpreter path

 


hashes and arrays:
@_ – contains the parameter from calling a function

@ARGV – contains the parameter from calling your Perl script

@INC -paths where Perl looks for Modules

@ISA – contains a list of basic classes for object oriented
@EXPORT – Used for Modules to export
@EXPORT_OK – Used for Modules to export, but optional
%ENV – contains environment variables from your system

%SIG – contains Signal Handler to communicate to other processes

 

If you want a list as comment block use this:

15 thoughts on “Perl default defined variables – store and restore”

  1. Aw, this was an exceptionally nice post. Spending some time
    and actual effort to create a superb article… but what can I
    say… I hesitate a lot and never manage to get anything done.

    View Comment
  2. I have been exploring for a little for any high quality articles or blog posts in this sort of area .
    Exploring in Yahoo I finally stumbled upon this web
    site. Reading this info So i am happy to convey that I’ve an incredibly good uncanny feeling I
    found out just what I needed. I so much undoubtedly will make
    certain to do not put out of your mind this web site and give it a glance on a relentless basis.

    View Comment
  3. I’m amazed, I have to admit. Rarely do I encounter a blog that’s equally
    educative and amusing, and let me tell you, you have hit the nail on the head.
    The problem is an issue that not enough people are
    speaking intelligently about. Now i’m very happy that I stumbled
    across this in my search for something relating to this.

    View Comment
  4. Thank you for the auspicious writeup. It in fact was once a leisure account it.
    Look complicated to far brought agreeable from you! However,
    how can we be in contact?

    View Comment
  5. I’m not that much of a internet reader to be honest but your sites really nice,
    keep it up! I’ll go ahead and bookmark your site to come back later.

    Many thanks

    View Comment
  6. Very nice post. I just stumbled upon your weblog and wanted to say
    that I have really enjoyed browsing your blog posts.
    After all I will be subscribing to your rss feed and I hope you write again soon!

    View Comment
  7. Hey There. I found your blog using msn. This is an extremely well written article.
    I’ll make sure to bookmark it and return to
    read more of your useful information. Thanks for the post. I’ll definitely return.

    View Comment
  8. Excellent items from you, man. I have take note your stuff previous to and you’re simply extremely excellent.
    I actually like what you have received right here, certainly like what you are stating and the way in which you say it.
    You’re making it entertaining and you continue to take care of to stay it sensible.
    I can’t wait to read much more from you. This is really a great website.

    View Comment
  9. Excellent post. I was checking continuously this weblog and I am
    inspired! Extremely useful information specifically the final phase 🙂 I deal with such information much.
    I used to be seeking this particular information for a very lengthy time.
    Thank you and best of luck.

    View Comment

Leave a Reply

Your email address will not be published.

three + 4 =