I need to remove backslash from an array.
use strict;
use warnings;
use Time::HiRes qw(sleep);
use Test::WWW::Selenium;
use Test::More "no_plan";
use Test::Exception;
@array = "qwerty-uioplkjadsfcxhbdhjjkgkmnvkgmkgmkgkglmzbcd\-\dfgtg\qwerty";
i need to remove \ in the above array. i tried with @array =~ s/\\//;but i’m unable to do it.
After removing backslash from an array, an array should contain like below:
print @array;
output:
qwerty-uioplkjadsfcxhbdhjjkgkmnvkgmkgmkgkglmzbcd - dfgtg qwerty
how can i just remove the backslash ?
First of all: double quotes will interpolate, so you should write
'...d\-\dfgtg\qwerty";'instead of"..";or useq{ }.Then there is
@array =~ s/\\//;which isn’t valid syntax. I guess you wanted to writes#\\##g for @array;.This code works:
The output:
BTW: If you have only one element in your array, you should probably use a scalar.