Skip to content
asicguru.tech@gmail.com
REGISTER LOGIN
AsicGuru Ventures
  • All Courses
  • CONTACT
  • GALLERY
  • HOME
  • Tutorials

0

Verilog Tutorial

17
  • Verilog Introduction
  • Lexical Tokens
  • Gate-Level Modelling
  • Data Types
  • Operators
  • Operands
  • Modules
  • Behavioral Modeling
  • Timing Controls
  • Procedures: Always and Initial Blocks
  • Functions
  • Tasks
  • Component Inference
  • Finite State Machines.
  • Compiler Directives
  • System Tasks and Functions
  • Test Benches

System Verilog

23
  • System Verilog Introduction
  • Data Types
  • Type Casting
  • Arrays
  • Associative Arrays
  • Dynamic Arrays
  • Queue
  • Operators
  • Procedural statements and Control flow
  • Classes
  • Inheritance
  • Encapsulation
  • This and Super operator
  • In-Line Constraints
  • Class Constraints
  • Virtual Classes
  • Parameterized Classes
  • Classes Summary
  • Singleton Classes
  • Functional Coverage Introduction
  • Covergroup
  • Tools
  • Books

Scripting

15
  • Introduction
  • Perl Tutorial
  • What is Perl
  • Perl: Syntax And Variable
  • Perl Strings
  • Perl Arrays
  • Perl Associative Arrays
  • If/While Syntax
  • File Input
  • Print Output
  • String Processing with Regular Expressions
  • Subroutines
  • Running External Programs
  • References
  • Terse Perl

Makefile

1
  • Makefile Tutorial
View Categories
  • Home
  • Tutorials
  • Scripting
  • References

References

1 min read


I’m happiest writing Perl code that does not use references because they always give me a mild headache. Here’s the short version of how they work. The backslash operator (\) computes a reference to something. The reference is a scalar that points to the original thing. The ‘$’ dereferences to access the original thing.

Suppose there is a string…


$str = “hello”;        ## original string


And there is a reference that points to that string…


$ref = \$str;          ## compute $ref that points to $str


The expression to access $str is $$ref. Essentially, the alphabetic part of the variable, ‘str’, is replaced with the dereference expression ‘$ref’…


print “$$ref\n”; ## prints “hello” — identical to “$str\n”;


Here’s an example of the same principle with a reference to an array…


@a = (1, 2, 3);        ## original array
$aRef = \@a;           ## reference to the array
print “a: @a\n”;                 ## prints “a: 1 2 3”
print “a: @$aRef\n”;             ## exactly the same


Curly braces { } can be added in code and in strings to help clarify the stack of @, $, …


print “a: @{$aRef}\n”;           ## use { } for clarity


Here’s how you put references to arrays in another array to make it look two dimensional…

@a = (1, 2, 3);
@b = (4, 5, 6);
@root = (\@a, \@b);
print “a: @a\n”;                       ## a: (1 2 3)
print “a: @{$root[0]}\n”;              ## a: (1 2 3)
print “b: @{$root[1]}\n”;              ## b: (4 5 6)
scalar(@root)                  ## root len == 2
scalar(@{$root[0]})            ## a len: == 3


For arrays of arrays, the [ ] operations can stack together so the syntax is more C like…
$root[1][0]                    ## this is 4

Updated on May 4, 2025

What are your Feelings

  • Happy
  • Normal
  • Sad
Share This Article :
  • Facebook
  • X
  • LinkedIn
  • Pinterest
Running External ProgramsTerse Perl

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Archives

  • May 2025

Categories

  • Slider Post
  • Uncategorized

Copyright @ Asicguru Ventures by Misbah WP | Proudly powered by WordPress