CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Meanigs of Expressions

 



per'l'over
Novice

Oct 18, 2008, 4:18 AM

Post #1 of 3 (2133 views)
Meanigs of Expressions 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


shawnhcorey
Enthusiast


Oct 18, 2008, 5:51 AM

Post #2 of 3 (2130 views)
Re: [per'l'over] Meanigs of Expressions [In reply to] Can't Post


In Reply To
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:

Code
{ 
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".


ruhi
New User

Nov 26, 2008, 7:54 AM

Post #3 of 3 (1957 views)
Script [In reply to] Can't Post

HI want to write a script that counts the no. of occurrences of alphabets in a file ignoring all spaces and punctuations marks...



Pls help me

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives