PerlSharp : Perl Namespace
Scalar

Scalars are strings and numbers in Perl.

public class Scalar : Value

Remarks
Scalars are stored by Perl as a string, integer, or double-precision floating point number. But, Perl will convert on the fly between its stored representation and the desired representation. Because the managed world is type-safe, some of this magic disappears when you want to actually access the value of the Scalar, because you must specify in what representation you want the value.
Members

See Also: Inherited members from Value.

Constructors
Scalar(Interpreter, int)
Creates a new scalar with an integer value.
Scalar(Interpreter, double)
Creates a new scalar with a double value.
Scalar(Interpreter, string)
Creates a new scalar with a string value.
Scalar(Scalar)
Creates a new scalar with the same value of the given scalar.
Scalar(Interpreter, object)
Creates a new scalar with the given value.
Properties
DoubleValue
double. Gets/sets the value of the Scalar as a double.
IntValue
int. Gets/sets the value of the Scalar as an integer.
StringValue
string. Gets/sets the value of the Scalar as a string.
Methods
Append(Scalar)
Appends a string to the end of this Scalar.
Concat(Scalar) : Scalar
Returns the concatenation of this Scalar and another Scalar.
static Eq(Scalar, Scalar) : bool
Tests for string equality on two Scalars, using the Perl eq operator.
SetValue(string)
Changes the value of the Scalar to a string.
SetValue(int)
Changes the value of the Scalar to an integer.
SetValue(double)
Changes the value of the Scalar to a double.
static StringCompare(Scalar, Scalar) : int
Performs a string comparison on two Scalars, using the Perl string comparison operator.
Operators
Conversion: Perl.Scalar to System.String
Implicitly converts a Scalar to its string value.
Conversion: Perl.Scalar to System.Int32
Implicitly converts a Scalar to its integer value.
Conversion: Perl.Scalar to System.Double
Implicitly converts a Scalar to its double value.
Member Details
Scalar Constructor
public Scalar (Interpreter context, int value)

Creates a new scalar with an integer value.

Parameters
context
The context in which to create the scalar.
value
The initial value of the scalar.

Scalar Constructor
public Scalar (Interpreter context, double value)

Creates a new scalar with a double value.

Parameters
context
The context in which to create the scalar.
value
The initial value of the scalar.

Scalar Constructor
public Scalar (Interpreter context, string value)

Creates a new scalar with a string value.

Parameters
context
The context in which to create the scalar.
value
The initial value of the scalar.

Scalar Constructor
public Scalar (Scalar value)

Creates a new scalar with the same value of the given scalar.

Parameters
value
The scalar that contains the initial value for the new scalar.
Remarks
The scalar is created in the context of value.

Scalar Constructor
public Scalar (Interpreter context, object value)

Creates a new scalar with the given value.

Parameters
context
The context in which to create the scalar.
value
The initial value of the scalar.
Remarks
If the type of value is convertible to a type used in one of the other constructors, value is converted, if necessary. Otherwise, ToString is called on value and the scalar is initialized with that string value.

SetValue
public void SetValue (string v)

Changes the value of the Scalar to a string.

Parameters
v
The new value for the Scalar.

SetValue
public void SetValue (int v)

Changes the value of the Scalar to an integer.

Parameters
v
The new value for the Scalar.

SetValue
public void SetValue (double v)

Changes the value of the Scalar to a double.

Parameters
v
The new value for the Scalar.

Append
public void Append (Scalar value)

Appends a string to the end of this Scalar.

Parameters
value
The value to append.

Concat
public Scalar Concat (Scalar value)

Returns the concatenation of this Scalar and another Scalar.

Parameters
value
The Scalar to concatenate.
Returns
A Scalar containing the concatenated string.

StringCompare
public static int StringCompare (Scalar s1, Scalar s2)

Performs a string comparison on two Scalars, using the Perl string comparison operator.

Parameters
s1
A Scalar.
s2
A Scalar.
Returns
The result of the Perl string comparison: -1 if s1 < s2, 0 if s1 eq s2, or 1 if s1 > s2.

Eq
public static bool Eq (Scalar s1, Scalar s2)

Tests for string equality on two Scalars, using the Perl eq operator.

Parameters
s1
A Scalar.
s2
A Scalar.
Returns
The result of the Perl eq operator: true iif the scalars are string-wise equal.

Conversion
public static implicit operator string (Scalar s)

Implicitly converts a Scalar to its string value.

Parameters
s
The Scalar to convert.
Returns
The string value of the Scalar.
Remarks
Equivalent to calling the StringValue property of the Scalar.

Conversion
public static implicit operator int (Scalar s)

Implicitly converts a Scalar to its integer value.

Parameters
s
The Scalar to convert.
Returns
The integer value of the Scalar.
Remarks
Equivalent to calling the IntValue property of the Scalar.

Conversion
public static implicit operator double (Scalar s)

Implicitly converts a Scalar to its double value.

Parameters
s
The Scalar to convert.
Returns
The double value of the Scalar.
Remarks
Equivalent to calling the DoubleValue property of the Scalar.

StringValue
public string StringValue { set; get; }

Gets/sets the value of the Scalar as a string.

Value
The value of the Scalar as a string.

IntValue
public int IntValue { set; get; }

Gets/sets the value of the Scalar as an integer.

Value
The value of the Scalar as an integer.

DoubleValue
public double DoubleValue { set; get; }

Gets/sets the value of the Scalar as a double.

Value
The value of the Scalar as a double.