1757087 Members
1678 Online
108858 Solutions
New Discussion юеВ

Re: New to Perl

 
SOLVED
Go to solution
Yvette Robinson
New Member

New to Perl

I need to specify
#If it's the inventory scanner set the scanner to upper case
Code:
If ($Scanner_Type eq 'inventory') {
$Scanner_Name = $UPPERCASE;
Is this about right?
4 REPLIES 4
g33k
Valued Contributor
Solution

Re: New to Perl

if you mean that if $Scanner_Type is inventory than it should be INVENTORY than this will be better
$Scanner_Type = ($Scanner_Type eq 'inventory')?uc($Scanner_Type):$Scanner_Type;
Yvette Robinson
New Member

Re: New to Perl

Couldn't I also have written it like this as well?
If ($Scanner_Type eq 'INVENTORY')?uc
$Scanner_Name = uc:$Scanner_Name
James R. Ferguson
Acclaimed Contributor

Re: New to Perl

Hi Yvette:

# perl -le '$name="allcaps";$type="InVeNtOrY";$name=uc($name) if $type=~/inventory/i;print $name'

Regards!

...JRF...
Alexander Chuzhoy
Honored Contributor

Re: New to Perl

The answer to your second question is NO.
In general you have several ways to write a script in perl.
One more that achieves what you want:
$Scanner_Name=uc($Scanner_Name) if $Scanner_Name eq "inventory";