Hi,
I am a newbie at PERL and really wanted to understand how server-side programming really works and operates since I use at the workplace. I use ASP and wanted to learn more about server-side programming since I am in the field of web design, development and multimedia.
Here are some tips and need some help how to program:
The way I learn is that I need an detailed explanation why and how we need use certain functions in PERL:
I wonder if there is a website that shows source code and detailed explanations that is easy to understand.
But anyway, I just need help how to program in PERL: Here are some tips and help on how to program: - #!/usr/bin/perl
-
-
=comment
-
The script assigns gen# accounts to a tab separated list of names and
-
id numbers provided at the bottom of the code under __DATA--
-
-
The following few lines explains some of the necessary syntax to
-
accomplish this task:
-
=cut
-
-
#The first two lines of the data below the __DATA__ syntax can be read with the following:
-
-
$line = <DATA>;
-
chomp $line;
-
print "first line: $line\n";
-
$line = <DATA>;
-
chomp $line;
-
print "second line: $line\n";
-
-
#The 'split' function is useful for splitting a string from a given character:
-
#In this case the username is being split from the number
-
#by specifying the tab in regexp notation (will learn later) in the first argument
-
#of the split function:
-
-
($name, $number) = split(/\t/, $line);
-
-
#You could use the following to read the whole list:
-
# the <DATA> command will keep reading one line at time until
-
# the internal pointer for <DATA> reads EOF, at which point,
-
# the 'while' loop is excausted
-
-
while ($line = <DATA>) {
-
print "line is: $line";
-
}
-
-
=comment
-
to do:
-
-
modify the while loop above to include a 'split' function to
-
separate the name from the number into a hash.
-
-
The hash should be designed to store the id number by using
-
the full name as key.
-
-
After populating the hash, save the keys (sorted) into an array.
-
The reason for saving the keys into an array is to help printing
-
a new list, sorted by name.
-
-
Print the hash data using a 'for' loop (use the loop index to generate the gen numbers)
-
and coordinating with the array to produce a sorted list in the following format:
-
-
gen1|Croft, Amy|4853
-
gen2|Fitzgerald, Brandon|7465
-
gen3|Fong, Ji-Men|2365
-
gen4|Fung, Kei Y.|8563
-
etc.
-
-
Last important example to demonstrate concatenation:
-
$gen = "gen" . $i; same as "gen3" if $i is equal to 3
-
-
Use the same technique to concatenate the data above, which is separated by 'pipes' (|)
-
-
=cut
-
-
__DATA__
-
Fong, Ji-Men 2365
-
Lwin, Pyi-Soe 2367
-
Lanferman, Alexander 3425
-
Wells, Shou 3669
-
Sira, Flavio 3756
-
Croft, Amy 4853
-
Todorova, Elina 5978
-
Han, Jason 6574
-
Tang, Michael 6892
-
Fitzgerald, Brandon 7465
-
Stout, John 8397
-
Fung, Kei 8563
-
Hoang, Hop 8657
-
Sundara, Rhama 9154
11 3179
Did you have a question? Is that your school/class/course work you have posted?
Did you have a question? Is that your school/class/course work you have posted?
i agree with KevinADC whats your question, and why post the howto
i don't think any one will get what you need unless you ask.
also have you tried to do this your self if so post some code, in code tags.
note: his question is in his post title.
The question may be in the title, but its a funny way to ask it. Usually its a good idea to reiterate the question in the body of the post.
Also, I doubt this code would even work. They are referencing a file handle (<DATA>), yet there is no open statement anywhere in the code. Where do they expect the file handle to come from?
Regards,
Jeff
The question may be in the title, but its a funny way to ask it. Usually its a good idea to reiterate the question in the body of the post.
Yes i agree with that,
and for his post i think his posted it from a website or something.
The question may be in the title, but its a funny way to ask it. Usually its a good idea to reiterate the question in the body of the post.
Also, I doubt this code would even work. They are referencing a file handle (<DATA>), yet there is no open statement anywhere in the code. Where do they expect the file handle to come from?
Regards,
Jeff
- while(<DATA>){
-
print;
-
}
-
__DATA__
-
these lines
-
will be printed
__DATA__ is a special token perl uses, <DATA> reads the text after __DATA__ in a perl script just like it would a regular file. For whatever reason it does not have to be opened before reading it. There is some discussion of its use here: http://perldoc.perl.org/SelfLoader.html
I wonder if there is a website that shows source code and detailed explanations that is easy to understand.
There are many such websites, google will find them for you. Try searching for:
perl beginner
perl tutorial
how to write perl programs
beginning perl
I guess this is not the right place to ask questions for a newbie at PERL here.
I'm trying to learn how to do a program that uses an external file such as a text that has names, ID numbers and their fictitious names. Also,I want to separate with | (pipes).
I am just new programming with PERL.
Do you know of websites that provide source code but at the same time has detailed explanations about it?
It's pretty challenging to program when I am a designer and have a strong background in design but need to keep pace of technology and the challenges of being a web developer.
I guess this is not the right place to ask questions for a newbie at PERL here.
I'm trying to learn how to do a program that uses an external file such as a text that has names, ID numbers and their fictitious names. Also,I want to separate with | (pipes).
I am just new programming with PERL.
Do you know of websites that provide source code but at the same time has detailed explanations about it?
It's pretty challenging to program when I am a designer and have a strong background in design but need to keep pace of technology and the challenges of being a web developer.
Read my previous post about using google. If you are new at perl you need to start from the beginning. The lesson you posted is several chapters into any beginners perl book.
It's pretty challenging to program when I am a designer and have a strong background in design but need to keep pace of technology and the challenges of being a web developer.
Perl is hardly considered keeping pace with web/internet technologies. Its one of the oldest programming languages to be used on the internet.
PHP is the language most designers with no programming experience would want to look at.
You can ask beginner questions here but this forum, and no forum, is the hold-my-hand-and-teach-me-perl forum.
I guess this is not the right place to ask questions for a newbie at PERL here.
I'm trying to learn how to do a program that uses an external file such as a text that has names, ID numbers and their fictitious names. Also,I want to separate with | (pipes).
I am just new programming with PERL.
Do you know of websites that provide source code but at the same time has detailed explanations about it?
It's pretty challenging to program when I am a designer and have a strong background in design but need to keep pace of technology and the challenges of being a web developer.
Try Googling the above in Kevin's Post you will find lots of them
Sorry Forgot to refresh
Note: May be deleted.
- while(<DATA>){
-
print;
-
}
-
__DATA__
-
these lines
-
will be printed
__DATA__ is a special token perl uses, <DATA> reads the text after __DATA__ in a perl script just like it would a regular file. For whatever reason it does not have to be opened before reading it. There is some discussion of its use here: http://perldoc.perl.org/SelfLoader.html
Wow, I did not know that. Nothing like a little light reading. Thanks for the quick lesson Kevin!
Regards,
Jeff
Sign in to post your reply or Sign up for a free account.
Similar topics
by: alex |
last post by:
Hi,
I am looking for a way to populate an HTML table from an external
local text file which looks like this:
DATE/TIME LAT. LON. DEPTH. ML....
|
by: Miguel Dias Moura |
last post by:
Hello,
i have an ASP.net / VB page with a Script (submitValues) and a Form.
1. The form has 20 input texts and a "Submit" button.
2. The script declares 20 variables. The value of each...
|
by: dibblm |
last post by:
I have a text file being created and need the values from the array that
gets created to populate my text file. I am new and not very good. Kinda
borrowing bits and pieces from here and there, so...
|
by: Karthik |
last post by:
I am trying to read Http request body values NOT form values
The content type is text/xml and its POST
I am posting data from Infopath to an asp.net page.
In ASP it works by just writing...
|
by: Preben Randhol |
last post by:
Hi
A short newbie question. I would like to extract some values from a
given text file directly into python variables. Can this be done simply
by either standard library or other libraries? Some...
|
by: vj |
last post by:
How i can populate all fileds dynamically in jsp page based on contents
found in xml file?
I have written jsp servlets and java class file.
i transferred automatic data from jsp to servlet then to...
|
by: vijendra |
last post by:
How i can populate all fileds dynamically in jsp page based on contents
found in xml file?I have written jsp servlets and java class file.
i transferred automatic data from jsp to servlet then to...
|
by: olaamussah |
last post by:
Hi, i just started learning perl which i would use for my uni. project unfortunately. Well, this is a simple user login page i tried to create but i cant get it to work. Can someone please check this...
|
by: Kelicula |
last post by:
Hello all. I have a problem which seems to make no sense to me.
Therefore I must be doing something wrong.
I am trying to populate an array using split with a regexe.
Here is the code (snippet...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |