
shawnhcorey
Enthusiast

Oct 18, 2008, 5:51 AM
Post #2 of 3
(1497 views)
|
|
Re: [per'l'over] Meanigs of Expressions
[In reply to]
|
Can't Post
|
|
1)($Progrm_name=$0)=~s@^.*/@@; 2)$chipcore = shift if $arg = /^chipcore// 3)$xml_utils::verbose = $verbose; 4) my $str = "$inst[0]($intf[0]) <-> $inst[1]($intf[1])\n @dbg_str 5) &xml_utils::std_error(&xml_utils::emsg("INTC_DIR_MIS", $str)) I would be very thankful if you explain bit clearly! Thanks u in advance No wonder you're having a hard time understand this; it's some of the most badly written Perl I have ever seen. (That means don't emulate them.) 1) ($Progrm_name=$0)=~s@^.*/@@; $0 is the path to the script. This is to get its name without any leading directories. A better way is: use File::Basename; $Progrm_name = basename( $0 ); 2) $chipcore = shift if $arg = /^chipcore// This won't pass the Perl compiler. Perhaps you mistyped it? I think it should be: $chipcore = shift @ARGV if $arg =~ /^chipcore/; or: $chipcore = shift @_ if $arg =~ /^chipcore/; Which one depends on if it's in a sub or not. Always add the array to a shift so its meaning is clear. 3)$xml_utils::verbose = $verbose; $xml_utils::verbose is a fully-qualified variable name. Fully-qualified variables consist of their package, two colons and their name. It also must be a global, introduced with `our` or `use vars...` By convention, all packages should start with a capital letter, like: $XmlUtils::verboase = $verbose; 4) my $str = "$inst[0]($intf[0]) <-> $inst[1]($intf[1])\n @dbg_str This line is incomplete and won't compile. Try: my $str = "$inst[0]($intf[0]) <-> $inst[1]($intf[1])\n @dbg_str\n"; The following does the same thing:
{ my $w = $inst[0]; my $x = intf[0]; my $y = $inst[1]; my $z = $intf[1] print "$w($x) <-> $y($z)\n"; print " @dbg_str\n"; } 5) &xml_utils::std_error(&xml_utils::emsg("INTC_DIR_MIS", $str)) Another compiler error. Try: &xml_utils::std_error(&xml_utils::emsg("INTC_DIR_MIS", $str)); This is two fully-qualified sub calls. The first is xml_utils::emsg and its results are used as parameters in xml_utils::std_error. The preferred way is: XmlUtils->std_error( $XmlUtils->emsg( 'INTC_DIR_MIS', $str )); __END__ I love Perl; it's the only language where you can bless your thingy. Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib. Get Markup Help. Please note the markup tag of "code".
|