Skip to content

Instantly share code, notes, and snippets.

@lamegaton
Last active March 24, 2021 22:17
Show Gist options
  • Save lamegaton/43bc015b3e2842611a6ca2a57971d930 to your computer and use it in GitHub Desktop.
Save lamegaton/43bc015b3e2842611a6ca2a57971d930 to your computer and use it in GitHub Desktop.
Learning Perl

Hi everyone, today I decide to learn Perl because its quick text processing capability.
I like to solve practical problem so here I'll show you how I solve each problem using Perl.
*Strawberry Perl 5 (windows) is used for this tutorial.

1: How to convert from 1 column to multiple column

So in this problem, I have a column with alternative value such as

Elephan
10
Shark
12
Turtle
30

As you can see, odd row is the name and even row is the age of each animal. I want to separate odd and even row then save it as CSV file such as:

Animal Ages
Elephan 10
Shark 12
Turtle 30

First, assuming you already have Perl on your PC, we can run perl with one line by using

perl -e "<YOUR CODE>"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment