how to debug perl script

hi guys,
i have to perl script which has shell script extention like
script name is deploy.sh
#!/usr/local/bin/perl -w
# $Id: deploy.sh 1214 2007-04-04 19:45:36Z  $
# Testing


how to debug this script...i gave set -x but didn't work..
i don't understand this if you can explain me
 my ($product, $version) =  $filename =~  m!^(\w+)-(.+)-SNAPSHOT(?:.+) $!mxi or die "Here $filename";
parlepointAsked:
Who is Participating?
 
Adam314Commented:
If the file is a perl program, from the prompt:
    perl -w deploy.sh

Perl does not care what the extension of the file is.  Windows uses the extension to determine the type of a file, and what program to use for that file.  Unix does not the extension for anything.
0
 
Adam314Commented:
For general debugging, there is a perl debugger:
http://perldoc.perl.org/perldebug.html

In the statement you have above:
This part:
    my ($product, $version)
declares two variables, $product and $version.  It it not normally required to declare variables before use, but is generally considered good practice to add a "use strict" statement, which requires variable declaration.

This part:
    $filename =~ m!^(\w+)-(.+)-SNAPSHOT(?:.+) $!
Matches the variable $filename against a regular expression.  A regular expression is used for searching for patterns in strings.  See these pages for more on regular expressions:
    http://perldoc.perl.org/perlrequick.html
    http://perldoc.perl.org/perlretut.html
You can use this to get a description of a regular expression:
    print YAPE::Regex::Explain->new(qr!^(\w+)-(.+)-SNAPSHOT(?:.+) $!)->explain;
    in this case:
  ^                        the beginning of the string
----------------------------------------------------------------------
  (                        group and capture to \1:
----------------------------------------------------------------------
    \w+                      word characters (a-z, A-Z, 0-9, _) (1 or
                             more times (matching the most amount
                             possible))
----------------------------------------------------------------------
  )                        end of \1
----------------------------------------------------------------------
  -                        '-'
----------------------------------------------------------------------
  (                        group and capture to \2:
----------------------------------------------------------------------
    .+                       any character except \n (1 or more times
                             (matching the most amount possible))
----------------------------------------------------------------------
  )                        end of \2
----------------------------------------------------------------------
  -SNAPSHOT                '-SNAPSHOT'
----------------------------------------------------------------------
  (?:                      group, but do not capture:
----------------------------------------------------------------------
    .+                       any character except \n (1 or more times
                             (matching the most amount possible))
----------------------------------------------------------------------
  )                        end of grouping
----------------------------------------------------------------------
                           ' '
----------------------------------------------------------------------
  $                        before an optional \n, and the end of the
                           string
----------------------------------------------------------------------
)                        end of grouping
----------------------------------------------------------------------

This part:
    or die "Here $filename";
causes your program to die (exit with an error code and message) if the variable $filename doesn't match the pattern.
0
 
parlepointAuthor Commented:
thanks adam, problem with script has extension .sh if there is perl then i can do with -w option.
there is not any option in docs link which you send it to me.

if you have any idea about debug deploy.sh which has all perl language.
0
 
ajay_kanseCommented:
U can use perl -d <filename> ....This will give you a debugger prompt . You can stepin the programme by line . Hope that helps.
0
 
parlepointAuthor Commented:
Thanks Adam
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.