Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can $^E be compared with a number?

In https://stackoverflow.com/a/3220688/180275 the answer suggests that (after an open) $^E can be compared with 0x20 to determine if a file is being used by another process:

open ($fh, "<", "the-file");
if ($^E == 0x20) {
  ...
}

I have tried that and it works. However, if I print the value of $^E I get a string (The process cannot access the file because it is being used by another process).

How then is the comparison to a number still possible?

This is on Windows.

like image 432
René Nyffenegger Avatar asked Jul 15 '14 11:07

René Nyffenegger


People also ask

What does e do to a number?

In statistics, the symbol e is a mathematical constant approximately equal to 2.71828183. Prism switches to scientific notation when the values are very large or very small. For example: 2.3e-5, means 2.3 times ten to the minus five power, or 0.000023.

How do you compare numbers in exponential form?

You can compare two numbers written in scientific notation by looking at their powers of 10. The number with the greater power of 10 will be the greater number. If two numbers have the same power of 10, then compare the decimal numbers to determine the greater number. Here is an example.

What does it mean to compare numbers?

Comparing numbers in math is defined as a process or method in which one can determine whether a number is smaller, greater, or equal to another number according to their values. The symbols used for comparing numbers are “ ”, which means “greater than”; “ ”, which means “less than”; and “=”, which means “equal to”.

What is the comparison between two numbers?

Ratios are used to compare two numbers. The value of a ratio a:b is the quotient a ÷ b, or the result of dividing a by b.


1 Answers

>perl -E"open my $fh, '<', 'nonexistent'; say 0+$^E; say ''.$^E;"
2
The system cannot find the file specified

Like $!, $^E is a dualvar, a scalar that contains two values. One's a string, and one's a number.

>perl -E"say $^E = 0x20;"
The process cannot access the file because it is being used by another process
like image 77
ikegami Avatar answered Oct 12 '22 22:10

ikegami