• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. How to call perl one-linear through system command in s...

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 143
  • Views 10979
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to call perl one-linear through system command in skill

saurabh96
saurabh96 over 4 years ago

Hi,

i have string box that contain realpath of file xyz.

setup_file_path = form->string_entry->value

now i want to remove lines from file that is starting from HELLO,EXAMPLE OR //.   I have written one-linear code from perl

system("perl -i.bak -ne 'print if !m{^(Hello|Example|//)}' setup_file_path")

but its not working and showing syntax errror

How to correct it?

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 4 years ago

    Assuming I have a file called "setup_file_path", it works for me. What's the syntax error?

    Presumably you really want to insert the actual file name - so are really intending to do something like this?

    system(strcat("perl -i.bak -ne 'print if !m{^(Hello|Example|//)}' " setup_file_path)

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • saurabh96
    saurabh96 over 4 years ago in reply to Andrew Beckett

    Hello Andrew,

    setup_file_path is not actual file its the variable which stored value of string field.

    when am running below code its,not showing any error but also not deleting the line which start with SOURCE,DESIGN,//

    system("perl -i.bak -ne 'print if !m{^(SOURCE|DESIGN|//)}' setup_path")   ;;;;;;;;;;;;;where

    setup_file_path = form->setup_Entry->value ;;;;;;;;;;;;setup_entry is the string field which stores the realpath of file xyz.

    is there any alternate way or how i can correct it.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 4 years ago in reply to saurabh96

    Did you read my previous reply? The variable will not get magically evaluated within a string - you have to build the string either using strcat or sprintf/lsprintf to insert the value in the right place. I showed the way of making this work with strcat in my previous reply...

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 4 years ago in reply to saurabh96

    Did you read my previous reply? The variable will not get magically evaluated within a string - you have to build the string either using strcat or sprintf/lsprintf to insert the value in the right place. I showed the way of making this work with strcat in my previous reply...

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
Children
  • saurabh96
    saurabh96 over 4 years ago in reply to Andrew Beckett

    Hi Andrew,

    am not very sure why this happening. when am trying 

    system(strcat("perl -i.bak -ne 'print if !m{^(Hello|Example|//)}' " setup_file_path) ;;;;;;;;;;;;where setup_file_path = form->string_entry->value

    it running clean without any error but not able to delete any line.

    although when am giving the direct file name i.e

    system("perl -i.bak -ne 'print if !m{^(SOURCE|DESIGN|//)}' run") ;;;;;;;;;;run is filename in pwd

    its working fine

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 4 years ago in reply to saurabh96

    Well, there's a missing close parenthesis in your code - not sure if that's it, but I would expect that to flag an error.

    If I have a file called "run" with this content:

    Hello
    Test
    Example
    Magic
    // this
    and
    // that

    and then do this (note, I fixed the missing close bracket):

    setup_file_path="run"
    system(strcat("perl -i.bak -ne 'print if !m{^(Hello|Example|//)}' " setup_file_path)) ;;;;;;;;;;;;where setup_file_path = form->string_entry->value

    this returns 0, and the file now contains:

    Test
    Magic
    and

    Presumably you've done something wrong somewhere - either the variable setup_file_path doesn't contain what you think it does (which should be easy enough for you to debug), or it was something to do with the brackets. Either of which ought to be the kind of thing you should be able to narrow down yourself; there's nothing magic about strcat versus a literal string.

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information