#!/usr/bin/perl -w use strict; use Tie::File; my $newdigit="+615"; my $search_id="0001"; my $personel_filename; my @personel; tie @personel, 'Tie::File', File::Spec->catfile($FindBin::Bin,$personel_filename) or die "Couldn't read '$personel_filename'\n"; for my $line (@personel) { my ($id, $name, $family, $oldphone)=split(/\|/, $line); # Look if we want to replace the phone if ($id eq $search_id) { $newphone = $newdigit .$oldphone; # And overwrite the line in the array $line = join ("|",$id, $name, $family, $newphone); }; };