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
  • Print Output

Print Output

1 min read


Print takes a series of things to print separated by commas. By default, print writes to the STDOUT file handle.


print “Woo Hoo\n”;                                         ## print a string to STDOUT
$num = 42;
$str = ” Hoo”;
print “Woo”, $a, ” bbb $num”, “\n”;                ## print several things

An optional first argument to print can specify the destination file handle. There is no comma after the file handle, but I always forget to omit it.


print FILE “Here”, ” there”, ” everywhere!”, “\n”; ## no comma after FILE


File Processing Example

As an example, here’s some code that opens each of the files listed in the @ARGV array, and reads in and prints out their contents to standard output…


#!/usr/bin/perl -w
require 5.004;
## Open each command line file and print its contents to standard out
foreach $fname (@ARGV) {
   open(FILE, $fname) || die(“Could not open $fname\n”);
   while($line = ) {
      print $line;
   }
   close(FILE);
}


The above uses “die” to abort the program if one of the files cannot be opened. We could use a more flexible strategy where we print an error message for that file but continue to try to process the other files. Alternately we could use the function call exit(-1) to exit the program with an error code. Also, the following shift pattern is a common alternative way to iterate through an array…


while($fname = shift(@ARGV)) {…

Updated on May 4, 2025

What are your Feelings

  • Happy
  • Normal
  • Sad
Share This Article :
  • Facebook
  • X
  • LinkedIn
  • Pinterest
File InputString Processing with Regular Expressions

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