I am trying to create a file path out of a predetermined path and a variable which is a folder inside the pre determined path.
The predetermined part of the path is /sys/kernel/scst_tgt/targets/iscsi/
The next folder is an address for an iSCSI target like iqn.2011-08.com.solignis:datastore2
Then the last part is something like /enabled which is a file that tells the state of the target.
When I try to print the full path with the variable $target_name being replaced with the name of the iSCSI target. The resulting output looks like this
/sys/kernel/scst_tgt/targets/iscsi/iqn.2011-08.com.solignis:datastore2
/enabled
It puts the enabled part on a new line. I can’t figure out what is going on
Here is the code for the sub routine I was working on:
sub target_enabled {
my $target_name = shift;
my $target_state_file = "/sys/kernel/scst_tgt/targets/iscsi/$target_name/enabled";
print "$target_state_file\n";
}
Looks like you have a newline at the end of
$target_name. So:And if that doesn’t work (because you may have for example
\r\nfrom a windows file):