I am very new to perl - I am editing a script that outputs data on a linux machine:
below is what I think is the portion of the code I need help with - I need help in formating the $port variable
The $port variable is usually equal to S0 through S32 (it is equal to one of these usually)
What I need done is to make it so that if $port is equal to S0 through S9 to format it as S00 - S09 (I need to have the leading zero)
I have code to do this with the linux command sed - but this is in linux and I'm not sure if it can be used with perl
Any help will be appreciated
%, 2004
below is what I think is the portion of the code I need help with - I need help in formating the $port variable
The $port variable is usually equal to S0 through S32 (it is equal to one of these usually)
What I need done is to make it so that if $port is equal to S0 through S9 to format it as S00 - S09 (I need to have the leading zero)
Code:
#code section I think is where the formating needs to be done
my ($port, $user, $start);
format STDOUT =
@<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<
$port, $user, $start
.
I have code to do this with the linux command sed - but this is in linux and I'm not sure if it can be used with perl
Code:
#Linux command to format $port
$port=`echo "$port" |sed 's/S\([0-9]\)/S0\1/g;s/S0\([0-9][0-9]\)/S\1/g'
Any help will be appreciated
%, 2004