Here is an excerpt:
#!/usr/bin/perl
$number = "5";
$exponent = "2 ** 8";
$string = "Hello, PERL!";
$float = 12.39;
# We can also assign a scalar an empty (undefined) value:
$nothing = undef;
# Printing all the above values
print "$number\n";
print "$exponent\n";
print "$string\n";
print "$float\n";
print "There is nothing: $nothing\n";
This will give following result
5
2 ** 8
Hello, PERL!
12.39
There is nothing:
My question is whether $number, $exponent, and $float are actually numbers
or character strings, particularly those that are enclosed in quotes. Thus,
what would be the result of:
$mynum = $number * $float;
print "$mynum";
print $mynum;
$mynum = 2 ** 8;
print "$mynum"
And what happens if you add characters and variables in a print statement?
print "This is a number$mynum2";
The information in the FAQ did not seem to address this except as follows:
my $string = '0644';
print $string + 0; # prints 644
print $string + 44; # prints 688, certainly not octal!
It seems like the printf and sprintf functions work as I would expect,
printf "0%o %d", $number, $number;
But what happens if you use the following:
$number = "0123";
$number = "A123";
$number = "one";
$number = 123;
$number = 123 + 4.56;
$number = "123 + 4.56";
$number = "123" + "4.56";
Sorry for the noobish questions, but I am used to C and Delphi Pascal,
where I am familiar with the syntax.
Thanks,
Paul
>I am trying to understand scalar variables, and I found the following:
>http://www.tutorialspoint.com/perl/perl_scalars.htm
>
>Here is an excerpt:
WARNING!!! You do not have strick/warnings turned on!
>
> #!/usr/bin/perl
>
> $number = "5";
> $exponent = "2 ** 8";
> $string = "Hello, PERL!";
> $float = 12.39;
>
> # We can also assign a scalar an empty (undefined) value:
> $nothing = undef;
>
> # Printing all the above values
> print "$number\n";
> print "$exponent\n";
> print "$string\n";
> print "$float\n";
> print "There is nothing: $nothing\n";
Warning, undefined value in print!
>
> This will give following result
> 5
> 2 ** 8
> Hello, PERL!
> 12.39
> There is nothing:
>
>My question is whether $number, $exponent, and $float are actually numbers
>or character strings,
No and Yes. But if you continue to try to confuse yourself by naming the
variables what you think they contain, you've already lost the war on the
understanding of Perl.
> particularly those that are enclosed in quotes. Thus,
>what would be the result of:
>
> $mynum = $number * $float;
> print "$mynum";
> print $mynum;
> $mynum = 2 ** 8;
> print "$mynum"
>
>And what happens if you add characters and variables in a print statement?
>
> print "This is a number$mynum2";
>
The context of the variable as used in the print statement at the time it is
parsed will be used.
>The information in the FAQ did not seem to address this except as follows:
>
> my $string = '0644';
>
> print $string + 0; # prints 644
>
> print $string + 44; # prints 688, certainly not octal!
if ($string * 1 == 644) {
print "string + 44 = ", $string + 44, "\n";
}
>
>It seems like the printf and sprintf functions work as I would expect,
>
> printf "0%o %d", $number, $number;
>
>But what happens if you use the following:
>
> $number = "0123";
> $number = "A123";
> $number = "one";
> $number = 123;
> $number = 123 + 4.56;
> $number = "123 + 4.56";
> $number = "123" + "4.56";
>
>Sorry for the noobish questions, but I am used to C and Delphi Pascal,
>where I am familiar with the syntax.
>
>Thanks,
>
>Paul
>
Its all how you use it. Use it as a string, its a string. Number, a number.
It appears Perl uses a few representations of the same variable, it appears.
-sln
What do you mean by "actually"?
perl -e '$num=5; $str="5"; print "actually" if $num == $str'
actually
>
> Sorry for the noobish questions, but I am used to C and Delphi Pascal,
> where I am familiar with the syntax.
>
You can't learn perl from a C manual. Be that as it may, in C I can do:
double d;
d = 5; /* Wait! I thought 5 was an integer! What's going on? */
perl is like C with a much smarter compiler.
Not exactly, Perl is like C, with a structural variant representation
of values per variable.
-sln
$number, $exponent and $string are (currently) strings. $float is a
(floating-point) number. However, Perl will auto-convert string<->number
(and int<->float) whenever it becomes necessary.
> Thus,
> what would be the result of:
<snip>
>
> And what happens if you add characters and variables in a print statement?
<snip>
What happened when you tried it?
> Sorry for the noobish questions, but I am used to C and Delphi Pascal,
> where I am familiar with the syntax.
I think you need to stop reading random web tutorials and read an actual
beginners' book on Perl. I would normally recommend reading the docs
rather than a book, but it looks like you are someone who would benefit
from a more structured approach than the docs provide. The FAQ has
several (good) recommendations, under perldoc -q book.
Ben
unions are structural variant variables in C.
>On Mon, 06 Jul 2009 19:52:52 GMT, "Paul E. Schoen" <pa...@peschoen.com> wrote:
>
>>I am trying to understand scalar variables, and I found the following:
>>http://www.tutorialspoint.com/perl/perl_scalars.htm
>>
As a simple example, a Perl variable is a C structure containing
types (a union if you will), where the particular code usage is
determined at parstime (and will vary in different parts of the code),
and determined at runtime (mostly).
So like:
var variable {
char *;
int;
float;
...
}
If the particular spot in the code is used as a string,
it will use char *. If that is empty, it will grab int or float
and convert it to char *, assign it to char * (in the structure)
and use it dynamically at run time.
The same goes for all the other variants. In this regard its no
different than any typless language, say like JScript. There are rules
and defaults as always, as it percolates up to the parser and runtime
engine.
-sln
You can only be as dumb as the language you use.
-sln
as for you, how you are learning perl is bizarre given your claim to
know c and other langs. do you know shell at all? awk even? unix in
general? perl is best understood as being born of that environment
(including c) and stealing the best of breeds from each.
PES> I am trying to understand scalar variables, and I found the following:
PES> http://www.tutorialspoint.com/perl/perl_scalars.htm
yeah! i haven't done this in a while and i am in the mood for it. i have
found extremely few perl tutorials on the net worth a single bit of
space. i have done reviews (google for them) and i need to vent some on
this one.
i moved this to the top so you can read my summary.
i have to stop now. of course i can go on. there is lots here and some
of it is useful but as typical there is poor writing and too many
mistakes, misconceptions, inaccuracies. what is needed for all those web
tutes on perl is a good editor. they never seem to be written by someone
active in the perl community as they would have gotten useful feedback
that way. given the free beginning perl book and perl's own great
documentation (including many tutorials now) why these web tutes still
are found is beyond me.
uri
from the scalars page:
$number = "5";
that is a string, not a number
$exponent = "2 ** 8";
$string = "Hello, PERL!";
$float = 12.39;
# We can also assign a scalar an empty (undefined) value:
$nothing = undef;
it prints:
There is nothing:
the empty string is more appropriate as it won't trigger a warning.
from the page on arrays:
@10 = (1 .. 10);
@100 = (1 .. 100;
@1000 = (100 .. 1000);
using numbers for var names works but is dumb as hell.
@abc = (a .. z);
the last one will warn on unquoted strings
print "@10"; # Prints number starting from 1 to 10
print "@100"; # Prints number starting from 1 to 100
print "@1000"; # Prints number starting from 1 to 1000
the comment should be from 100. and do you want to print 900 numbers on
one line for a demo?
print "@abc"; # Prints number starting from a to z
that is not a number.
When adding elements using push() or shift() you must specify
two arguments, first the array name and second the name of the
element to add.
wrong. push and unshift take a list of elements to add to the array. and
you don't pass in the array name but the array variable. and what is the
'name of the element to add'? how would i push 1 as it has no name? or
an anon reference which has no name?
from the Object Oriented section:
Within Perl, an object is merely a reference to a data type that
knows what class it belongs to. The object is stored as a
reference in a scalar variable. Because a scalar only contains a
reference to the object, the same scalar can hold different
objects in different classes.
that is sara palin logic! what about a hash element holding an object?
what does different classes have to do with a single reference? it is
just the ability of a scalar value to be a reference to a blessed object
that is the core of perl's object flexibility.
Perl provides a bless() function which is used to return a
reference and which becomes an object.
bless associates a perl datum to a class. it is passed in a reference to
that datum and returns it. it does not create the reference which is
what the above statement implies.
the list of topics has this whopper!
Perl Error Handeling
how does he handle that error? :)
from the Perl IF..ELSE.. section (sic)
The final conditional statement is actually an operator.the
conditional operator. It is synonymous with the if...else
conditional statement but is shorter and more compact. The
format for the operator is:
(expression) ? (statement if true) : (statement if false)
huh? those are expressions, not statements. teaching that is the way to
get nasty precedence issues with ?:.
For example, we can emulate the previous example as follows:
($date == $today) ? print "Happy B.Day!\n" : print "Happy Day!\n";
and he doesn't even obey the previous style as () were not used. it will
work here because : is low binding but if you put an assignment in there
it breaks without the parens. also it subverts the purpose of ?: which
is to return a value based on a condition, not to do side effects. that
would better be written as:
print ($date == $today) ? "Happy B.Day!\n" : "Happy Day!\n";
which removes the redundant print calls, is shorter and proper.
from the operators page (edited a bit):
There are many Perl operators but here are a few of the most
common ones:
Arithmetic Operators
+ addition
- subtraction
* multiplication
/ division
Numeric Comparison Operators
== equality
!= inequality
String Comparison Operators
le less than or equal
ge greater than or equal
the comparison ops are the most common ops? who uses ge and le often?? i
can't recall the last time i actually used those!!
the only other text on this page is a copy of the precedence
table. that's it. basic math, comparison ops and then precedence with
nothing on any other ops.
from the regular expressions page:
There are three regular expression operators within Perl
* Match Regular Expression - m//
* Substitute Regular Expression - s///
* Transliterate Regular Expression - tr///
this is a classic tutorial laugher, calling tr/// a regex op.
the rest of this page has minimal explanations of regexes but a table of
all the modifiers. it shows $1 being used but with no explanation. there
is a minimal cheat sheet on character classes, anchors, etc.
it covers ?PATTERN? which is rarely used and newbies will not want to
learn about it. it is used mostly in more complex parsers and such to
match only one time.
so you could read perlretut and perlrequick and learn more from better
and more accurate writing.
uri
--
Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
>>>>>> "PES" == Paul E Schoen <pa...@peschoen.com> writes:
>
>as for you, how you are learning perl is bizarre given your claim to
>know c and other langs. do you know shell at all? awk even? unix in
>general? perl is best understood as being born of that environment
>(including c) and stealing the best of breeds from each.
Whats your claim, apparently you know everything, sort of a jack-off
of all trades.
-sln
s> On Mon, 06 Jul 2009 17:05:02 -0400, Uri Guttman <u...@stemsystems.com> wrote:
>>>>>>> "PES" == Paul E Schoen <pa...@peschoen.com> writes:
>>
>> as for you, how you are learning perl is bizarre given your claim to
>> know c and other langs. do you know shell at all? awk even? unix in
>> general? perl is best understood as being born of that environment
>> (including c) and stealing the best of breeds from each.
s> Whats your claim, apparently you know everything, sort of a jack-off
s> of all trades.
i know enough to not help you get a perl job. that is all i need to
know.
>>>>>> "s" == sln <s...@netherlands.com> writes:
>
> s> On Mon, 06 Jul 2009 17:05:02 -0400, Uri Guttman <u...@stemsystems.com> wrote:
> >>>>>>> "PES" == Paul E Schoen <pa...@peschoen.com> writes:
> >>
> >> as for you, how you are learning perl is bizarre given your claim to
> >> know c and other langs. do you know shell at all? awk even? unix in
> >> general? perl is best understood as being born of that environment
> >> (including c) and stealing the best of breeds from each.
>
> s> Whats your claim, apparently you know everything, sort of a jack-off
> s> of all trades.
>
>i know enough to not help you get a perl job. that is all i need to
>know.
>
>uri
I work for Google as a Perl manager. Don't let your resume pass my desk!
-sln
> I work for Google as a Perl manager.
Pffft!
Daydreaming of having a position is not actually the
same as having acquired that position...
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
I think I have a general aversion to languages that make assumptions about
variables, and that includes JavaScript and VB. I know enough C and Delphi
to make fairly complex Windows GUI applications that operate on a nearly
real-time basis with serial communication and data analysis, and I use a
version of C for some PIC projects, but mostly I use assembly.
I don't know shell. I found this:
http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
I have seen awk programs. I am not familiar with the syntax.
I know a few unix commands and I have used FTP and Telnet, but that's about
it. It seems similar to MSDOS but with more powerful features (like grep).
> PES> I am trying to understand scalar variables, and I found the
> following:
> PES> http://www.tutorialspoint.com/perl/perl_scalars.htm
>
> yeah! i haven't done this in a while and i am in the mood for it. i have
> found extremely few perl tutorials on the net worth a single bit of
> space. i have done reviews (google for them) and i need to vent some on
> this one.
Thanks for the warnings about on-line tutorials and other sources of
information. Even I found an error where a /E should have been \E:
$PARTIALCAPS = "\UThis half will/E become capital!";
I think it will not be worth it for me to learn enough Perl to do even the
simple things I may want to do. I should probably just hire an expert or
use some canned scripts and web apps, and stick with what I know.
Paul
First two are strings (exactly because they are enclosed in quotes),
$float is a number.
BUT(!!!): in Perl any string also has a numerical value and any number
also has a string value (and a boolean value, too).
>Thus,
>what would be the result of:
>
> $mynum = $number * $float;
Perl recognizes that $number, although a string, is used as a number and
therefore takes its numerical value, which happens to be 5.
If you had
$mynum = $exponent * $float;
then the numerical value of the string "2 ** 8" wold be 2, not 256!
> print "$mynum";
This is a useless use of quotes. See "perldoc -q always":
What's wrong with always quoting "$vars"?
> print $mynum;
> $mynum = 2 ** 8;
> print "$mynum"
Same here
>And what happens if you add characters and variables in a print statement?
>
> print "This is a number$mynum2";
You are using the variable $mynum2 instead of the variable $mynum.
If you want to print another character directly after the value of the
variable then enclose the variable name in curly brackets:
print "This is a number${mynum}2";
>The information in the FAQ did not seem to address this except as follows:
>
> my $string = '0644';
> print $string + 0; # prints 644
> print $string + 44; # prints 688, certainly not octal!
Totally different issue, that's about numbers with leading 0s, which
normally are interpreted as octal, but not so when explicitely marked as
strings by enclosing them in quotes.
>But what happens if you use the following:
>
> $number = "0123";
Numerical value is 123.
> $number = "A123";
Numerical value is 0 (and when used in numerical context you will also
get a warning about "argument not numerical").
> $number = "one";
Numerical value is 0 (and when used in numerical context you will also
get a warning about "argument not numerical").
> $number = 123;
Numerical value is 123.
> $number = 123 + 4.56;
Numerical value is 127.56.
> $number = "123 + 4.56";
Numerical value is 123 and when used in numerical context you will also
get a warning about "argument not numerical".
> $number = "123" + "4.56";
The + operator creates numerical context, thus you are adding the
numerical values of the strings "123" and "4.56", which happen to be 123
and 4.56, thus $number contains 127.56.
jue
Even though I have a job, I would do some side contract work for you.
-sln
> I am trying to understand scalar variables, and I found the following:
[ snip URL of a random tutorial found on "the web" ]
You will save yourself a lot of pain if you stop using your
current approach to learning this stuff.
Searching the web for "tutorial" type of information will almost
always lead to crap that will confuse rather than enlighten you.
There are precious few "good" tutorials out there, and as a beginner
you won't be able to tell the (few) good ones from the (many) bad ones.
You will save a boatload of time and pain if you learn it "right"
the first time...
... you should probably consider buying or borrowing a tutorial
book rather than letting web crap pollute your mental model.
Don't just go to the bookstore and pick a book either, there are
more than a few crappy Perl books out there too.
Do a bit of research to find a book that has a good reputation
among people who DO know Perl.
perldoc -q book
will suggest several.
Or, you could at least start with one that is most surely non-crap:
http://www.perl.org/books/beginning-perl/
> Here is an excerpt:
No thanks, I watch the Colbert Report when I want laughs.
I've no time to laugh at the foolishness embodied in the
random thingie that you've stumbled upon.
>s...@netherlands.com <s...@netherlands.com> wrote:
>
>
>> I work for Google as a Perl manager.
>
>
>Pffft!
>
>Daydreaming of having a position is not actually the
>same as having acquired that position...
-sln
PES> "Uri Guttman" <u...@stemsystems.com> wrote in message
PES> news:87zlbh1...@quad.sysarch.com...
>>>>>>> "PES" == Paul E Schoen <pa...@peschoen.com> writes:
>>
>> as for you, how you are learning perl is bizarre given your claim to
>> know c and other langs. do you know shell at all? awk even? unix in
>> general? perl is best understood as being born of that environment
>> (including c) and stealing the best of breeds from each.
PES> I think I have a general aversion to languages that make
PES> assumptions about variables, and that includes JavaScript and
PES> VB. I know enough C and Delphi to make fairly complex Windows GUI
PES> applications that operate on a nearly real-time basis with serial
PES> communication and data analysis, and I use a version of C for
PES> some PIC projects, but mostly I use assembly.
then you have an aversion to most popular languages today. c is still
used and is useful but it isn't good for dynamic data which is what web
apps typically need.
PES> I don't know shell. I found this:
PES> http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
PES> I have seen awk programs. I am not familiar with the syntax.
PES> I know a few unix commands and I have used FTP and Telnet, but
PES> that's about it. It seems similar to MSDOS but with more powerful
PES> features (like grep).
what rock did you live under if you think unix is ftp and telnet? do you
still code on punch cards? i gave that up in 1975.
PES> I think it will not be worth it for me to learn enough Perl to do
PES> even the simple things I may want to do. I should probably just
PES> hire an expert or use some canned scripts and web apps, and stick
PES> with what I know.
your choice but don't hack it if you don't want to learn it. canned apps
are hit or miss and you won't know enough to know if they are any
good. and changing them still requires some programming skill in the
language.
s> I work for Google as a Perl manager. Don't let your resume pass my desk!
even funnier since they use little perl. mostly python and other stuff.
and wtf is a perl manager? in any company, that would be a strange
title.
>>>>>> "PES" == Paul E Schoen <pa...@peschoen.com> writes:
>
> PES> "Uri Guttman" <u...@stemsystems.com> wrote in message
> PES> news:87zlbh1...@quad.sysarch.com...
> >>>>>>> "PES" == Paul E Schoen <pa...@peschoen.com> writes:
> >>
> >> as for you, how you are learning perl is bizarre given your claim to
> >> know c and other langs. do you know shell at all? awk even? unix in
> >> general? perl is best understood as being born of that environment
> >> (including c) and stealing the best of breeds from each.
>
> PES> I think I have a general aversion to languages that make
> PES> assumptions about variables, and that includes JavaScript and
> PES> VB. I know enough C and Delphi to make fairly complex Windows GUI
> PES> applications that operate on a nearly real-time basis with serial
> PES> communication and data analysis, and I use a version of C for
> PES> some PIC projects, but mostly I use assembly.
>
>then you have an aversion to most popular languages today. c is still
>used and is useful but it isn't good for dynamic data which is what web
>apps typically need.
WTF is a Web App, lol !!!!
There it is, throw away C++, no need for that when you got Perl.
Do they raise these pigs on Iowa corn or what?
-sln
>>>>>> "s" == sln <s...@netherlands.com> writes:
>
> s> On Mon, 06 Jul 2009 17:10:07 -0400, Uri Guttman <u...@stemsystems.com> wrote:
> >>>>>>> "s" == sln <s...@netherlands.com> writes:
> >>
> s> On Mon, 06 Jul 2009 17:05:02 -0400, Uri Guttman <u...@stemsystems.com> wrote:
> >> >>>>>>> "PES" == Paul E Schoen <pa...@peschoen.com> writes:
> >> >>
> >> >> as for you, how you are learning perl is bizarre given your claim to
> >> >> know c and other langs. do you know shell at all? awk even? unix in
> >> >> general? perl is best understood as being born of that environment
> >> >> (including c) and stealing the best of breeds from each.
> >>
> s> Whats your claim, apparently you know everything, sort of a jack-off
> s> of all trades.
> >>
> >> i know enough to not help you get a perl job. that is all i need to
> >> know.
> >>
> >> uri
>
> s> I work for Google as a Perl manager. Don't let your resume pass my desk!
>
>even funnier since they use little perl. mostly python and other stuff.
>
>and wtf is a perl manager? in any company, that would be a strange
>title.
>
>uri
We at Google do %95 Perl, us managers make sure the applicants know that.
-sln
PES> Sorry for the noobish questions, but I am used to C and Delphi
PES> Pascal, where I am familiar with the syntax.
It's not the syntax you're having trouble with, it's the semantics.
Perl doesn't have strongly typed variables the way the languages you
insist on comparing it with do.
A scalar holds one data value, such as a string or a number. If you
treat a scalar as if it has a number in it, Perl will do its best to
interpret that scalar as a number. If you treat a scalar as if it has a
string in it, Perl will do its best to interpret that scalar as a
string.
So yes, you can say $x = "57"; and Perl will dutifully put the string
"57" into $x. Then, when you say $y = $x + 7; Perl will interpret $x as
if it contains a number and add 7 to it. And then, when you say print
$y; -- well, Perl will convert $y to a string to print it for you.
Charlton
--
Charlton Wilbur
cwi...@chromatico.net
Total confusion. A vaiable contains a value that is typed. How you
use it depends on its TYPE not visa versa. Don't go down that road
with a C person.
Do give C people credit for knowing what a Union is. Because, that
is what Perl uses.
You obviously, never, ever, programed in a structured language.
If you did, describe Perl's actual usage to somebody who has.
And don't sugar coat, and lay off beginner crap, superiority shit
you and others keep foaming about via insinuation.
And since PERL is actually written upon C, try to learn it.
I realize you don't know C/C++, or structured language, but
try to make it sound like you do, at least.
-sln
sln> Total confusion. A vaiable contains a value that is typed. How
sln> you use it depends on its TYPE not visa versa. Don't go down
sln> that road with a C person.
You appear to be the one who's confused; if your assertion here is to be
believed, then saying something like:
$x = "42";
print $x + 7;
would result in a type mismatch error of some sort.
The values in scalars do have types, but the value and the type are
implicitly converted whenever it's appropriate. It's a lot less
confusing if you don't worry about the implicit type and value
conversion until you get a grasp on the basics, just as it's a lot less
confusing if you don't worry about reference counts and garbage
collection until you get a grasp on the basics.
sln> Do give C people credit for knowing what a Union is. Because,
sln> that is what Perl uses.
Except that it's a good deal more complicated than that, and explaining
it at that level is not likely to make things any clearer.
Consider:
union foo
{
int i;
char *str;
};
struct foo x;
If I then say
x.i = 27;
I can't then say
printf ("%s", x.str);
and expect to see a nice neat 27.
Likewise, I can't say
x.str = malloc (20);
strcpy (x.str, "27");
printf ("%d", x.i + 3);
and expect to see a nice neat 30.
Explaining scalars to a C programmer as if they were unions is unlikely
to be productive because the resemblance is only superficial. If he
understands unions well, the differences are going to trip him up far
more than the similarities are going to help him, and if he does not
understand unions well, then it's just going to confuse him further.
sln> You obviously, never, ever, programed in a structured language.
sln> If you did, describe Perl's actual usage to somebody who has.
Perl's implementation details are irrelevant to someone working at the
level of the original poster, and they're unlikely to help him
understand the language itself.
And what you seem to think is obvious is, frankly, wrong. This should
be obvious to most of the people who have read your postings, but it
doesn't hurt to reiterate it.
sln> And since PERL is actually written upon C, try to learn it. I
sln> realize you don't know C/C++, or structured language, but try
sln> to make it sound like you do, at least.
What you "realize" is utter nonsense; among other things, if you had the
remotest clue about either C or C++ you'd realize that calling it
"C/C++" shows idiocy to the C aficionados that's roughly comparable to
the idiocy you demonstrate by calling Perl "PERL."
And given your confusion about how Perl implements its data structures
internally -- they're structs, not unions -- and your misconception that
Perl scalars are usefuly analogous to C unions, I daresay I most likely
have a better grasp of C than you do.
I think I understand. But I don't like it. I am really more used to Delphi,
where it is easy to concatenate strings such as '5'+'7' := '57';
> Total confusion. A vaiable contains a value that is typed. How you
> use it depends on its TYPE not visa versa. Don't go down that road
> with a C person.
>
> Do give C people credit for knowing what a Union is. Because, that
> is what Perl uses.
My understanding of a Union is allowing a certain block of memory to be
interpreted in more than one way. So an integer of 32 bits may also be
addressed as an array of bytes, or a multipart record may also be addressed
as a single string. It is essentially a predefined typecast. I really have
not used it often, and it's done differently in Delphi, which uses a Case
statement to refer to the same data in different ways.
But a string in C, such as "1234", will always be just four ASCII
characters, and a NULL terminator. You use a function like atol() or atoi()
or atof() to assign the result to a numerical variable in a different
memory space.
Now a Variant may hold various kinds of information, and is used when the
data type is known only at runtime. But once it is set to a specific type,
it remains as such until explicitly reassigned to another type with new
data. It is essentially a pointer to an object that is created at runtime.
In Perl I don't know enough about the internals, but since it is
essentially an interpreted language it may perform its interpretations of
the data type on the fly, by applying appropriate conversions, or perhaps
the data is stored in a structure which contains parts that are string,
integer, and floating point.
Paul
Right.
And in Perl those types are scalar, array, hash, file handle, and
directory handle (did I forget any?).
> sln>How
> sln> you use it depends on its TYPE not visa versa.
Right. In general you cannot use e.g. an array instead of a file handle.
Now, what does that have to do with the numerical versus the string
versus the boolean value of a scalar?
> sln> Do give C people credit for knowing what a Union is. Because,
> sln> that is what Perl uses.
>
>Except that it's a good deal more complicated than that, and explaining
>it at that level is not likely to make things any clearer.
Actually it is WAAAAYYY easier than that. Perl has scalars.
And when used in numerical context then the numerical value of the
scalar will be used, when in string context then the string value will
be used, when in boolean context then the boolean value will be used.
That's it. Nothing compicated about it unless you insist on making it
complicated.
And it has nothing whatsoever to do with a union in C. And scalars
aren't implemented using C unions (set sum in mathematics), either.
Actually quite the opposite, they are more like a struct in C (cross
product in mathematics), where the system ensures that the different
representation of the value (numerical, text, ...) are automatically
kept in sync with each other whenever needed.
jue
PES> I think I understand. But I don't like it. I am really more
PES> used to Delphi, where it is easy to concatenate strings such as
PES> '5'+'7' := '57';
You can concatenate strings in Perl too; it uses the . operator.
sln> Do give C people credit for knowing what a Union is. Because,
sln> that is what Perl uses.
PES> My understanding of a Union is allowing a certain block of
PES> memory to be interpreted in more than one way.
...which is *not* what a Perl scalar is. sln is tragically confused,
and probably best ignored.
PES> In Perl I don't know enough about the internals, but since it
PES> is essentially an interpreted language
Er, no. Perl is compiled to an intermediate representation, which is
then executed. It's no more "essentially an interpreted language" than
Java is -- the principal difference is that you can store the
intermediate representation in Java, and you can't in Perl.
You *really* need to get yourself a good basic book on Perl. Beginning
Perl is available online for free at
http://www.perl.org/books/beginning-perl/, and odds are good that it's
better than any other tutorial you're likely to find free online. Work
through it -- if you're an experienced programmer with a clue, it will
go quickly, and you'll spare yourself a lot of the fumbling around that
you're doing now.
Well, I'd rather rephrase this as
Then, when you say $y = $x + 7; Perl will determine the numerical value
of $x and add 7 to it. And then, when you say print
$y; -- well, Perl will determine the string value of $y and print it for
you.
This "determine the xxx value of" doesn't change the value of the
scalar. It just creates (and actually even stores for later re-use) an
additional representation of that value in the scalar data item.
>I think I understand. But I don't like it. I am really more used to Delphi,
>where it is easy to concatenate strings such as '5'+'7' := '57';
What's the problem? In Perl you use + to add numbers and . to
concatenate strings:
my $foo = '5' . '7';
It's just a different operator (. instead of +).
>In Perl I don't know enough about the internals, but since it is
And you don't have to. Just remember that in Perl a scalar always has a
numerical, a string, a float, a boolean value and Perl will
automatically choose the right representation for the task at hand.
>essentially an interpreted language it may perform its interpretations of
>the data type on the fly, by applying appropriate conversions, or perhaps
>the data is stored in a structure which contains parts that are string,
>integer, and floating point.
Both.
jue
A Perl variable is probably most closely related to a structure.
I achieved my intended purpose. C programmer, now u know and have
some respect.
Good luck!
-sln
> sln is tragically confused,
That is no news at all.
>and probably best ignored.
which pretty much everyone does anyway.
jue
Tweedle de, tweedle dum, lol.
-sln
<http://lmgtfy.com/?q=web+app>
[...]
--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
>s...@netherlands.com writes:
>> On Mon, 06 Jul 2009 18:16:11 -0400, Uri Guttman <u...@stemsystems.com> wrote:
>[...]
>>>then you have an aversion to most popular languages today. c is still
>>>used and is useful but it isn't good for dynamic data which is what web
>>>apps typically need.
>>
>> WTF is a Web App, lol !!!!
>
><http://lmgtfy.com/?q=web+app>
>
>[...]
You know i won't explore any links anybody types here.
Wanna know why? Cause some jack-off like you points to a page that
will load my machine with a virus.
In lieu of a voice, I suggest you recant to yourself just exactly what
C/C++/api's writtine on them (fuckin all of them) are fucking good for
you moron.
-sln
format, subroutine
> sln is tragically confused,
> and probably best ignored.
Yet more good advice.
>Charlton Wilbur <cwi...@chromatico.net> wrote:
>
>> sln is tragically confused,
>> and probably best ignored.
>
>
>Yet more good advice.
No need to camp with a trojin. The walls are coming down.
-sln
De-cloaking Klingon eh.. Every assholes got em, nothing new,
"move on", "move on", "move on to offworld colony", "move on"...!
-sln
would better be written as:
>
> print ($date == $today) ? "Happy B.Day!\n" : "Happy Day!\n";
Really better?
# perl -cwe 'print ($date == $today) ? "Happy B.Day!\n" : "Happy Day!\n";'
print (...) interpreted as function at -e line 1.
Useless use of a constant in void context at -e line 1.
Useless use of a constant in void context at -e line 1.
Name "main::date" used only once: possible typo at -e line 1.
Name "main::today" used only once: possible typo at -e line 1.
-e syntax OK
Cheers
Heinrich
--
Heinrich Mislik
Zentraler Informatikdienst der Universitaet Wien
A-1010 Wien, Universitaetsstrasse 7
Tel.: (+43 1) 4277-14056, Fax: (+43 1) 4277-9140
Ok, fine. If you really want an answer to your question, go to
www.google.com and type "web app" into the search box, or do the
research in any other manner you like. And your accusation is
unfounded, untrue, and stupid. (I don't deny that some people would
post malicious links; I deny that I would do so or have done so,
and that you have any basis for assuming that I would or did.
> In lieu of a voice, I suggest you recant to yourself just exactly what
> C/C++/api's writtine on them (f***in all of them) are f***ing good for
> you moron.
Quoted text edited for content.
Plonk. (Since you probably won't look that up, it means I'm adding
you to my killfile and am unlikely to see anything you post in the
future.)
>s...@netherlands.com writes:
>> On Mon, 06 Jul 2009 18:26:21 -0700, Keith Thompson <ks...@mib.org> wrote:
>>>s...@netherlands.com writes:
>>>> On Mon, 06 Jul 2009 18:16:11 -0400, Uri Guttman
>>>> <u...@stemsystems.com> wrote:
>>>[...]
>>>>>then you have an aversion to most popular languages today. c is still
>>>>>used and is useful but it isn't good for dynamic data which is what web
>>>>>apps typically need.
>>>>
>>>> WTF is a Web App, lol !!!!
>>>
>>><http://lmgtfy.com/?q=web+app>
>>>
>>>[...]
>>
>> You know i won't explore any links anybody types here.
>> Wanna know why? Cause some jack-off like you points to a page that
>> will load my machine with a virus.
>
>Ok, fine. If you really want an answer to your question, go to
>www.google.com and type "web app" into the search box, or do the
>research in any other manner you like. And your accusation is
>unfounded, untrue, and stupid. (I don't deny that some people would
>post malicious links; I deny that I would do so or have done so,
>and that you have any basis for assuming that I would or did.
>
>> In lieu of a voice, I suggest you recant to yourself just exactly what
>> C/C++/api's writtine on them (f***in all of them) are f***ing good for
^^^ ^^^
>> you moron.
>
>Quoted text edited for content.
>
>Plonk. (Since you probably won't look that up, it means I'm adding
>you to my killfile and am unlikely to see anything you post in the
>future.)
Your a cartoon character from Toon Town. The more plonks the better,
as if silly little people like you who post on usenet from censured html
sites, who post nefarious one-line html links as a reply, mean jack shit to me.
I'm going to say it again. Everything WEB/ANYTHING api is written in assembly/C/C++.
Stop the bullshit and get your head out of your ass!!
-sln