# Perl tr command problem

**URL:** <https://community.unix.com/t/perl-tr-command-problem/260115>\
**Category:** Shell Programming and Scripting\
**Created:** [February 19, 2010, 12:33pm UTC](https://community.unix.com/t/perl-tr-command-problem/260115 "2010-02-19T12:33:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rsanjay](https://community.unix.com/user_avatar/community.unix.com/rsanjay/32/5799_2.png) [@rsanjay](https://community.unix.com/u/rsanjay)\
**Post date:** [February 19, 2010, 12:33pm UTC](https://community.unix.com/t/perl-tr-command-problem/260115/1 "2010-02-19T12:33:14Z")

</div>

#!/usr/bin/perl

#use strict;  
#use warnings;

my $data = 'node: id=c1, class=nb, cx=100, cy=100, r=10';

#in the above string stored in $data i want to replace = with =" and ',' with "\t

so i used the tr operator as follows

$data =~tr/=/="/s;  
print "$data";

But this is not giving me the desired result . what am i doing wrong?

---

<div class="post-metadata">

**Author:** ![anbu23](https://community.unix.com/user_avatar/community.unix.com/anbu23/32/351_2.png) [@anbu23](https://community.unix.com/u/anbu23)\
**Post date:** [February 19, 2010, 12:50pm UTC](https://community.unix.com/t/perl-tr-command-problem/260115/2 "2010-02-19T12:50:17Z")

</div>

tr is to replace one char by another char. If you want to replace by multiple characters then use this

```nohighlight
$data=~ s/=/="/g

```

---

<div class="post-metadata">

**Author:** ![rsanjay](https://community.unix.com/user_avatar/community.unix.com/rsanjay/32/5799_2.png) [@rsanjay](https://community.unix.com/u/rsanjay)\
**Post date:** [February 19, 2010, 12:58pm UTC](https://community.unix.com/t/perl-tr-command-problem/260115/3 "2010-02-19T12:58:19Z")

</div>

your right...This works like a charm . Thank you .
