2 Replies - 807 Views - Last Post: 02 May 2010 - 01:13 AM

#1 chaitrahosmane   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 07-May 09

Perl Regular expressions

Posted 30 April 2010 - 08:35 AM

Hi,

I want to take regular expression as command line input for my script.
Example scriptname -dev nch* nch/nch_123 like that.
If i think i do not have getOpt:Regex module installed. So what is the best to way handle command line inputs regular expressions.?
Take the inputs as ARGV[0] ARGV[1] didn't solve my purpose.?
Please let me know how to process metacharacters as input through command line.

Thanks
chaitra

Is This A Good Question/Topic? 0
  • +

Replies To: Perl Regular expressions

#2 dsherohman   User is offline

  • Perl Parson
  • member icon

Reputation: 227
  • View blog
  • Posts: 654
  • Joined: 29-March 09

Re: Perl Regular expressions

Posted 01 May 2010 - 04:08 AM

You need to put quotes around any argument that contains shell metacharacters. When you enter the command
scriptname -dev nch* nch/nch_123

the shell sees "nch*" and replaces it with a list of all files in the current directory which start with the letters "nch" before starting up the script. Perl never gets a chance to see "nch*" (unless there are no matching files in the directory) because the shell has already expanded it into a list of filenames.
Was This Post Helpful? 1
  • +
  • -

#3 chaitrahosmane   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 07-May 09

Re: Perl Regular expressions

Posted 02 May 2010 - 01:13 AM

Hi, Thanks. It works :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1