Ravindra has asked for the wisdom of the Perl Monks concerning the following question:

Could you explain me the following statements.

  •     my $str = "$amap->{inst1}($amap->{sref1}) <-> $amap->{inst2}($amap->{sref2})";
  • while ($ARGV[0] =~ /^([\-+])/)#Tool usage:chipgen.pl -ipxact <conf> -c +hipcore <name> { $arg = substr(shift, 1); $chipcore = shift if $arg =~ s/^chipcore//; # what will be stored in $chipcore }
  •  print "$program_name: Processing hierarchy map: $hmap->{inst}::$hmap->{busif}\n";
  • my $str = "$imap->{inst1}($imap->{busif1}) <-> $imap->{inst2}($imap->{busif2})";

    I would be very thankful if you explain bit clearly! Thanks u in advance

  • Replies are listed 'Best First'.
    Re: Meanigs of Expressions
    by jethro (Monsignor) on Oct 18, 2008 at 12:31 UTC

      Please put code or c-tags ( <c> and </c> ) around your code

      The first line gets the name with which the script was started and throws away everything up to the last '/', i.e. any path components. s is a normal substitution regex, just with the delimiter '@' instead of '/'

      The second line has a syntax error (was it .../^chipcore/;' ? Maybe a result of you not using code tags). If the string $_ starts with the word chipcore, $arg is set to 1 and the first value of @ARGV (or in a subroutine @_) is shifted off and put into $chipcore

      Third and fifth line: Did you read the documentation of (probably) XML::utils ? If not, do it

      The fourth line interpolates some values into a string that probably continues after that, because there is no ending delimiter

    Re: Meanigs of Expressions
    by Illuminatus (Curate) on Oct 18, 2008 at 12:51 UTC
      This is not a forum for getting other people to do your homework for you.
    Re: Meanigs of Expressions
    by JavaFan (Canon) on Oct 18, 2008 at 11:31 UTC
      I would be very thankful if you format it a bit clearly!
    Re: Meanigs of Expressions
    by blazar (Canon) on Oct 19, 2008 at 12:13 UTC
      Could you explain me the following statements.

      I personally believe that if the above is a question, then it should end with a question mark. If it is a question, then the answer is yes! If you want me to also explain you "the following statements" then I'll do so only in the order given by:

      perl -MList::Util=shuffle -E "say shuffle 1..5"

      You have to work out which is which, so some work is left to you, since this is not a helpdesk:

      1. This is part of code assigning a string to a lexical variable which is declared in the same statement. But the string is not closed, which is the reason why it's only a portion of code - i.e. as such it is not valid Perl. The string also seems to contain code which resembles but is not Perl - it misses the correct statement separator and sports an unknown operator.
      2. Assignment of a variable's value to another variable. The variables have the same name but (supposedly) live in different packages. The package the variable being assigned to lives in has a name which follows the convention Perl assigns to pragmatas, but which also sound dubious in that role...
      3. A variable is assigned the full path to the program and then stripped of everything that precedes the last slash in it, including the latter.
      4. A sub is called on a sub which is called on a literal string and on a variable. Both subs are called the "old" way, which is nowadays deprecated.
      5. This is not valid Perl, but it would be if you remove a spurious slash. If you remove it, then a variable is assigned either the first command line argument or the first argument passed to a sub (depending on whether the expression is inside a sub or not) if the special variable $_ begins with a given string. (Upon assignement, if it takes place, either the @ARGV or @_ array gets shifted) But then it strongly smells like another error, and if it is then a tilde is missing somewhere to the effect that the assignement takes place if a generic variable, instead of $_, begins with that given string.
      --
      If you can't understand the incipit, then please check the IPB Campaign.