in reply to calling menu bar creating code from another cgi/pl code

i am generating all this web pages using Perl so can't I put menu bar code in separate file, and call it whenever required.

Sure you can :) you can do the same with frobnits.cgi/pagename ... Path::Dispatcher, CGI::Application::Dispatch

example :) run it (maybe  perl moannoy.pl daemon -l http://localhost:80/ ), click the links in your browser ....

#!/usr/bin/perl -- use Mojolicious::Lite; get '/' => { template => 'index', title => time };;; app->start; __DATA__ @@ index.html.ep <html> <head> <title><%= title =%></title> </head> <body> <h1><%= title =%></h1> <button onclick="annoying()"> hi </button> <a href="/annoying.js"> /annoying.js </a> %= javascript '/annoying.js' </body> </html> @@ annoying.js function annoying() { alert('hi'); }

or should i write a simple module

You should write that regardless -- doesn't have to be a real module, but each page should be a function DebugCGI

Replies are listed 'Best First'.
Re^2: calling menu bar creating code from another cgi/pl code (mojo)
by msinfo (Sexton) on Aug 27, 2013 at 06:44 UTC

    thanks anonymous monk

    i was actually looking some thing like as follows

    print $cgi->start_html(); # using ssi to call another code print '<!--#include virtual="/cgi-bin/menu.pl" -->'; # some similar cgi method to call above mentioned # perl / html file print $cgi->p("hello world"); print $cgi->end_html();

    i am currently against using any framework, because my production scale is not that much large, i am not well aware with mvc development pattern, and yes i am new to perl cgi.

Re^2: calling menu bar creating code from another cgi/pl code (mojo link_to)
by Anonymous Monk on Aug 28, 2013 at 03:09 UTC
    For portability (link relativity/portability) use url_for
    - <a href="/annoying.js"> /annoying.js </a> + %= link_to( ( "/annoying.js" ) x 2 )

    That is  link_to( "/annoying.js"  => "/annoying.js"  ), its perl after all :)