Reputation: 663
Seem like my daily road block. Is this possible? String in qw?
#!/usr/bin/perl
use strict;
use warnings;
print "Enter Your Number\n";
my $usercc = <>;
##split number
$usercc =~ s/(\w)(?=\w)/$1 /g;
print $usercc;
## string in qw, hmm..
my @ccnumber = qw($usercc);
I get Argument "$usercc" isn't numeric in multiplication (*) at
Thanks
Upvotes: 0
Views: 694
Reputation: 1539
Instead of that, use
my @ccnumber = split /\s+/, $usercc;
Which does what you probably want, to split $usercc
on whitespace.
Upvotes: 4
Reputation: 18237
No.
From: http://perlmeme.org/howtos/perlfunc/qw_function.html
How it works
qw()
extracts words out of your string using embedded whitsepace as the delimiter and returns the words as a list. Note that this happens at compile time, which means that the call toqw()
is replaced with the list before your code starts executing.
Additionlly, no interpolation is possible in the string you pass to qw().
Upvotes: 6