setting new variable to regex of another without changing the other variable in perl
currently i have a Variable named $name which contains "JOHN,SMITH".
What i'm looking to do is take the first letter of the first and last name and assign it to another variable without changing $name. what i tried was this: Code:
$OF = $name =~ s/^(.).*,(.).*/$1$2/; how do i get $OF to be JS and $name to stay "JOHN,SMITH" thanks Edit: figured it out: Code:
($OF = $name) =~ s/^(.).*,(.).*/$1$2/; |
Hi Eppo,
it becomes more obvious what you want to achieve when you split the name at first and then use a regex for each word, here's the example: Code:
#!/usr/bin/perl |
All times are GMT -5. The time now is 03:40 AM. |