Is there an equivalent to Perl's $_
function? I'm rewriting some old perl scripts in C# and I never learned any perl. Heres an example of what i'm trying to figure out
sub copyText {
while($_[0]){
$_[1]->Empty();
$_[0] = $_[1]->IsText();
sleep(1);
}
First of all, $_
is not a function. It's just an ordinary variable (that happens to be read and changed by a lot of builtins).
Second of all, the code you posted does not use $_
. It's accessing elements of @_
, the parameter list.
A more more readable version of the code you posted would be:
sub copyText {
my ($arg1, $arg2) = @_;
while ($arg1) {
$arg2->Empty();
$arg1 = $arg2->IsText();
sleep(1);
}
$_[0] = $arg1; # arg1 is passed by reference
}
Empty
and one named IsText
.Sorry, I don't know C#, but hopefully you can move on with this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With