in reply to Re^4: Why can't I use s///
in thread Why can't I use s///

What do you mean with "does not work"?

Any errors? Which ones? Which messages? Any warnings? Which ones? Please be more specific with your error descriptions.

Spend some spaces, so you can visually separate inline comments from code, this may help to better see the "error"...

my $cgi = CGI->new; # Instantiate a +CGI class print $cgi->header, # First we creat +e a header $cgi->start_html('My first Perl website'), # Begin HTML pag +e $cgi->h1('Success'), # create the Tag + <h1>TEXT</h1> my $text="../files/jack/2012/derpone.pdf"; $text = basename($text); $cgi->p($text),
Your are printing a list of items:

And the print is done, as the semicolon behind my $text = "...path" terminates print's argument list.

The final $cgi->p($text); is executed in void context and therefor not printed!

Watch out where your commas and semicolons are!

But apart from the technical issue:

Why do you want to mix printing and (initializing and ) processing data?

Better do it step by step:

  1. Prepare your data,
  2. print your data.

Although one could mix it, I don't think it's a good idea to do so.

Keep it the way as your first example shows it (but spend some spaces as well).

edit: fixed ordered list