Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

creating a link

by ROB6789 (Novice)
on Mar 25, 2005 at 23:59 UTC ( [id://442434]=perlquestion: print w/replies, xml ) Need Help??

ROB6789 has asked for the wisdom of the Perl Monks concerning the following question:

in this code how would i make the word pyrite a link to say google.com ?
print "does your rock have the same metalic luster as gold? yes or no: + \n"; chomp($buck = <STDIN>); if ($sbuck eq 'yes') { print "your rock is pyrite\n"; } else { print "does your rock look like a thin metalic disk? yes or no?:\n"; chomp($buck2 = <STDIN>); if ($buck eq 'yes') { print "your rock is Mica.\n"; } else { print "is your rock purple? yes or no: \n"; } chomp($buck3 = <STDIN>); if ($buck3 eq 'yes') { print "your rock is amethyst.\n"; } else { print "is your rock jet black? yes or no: \n"; } chomp($buck4 = <STDIN>); if ($buck4 eq 'yes') { print "your rock is obsidian. \n"; } else { print "is your rock a translucent green? yes or no: \n"; } chomp($buck5 = <STDIN>); if ($buck5 eq 'yes') { print "your rock is flourite. \n"; } else { print "is your rock white with many green speckles in it? yes or no: \ +n"; } chomp($buck6 = <STDIN>); if ($buck6 eq 'yes') { print "your rock is sandstone. \n"; } else { print "is your rock greyish black with an amber luster? yes or no: \n" +; } chomp($buck7 = <STDIN>); if ($buck7 eq 'yes') { print "your rock is smoky quartz \n";} else { print "is your rock white with a really low hardness? yes or no: \n"; } chomp($buck8 = <STDIN>); if ($buck8 eq 'yes') { print "your rock is talc. \n"; } else { print "is your rock dull green? yes or no: \n"; } chomp($buck9 = <STDIN>); if ($buck9 eq 'yes') { print "your rock is aventurine. \n"; } else { print "is your rock pure white? yes or no: \n"; } chomp($dan = <STDIN>); if ($dan eq 'yes') { print "your rock is talc. \n"; } else { print "is your rock translucent with a pinkish tinge? yes or no:\n"; } chomp($dan2 = <STDIN>); if ($dan2 eq 'yes') { print "your rock is rose quartz. \n"; } else { print "your rock is mica schist.\n"; } } chomp($coolhuh = <STDIN>);

Replies are listed 'Best First'.
Re: creating a link
by crashtest (Curate) on Mar 26, 2005 at 00:20 UTC
    I don't know of any way to create a clickable link in a shell.

    Maybe as an alternative, you could provide a command a user can hit to open up a browser to a google search. For instance, this works on my MS-Windows box:
    use strict; use warnings; my $buck; print "does your rock have the same metalic luster as gold? yes or no: + "; chomp($buck = <STDIN>); if ($buck eq 'yes') { print "your rock is pyrite [Hit enter to quit, \"L\" and enter to se +arch Google] "; system('explorer "http://www.google.com/search?q=pyrite"') if (my $in = <STDIN> =~ /^L/i); }
    By the way, your 3rd line of code has a typo: if ($sbuck eq 'yes') should be if ($buck eq 'yes'). You would have caught this typo if you had started your script with use strict;, which is almost always a very good idea. In addition, your second test is using the variable $buck instead of $buck2 (line 11).

      Actually, you don't even need to use strict for that. Use warnings would have catched it too.

Re: creating a link
by The Mad Hatter (Priest) on Mar 26, 2005 at 00:08 UTC
    There's no standard way I know of since you're going to be using this program via a terminal of some sort. Some terminals will automatically link any plain URLs they find in output, but most don't.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://442434]
Approved by moot
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-16 12:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found