Hi all,
I get a return value from running execution quotes
@var =`command here`;
The output is something like
G: <+> HardDiskVolume7
What I am trying to do is to capture the last number
There is newline character at the end, so I can chomp or split the array into individual elements and look at the second last element (because the last is newline)
code:
$retval = `command here`;
@char = split (//,$retval);
do something with $char[-2];
Problem 1)
This is fine if the last number is a single digit - ie length of array stays constant. How do I capture the number if it is double-digits? eg
G: <+> HardDiskVolume12
Problem 2)
Also, I can't rely on the first block of elements/text to be constant eg sometimes it might be:
G: <+> HarddiskDmVolumes\VariableServerName\Volume7
Should I do some sort of RegExp on "VolumeX", since it is the only thing that remains constant?
Cheers
Steve
I get a return value from running execution quotes
@var =`command here`;
The output is something like
G: <+> HardDiskVolume7
What I am trying to do is to capture the last number
There is newline character at the end, so I can chomp or split the array into individual elements and look at the second last element (because the last is newline)
code:
$retval = `command here`;
@char = split (//,$retval);
do something with $char[-2];
Problem 1)
This is fine if the last number is a single digit - ie length of array stays constant. How do I capture the number if it is double-digits? eg
G: <+> HardDiskVolume12
Problem 2)
Also, I can't rely on the first block of elements/text to be constant eg sometimes it might be:
G: <+> HarddiskDmVolumes\VariableServerName\Volume7
Should I do some sort of RegExp on "VolumeX", since it is the only thing that remains constant?
Cheers
Steve