Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 12-20-2003, 08:47 PM   #1 (permalink)
Apodysophilia
Regular Contributor
 
Apodysophilia's Avatar
 
Join Date: Apr 2003
Location: noWhere, PA
Posts: 104
Apodysophilia is on a distinguished road
Send a message via AIM to Apodysophilia
paramerters in perl & an input problem

i just dont get it bah.
this works, i found a tut on it
Code:
#!/usr/bin/perl


sub test
{
	$temp = $_ for @_;
	print "the var is $temp";
}
	
test(34);
i dont knwo what the "$_ for @_ " does? and that only works for one argument. what if i want more?
and that doesnt work for text, how do i do it for text?

and
how do i terminate this. or/and is there a better way to get input from the keyboard?
Code:
@info = <STDIN>;

thanks for you time
Apodysophilia is offline   Reply With Quote
Old 12-21-2003, 09:47 AM   #2 (permalink)
Apodysophilia
Regular Contributor
 
Apodysophilia's Avatar
 
Join Date: Apr 2003
Location: noWhere, PA
Posts: 104
Apodysophilia is on a distinguished road
Send a message via AIM to Apodysophilia
ok,i figured out something, now i am just more confused
Code:
$temp = <> ;
also works for input, so what does STDIN stand/used for?

[edit]back to argurment, i kindof got it but sill am confused
Code:
sub test
{
	$temp = shift(@_) ;
	print "the add is $temp";
}
	
test(23);
what does the shift() do. and why does it have to be an array?
Apodysophilia is offline   Reply With Quote
Old 12-22-2003, 12:38 PM   #3 (permalink)
Apodysophilia
Regular Contributor
 
Apodysophilia's Avatar
 
Join Date: Apr 2003
Location: noWhere, PA
Posts: 104
Apodysophilia is on a distinguished road
Send a message via AIM to Apodysophilia
gah, i cant find a good explantion anywhere, anyone else care to help me out?
Apodysophilia is offline   Reply With Quote
Old 12-22-2003, 09:07 PM   #4 (permalink)
Epsilon
Regular Contributor
 
Epsilon's Avatar
 
Join Date: Mar 2003
Location: Las Vegas, NV
Posts: 127
Epsilon is on a distinguished road
$_ is a special variable that hold the value of STDIN if you don't assign STDIN to a variable.

@_ holds an array of all the values passed to a subroutine.

STDIN stands for Standard Input and it is used to get input from the keyboard (typically to prompt a user to type something). You don't have to specifically type STDIN. If you just use the angle brackets as in:
$temp = <>;
STDIN is implied as the default.

Shift returns the first value in an array and shortens the array by one element.
Code:
@arr = ('one','two','three');

$temp1 = shift(@arr);
$temp2 = shift(@arr);
$temp1 would be 'one' since that's the first element of the array. 'one' would also be removed from the array, so when we shift again, $temp2 is 'two' since that is now the first element of the array.
__________________
--Epsilon--
Epsilon is offline   Reply With Quote
Old 12-24-2003, 11:30 AM   #5 (permalink)
Apodysophilia
Regular Contributor
 
Apodysophilia's Avatar
 
Join Date: Apr 2003
Location: noWhere, PA
Posts: 104
Apodysophilia is on a distinguished road
Send a message via AIM to Apodysophilia
thanks, i got a book on it, and also after reading this i understand it more. thank you
Apodysophilia is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamic allocation..urgent help needed!!! kashif Standard C, C++ 4 04-21-2003 08:50 AM


All times are GMT -8. The time now is 11:26 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting