DEV Community

Yuki Kimoto
Yuki Kimoto

Posted on

PowerShell(pwsh) Tutorial for Perl

PowerShell(pwsh) is a CLI tool to run programs on Windows.

This article is originally PowerShell(pwsh) Tutorial for Perl | Perl ABC

  • UTF-8
  • Linux/UNIX-like Shell
  • ls, echo commands, etc
  • A string is quoted "" and ''

Installation of PowerShell(pwsh)

PowerShell(pwsh) can be downloaded from the following page.

Installing PowerShell on Windows

Click the following link to download PowerShell(pwsh).


And double-click the downloaded file. The installer is executed.

"Next" | "Next" | "Next" | "Install" | "Finish"

Execution of PowerShell/pwsh

Let's execute PowerShell/pwsh.

"Start Menu" | "Apps" | "PowerShell" | "PowerShell 7 (x64)"

Your home directory is shown on PowerShell/pwsh.

PS C:\Users\kimot

Showing File Extensions

The extension of Perl program is ".pl". It is useful if extensions of files are displayed.

The way to show file extensions is described in the following page.

How to Make Windows Show File Extensions

Execution of Notepad

Perl programs are text files. You can create your Perl programs using Notepad.

The way to use Notepad is described in the following page.

11 ways to start Notepad in Windows

Creating Perl Programs

Let's create a Perl program.

Create a file named "" at your home directory.


And write the following text.

print "Hello World";

And save it.

Running Perl Programs

You can run your Perl program using perl command.


The output is:

Hello World

Commands of PowerShell/pwsh

Introduce often used commands of PowerShell/pwsh.


The "ls" command displays the list of files.



The "cd" command changes the working directory.

cd DirectoryName

".." is the file name that means the folder one level higher.

cd ..

Changing Drives

You can change drives using "c:" or "d:".

Set-Location -Path c:
Set-Location -Path d:

Seeing Command Histories

You can see command histories using "↑" and "↓" keys.


Show Environment Variables

Show environment variables.

ls env:

Getting Environment Variables

You can get and show an environment variable as the following.

echo $env:PATH

$env:MYENV = "This is my env."

Setting Environment Variable

You can set an environment variable as the following.


Discussion (0)