To add an item to a Set in Perl, you can use the Set::Scalar module.
In this example,
$set
.insert
method to add an item to the set.use Set::Scalar;
my $set = Set::Scalar->new();
$set->insert("item1");
say $set;
{ item1 }
In this example,
$numbers
.insert
method to add an integer to the set.use Set::Scalar;
my $numbers = Set::Scalar->new();
$numbers->insert(123);
say $numbers;
{ 123 }
In this tutorial, we learned How to add an Item to a Set in Perl language with well detailed examples.