Hello Asim,

> PROBLEM NO.1:
> IN PERL WHAT IS EQUIVALENT OF VB FUNCTION : Asc()

Please don't shout, I have a headache... :-)

Also, this is not a VB list. I don't even know what Asc() does in VB (though
I can guess), so please instead of asking us questions in the form

"I know how to do this in VB, how do I do it in Perl?"

please ask them in the form

"I am trying to achieve this, how should I go about it?"

Learning Perl when you know VB is like learning a new natural language: When
you try to translate literally from the old language to the new one, you get
bad translations that do not take advantage of the new language's special
constructs and grammar. If you tell us what you're trying to achieve
instead, we can teach you to eventually "think in Perl" and your code will
be more efficient (and most often shorter, too) because of that.

> PROBLEM NO.1:
> $string="My name is Asim Siddiqui.";
> while($i<=length($string)){
> $Alphabat = substr($string,$i,$i+1);
> }
> 
> WHATS WRONG IN THIS CODE THAT I CAN NOT ACHIEVE $Akphabat EQUAL TO EVERY 
> LETTER OF THE $string...

Try this:


<---------------------- snip ---------------------->
use strict;                     # Enforce some good programming practices
use warnings;           # Show warnings for common mistakes

my $string = "My name is Asim Siddiqui.";

my $character;
for (my $i = 0; $i < length $string; $i++) {
        $character = substr($string, $i, 1);
        print "The character no.$i is $character\n";
}
<---------------------- snip ---------------------->


Note the following in the above code:

1. use strict and use warnings will catch most common mistakes you can make
when starting to program in Perl (typos, etc).

2. When using strict, you need to declare variables with my (or other ways
which you'll learn about later).

3. You can declare and define a variable in the same statement, such as the
"my $string" line. I am declaring the variable $string, and assigning a
value to it at the same time.

4. Same thing for "my $i", but this shows you can do it in the start of a
for statement too. The $i variable lives only inside the for's brackets
(that's its "scope").

5. You can call functions without putting their arguments in parentheses in
Perl, as long as it doesn't cause precedence problems. It also makes your
code look more like natural language, so for example instead of
"length($string)" I used "length $string". But when in doubt, use
parentheses, especially when you don't know Perl's precedence rules yet...

6. Notice that substr's 3rd argument is the length of the substring to
extract, and not the index of the last character or something like that...
See the doc on substr (type "perldoc -f substr" at the command line) for the
details.

7. Finally, as you can see, you can put variables directly in strings (in
the print statement above) and Perl will interpolate and put the value of
the variable in its place automatically. That happens when using double
quotes, not single quotes.


To learn Perl, you need to read a lot. I suggest you read the perldoc for
any function you have doubts about, to learn how to use them. You can use
"perldoc -f function_name" to access the documentation of a given built-in
Perl function, like print or substr. perldoc is a wealth of documentation at
your fingertips, just browse till your heart's content! 

By the way, you may appreciate browsing the perldoc via the web -- see
www.perldoc.com or, if you have ActiveState Perl, go to your start menu, in
the ActiveState Perl folder, there is a Documentation icon that leads to
similar documents, only installed locally on your machine. I personally find
it easier to browse that way. You can click on links to call up another doc
page and see the relationships between things more easily.

> PROBLEM NO.3:
> IN PERL WHAT IS EQUIVALENT OF VB FUNCTION : RGB(RED,GREEN,BLUE)
> 
> PROBLEM NO.4:
> DOES ANYONE HAVE ANY PURE PERL CODE TO :
> 1) LOADING A BITMAP(FILE) TO A DC(or MEMORY DC)
> 2) SAVING THE CURRENT HDC IMAGE TO A FILE
> 
> PROBLEM NO.5:
> HOW TO DO THE WORK OF TRANSPARENTBLT(API) ON A PATH: Setting Pixel is a
bad 
> technique, try someting else...

Perl, at its core, is not made for graphical applications. There are many
modules that help you make some in Perl though (such as Tk, WxPerl, etc --
Google for details). You will need to choose one, install it via ppm or
CPAN, and then you can use it in your Perl programs. But again, you will
probably have to change the way you do some things, since the language and
the ways to access the functionality are very different between VB and Perl.

Try using these modules, or searching Google for some examples of work
similar to what you're trying to achieve. If you need help with specific
problems, don't hesitate to write to the list.

Good luck,


Jean-Sébastien Guay


_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to