CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
" -> " in the syntax

 



jigneshjsoni
User

Mar 5, 2009, 3:12 PM

Post #1 of 6 (2456 views)
" -> " in the syntax Can't Post

if($q -> Accept("image/png"))

In this syntax, what does " -> " mean ? I have used only == or 'eq' for the comparison purpose. Pls explain this arrow symbol.


KevinR
Veteran


Mar 5, 2009, 3:38 PM

Post #2 of 6 (2454 views)
Re: [jigneshjsoni] " -> " in the syntax [In reply to] Can't Post

it means $q is an object and Accept() is a method of the object.

http://perldoc.perl.org/perlop.html#The-Arrow-Operator
-------------------------------------------------


jigneshjsoni
User

Mar 5, 2009, 4:51 PM

Post #3 of 6 (2452 views)
Re: [KevinR] " -> " in the syntax [In reply to] Can't Post

thanks. So its like q.accept() in java. I got it.

One more thing

print $q -> start_html(-title => "The Timr", -bgcolor => "#ffffff")

In this syntax, there is "-" before title and bgcolor, what does that mean ?

Can we have space between $q and -> , between -> and start_html ?

thanks


KevinR
Veteran


Mar 5, 2009, 5:46 PM

Post #4 of 6 (2450 views)
Re: [jigneshjsoni] " -> " in the syntax [In reply to] Can't Post

The dash before title and bgcolor is discussed in the CGI modules documentation.

You can have a space between the arrow operator -> and whatever is to the left or right of it, but its a bad habit to get into because there a situations where you can't have a space.
-------------------------------------------------


jigneshjsoni
User

Mar 5, 2009, 7:46 PM

Post #5 of 6 (2448 views)
Re: [KevinR] " -> " in the syntax [In reply to] Can't Post

How do I locate that in the documentation ? I am going through CGI.pm , its a looong documentation. I dont seem to find it.


KevinR
Veteran


Mar 5, 2009, 8:41 PM

Post #6 of 6 (2444 views)
Re: [jigneshjsoni] " -> " in the syntax [In reply to] Can't Post

CALLING CGI.PM ROUTINES

Most CGI.pm routines accept several arguments, sometimes as many as 20 optional ones! To simplify this interface, all routines use a named argument calling style that looks like this:
print $q->header(-type=>'image/gif',-expires=>'+3d');

Each argument name is preceded by a dash. Neither case nor order matters in the argument list. -type, -Type, and -TYPE are all acceptable. In fact, only the first argument needs to begin with a dash. If a dash is present in the first argument, CGI.pm assumes dashes for the subsequent ones
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives