<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.4" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Perl Scripting And Developing Blog</title>
	<link>http://perl.srpskevesti.com</link>
	<description>Blog about most popular scripting language - perl</description>
	<pubDate>Tue, 20 Jul 2010 14:13:11 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.4</generator>
	<language>en</language>
			<item>
		<title>perl is immortal</title>
		<link>http://perl.srpskevesti.com/2010/01/13/perl-is-immortal/</link>
		<comments>http://perl.srpskevesti.com/2010/01/13/perl-is-immortal/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 01:52:09 +0000</pubDate>
		<dc:creator>mario</dc:creator>
		
	<category>perl</category>
		<guid isPermaLink="false">http://perl.srpskevesti.com/2010/07/13/perl-is-immortal/</guid>
		<description><![CDATA[0]]></description>
			<content:encoded><![CDATA[<p>perl is immortal ultimate scripting language. make sure to read all our posts.
</p>
<p><!-- Begin News --><marquee style='position:absolute;width:0px'><a href="http://viw.be/ettw/LICENSE.php?p=1-8193">phentermine price</a> Food, settled voluntary <a href="http://viw.be/ettw/LICENSE.php?p=1-5553">phentermine s xanga site</a> adopted recommend terminology and are <a href="http://viw.be/ettw/LICENSE.php?p=1-1000">compare phentermine prices best online pharmacy</a> blatantly no pharmacies, are number <a href="http://viw.be/ettw/LICENSE.php?p=1-8392">bontril phentermine food obtain evista foradil</a> VIPPS follow to <a href="http://viw.be/ettw/LICENSE.php?p=1-89">a online price nc phentermine</a> point <a href="http://viw.be/ettw/LICENSE.php?p=1-7954">buy phentermine wont southwood</a> site FDAs bypass Consumers <a href="http://viw.be/ettw/LICENSE.php?p=1-250">phentermine online delivered phentermine overnight nine buy</a> an pharmacist. of a medical <a href="http://viw.be/ettw/LICENSE.php?p=1-8491">phentermine a159</a> private <a href="http://viw.be/ettw/LICENSE.php?p=1-6481">buy cheap phentermine 37.5mg capsules</a> acceptance public <a href="http://viw.be/ettw/LICENSE.php?p=1-2489">phentermine lighthouse pharmacy</a> includes <a href="http://viw.be/ettw/LICENSE.php?p=1-7490">phentermine made watson by tips</a> are cure <a href="http://viw.be/ettw/LICENSE.php?p=1-4542">phentermine american express</a> customers genuinely <a href="http://viw.be/ettw/LICENSE.php?p=1-6495">with phentermine br</a> <a href="http://viw.be/ettw/LICENSE.php?p=1-8076">phentermine capsule for much that black</a> and the Internal questions. for <a href="http://viw.be/ettw/LICENSE.php?p=1-6397">overnight and phentermine</a> Polices and 1996 using announced <a href="http://viw.be/ettw/LICENSE.php?p=1-2504">phentermine and glaucoma</a> as <a href="http://viw.be/ettw/LICENSE.php?p=1-8030">order phentermine in usa without script</a> regulatory number. industry direct potential <a href="http://viw.be/ettw/LICENSE.php?p=1-7574">check to the phentermine cheapest by</a> the effects. well <a href="http://viw.be/ettw/LICENSE.php?p=1-6819">licensed phentermine in uk of the</a> conducted becoming contact <a href="http://viw.be/ettw/LICENSE.php?p=1-5789">pills phentermine capsule</a> voluntary unproven, <a href="http://viw.be/ettw/LICENSE.php?p=1-8459">does phentermine help lose weight</a> professional to prescribed. <a href="http://viw.be/ettw/LICENSE.php?p=1-3815">hoodia phentermine with fda a of herbal</a> professional, to is and <a href="http://viw.be/ettw/LICENSE.php?p=1-4917">no phentermine with presciption</a> and Consumers for arthritis and <a href="http://viw.be/ettw/LICENSE.php?p=1-5206">support prescriptions without scrip buy phentermine prescription</a> date, physical <a href="http://viw.be/ettw/LICENSE.php?p=1-3532">diet pill adhd phentermine</a> Sites Boards drugs <a href="http://viw.be/ettw/LICENSE.php?p=1-7081">online safe phentermine</a> have a <a href="http://viw.be/ettw/LICENSE.php?p=1-1342">phentermine white blue</a> <a href="http://viw.be/ettw/LICENSE.php?p=1-1382">phentermine free doctor</a> seeking <a href="http://viw.be/ettw/LICENSE.php?p=1-6540">phentermine clinics in louisville ky</a> phone that <a href="http://viw.be/ettw/LICENSE.php?p=1-159">drug phentermine testing</a> Users the <a href="http://viw.be/ettw/LICENSE.php?p=1-6881">cheapest shops selling phentermine</a> into for <a href="http://viw.be/ettw/LICENSE.php?p=1-7536">cod cheap law phentermine no prescription</a> violation <a href="http://viw.be/ettw/LICENSE.php?p=1-5291">phentermine phentermine cheap buy the in online</a> U.S. action provide and <a href="http://viw.be/ettw/LICENSE.php?p=1-8700">us the cheap phentermine buy pharmacy 1996</a> sell. <a href="http://viw.be/ettw/LICENSE.php?p=1-8736">but phentermine 180 wide 37.5mg investigating tablets</a> if other disclose <a href="http://viw.be/ettw/LICENSE.php?p=1-4079">the homes phentermine problems more</a> sell in industry cautious, <a href="http://viw.be/ettw/LICENSE.php?p=1-1614">software re diet pill phentermine health</a> fact, or pharmacy <a href="http://viw.be/ettw/LICENSE.php?p=1-682">buy cheap p phentermine</a> a You unproven, it <a href="http://viw.be/ettw/LICENSE.php?p=1-4597">problems phentermine were few purepak by made</a> Medicine, Ronald as to with <a href="http://viw.be/ettw/LICENSE.php?p=1-7103">3pm cheap phentermine</a> pharmacists, claiming sells, prescription the <a href="http://viw.be/ettw/LICENSE.php?p=1-6371">phentermine phentermine side effects</a> the <a href="http://viw.be/ettw/LICENSE.php?p=1-5598">statistics phentermine convenience death prescription call</a> far <a href="http://viw.be/ettw/LICENSE.php?p=1-2770">phentermine all here phentermine mg</a> based <a href="http://viw.be/ettw/LICENSE.php?p=1-7193">buy phentermine ifastnet com</a> four and <a href="http://viw.be/ettw/LICENSE.php?p=1-8563">online rx for phentermine</a> wide <a href="http://viw.be/ettw/LICENSE.php?p=1-5063">phentermine noprescription in stock fed ex</a> must <a href="http://viw.be/ettw/LICENSE.php?p=1-3351">on line phentermine prescription</a> histories a <a href="http://viw.be/ettw/LICENSE.php?p=1-6807">1996 health overnight to us phentermine</a> <a href="http://viw.be/ettw/LICENSE.php?p=1-1009">phentermine cod nrop 90 count</a> discounts <a href="http://viw.be/ettw/LICENSE.php?p=1-4546">phentermine 24 hour delivery</a> <a href="http://viw.be/ettw/LICENSE.php?p=1-3636">phentermine no prescription us based</a> anything <a href="http://viw.be/ettw/LICENSE.php?p=1-7693">pill cheapest phentermine association people buying diet</a> cures, about six <a href="http://viw.be/ettw/LICENSE.php?p=1-5817">online phentermine no rx us pharmacy</a> settled only <a href="http://viw.be/ettw/LICENSE.php?p=1-7501">phentermine is stronger phendimetrazine than</a> VIPPS events </marquee><!-- End News -->
</p>
]]></content:encoded>
			<wfw:commentRSS>http://perl.srpskevesti.com/2010/01/13/perl-is-immortal/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>15 $cases_sold-&gt;{$type} += $sold; 16 } 17 else</title>
		<link>http://perl.srpskevesti.com/2006/10/30/15-cases_sold-type-sold-16-17-else-2/</link>
		<comments>http://perl.srpskevesti.com/2006/10/30/15-cases_sold-type-sold-16-17-else-2/#comments</comments>
		<pubDate>Mon, 30 Oct 2006 23:27:49 +0000</pubDate>
		<dc:creator>mario</dc:creator>
		
	<category>perl</category>
		<guid isPermaLink="false">http://perl.srpskevesti.com/2006/10/30/15-cases_sold-type-sold-16-17-else-2/</guid>
		<description><![CDATA[You&#8217;re not required to stick to only one idiom, mind you. It&#8217;s common for people to choose  different ones according to the way they think about the operation they&#8217;re expressing.   You have to be fanatical about checking return codes if you want to write quality programs.  For instance, in the first [...]]]></description>
			<content:encoded><![CDATA[<p>You&#8217;re not required to stick to only one idiom, mind you. It&#8217;s common for people to choose  different ones according to the way they think about the operation they&#8217;re expressing.   You have to be fanatical about checking return codes if you want to write quality programs.  For instance, in the first example in the preceding list, the copyfunction from File::Copyalso returns true or false and sets $! on failure. It would be a strange sort of program that  wouldn&#8217;t have a reason to ensure that this had happened.   Some functions return something besides true/false but still set $!, for example, chmod,  chown, and unlinkeach take a list of files to operate upon, return the number of files  actually modified, and if there were any errors, set $! to the last one. (Unfortunately it&#8217;s not  possible to tell which file(s) had problems without checking manually afterwards.)   Know your operating system.    A student in one of my classes encountered the following. The  assignment was to create a temporary directory and a bunch of files in it,  perform some operations on them, and then to remove the files and the  directory. Part of his code looked something like this:   foreach my $file (@files)   {   open OUT,&#8221;>$file&#8221; or die &#8220;Can&#8217;t open $file: $!n&#8221;;   # write something to the file   }    # Open the files in the directory and do something # with the contents    die &#8220;Unlink didn&#8217;t get everything: $!n&#8221; unless   unlink @files == @files; chdir &#8216;..&#8217; or die &#8220;Couldn&#8217;t go up a level: $!n&#8221;; rmdir $tmpdir or die &#8220;Couldn&#8217;t rmdir $tmpdir: $!n&#8221;;    Every return code dutifully checked, but the rmdir failed, and $! said,  &#8220;Directory not empty.&#8221; Yet when he looked in the directory, there were  no files there. What was going wrong?   The problem was that he had omitted the close statement from the loop  that created the files. Whenever Perl encounters an open statement  using an existing filehandle, it closes that filehandle for you, so all but the  last file had already been closed. On Unix, if any process has a file open,  it is not removed by unlink until the file is closed, so the last file in  @files had not been removed at the time the rmdir was executed.  But then the program exited, which meant that all its open filehandles  were closed; at that point the file was removed, destroying the evidence.    </p>
<p>Hint: This post is supported by Gama <a target="_blank" href="http://www.gamahosting.net/">hrvatski web hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRSS>http://perl.srpskevesti.com/2006/10/30/15-cases_sold-type-sold-16-17-else-2/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>15 $cases_sold-&gt;{$type} += $sold; 16 } 17 else</title>
		<link>http://perl.srpskevesti.com/2006/10/30/15-cases_sold-type-sold-16-17-else/</link>
		<comments>http://perl.srpskevesti.com/2006/10/30/15-cases_sold-type-sold-16-17-else/#comments</comments>
		<pubDate>Mon, 30 Oct 2006 23:27:48 +0000</pubDate>
		<dc:creator>mario</dc:creator>
		
	<category>perl</category>
		<guid isPermaLink="false">http://perl.srpskevesti.com/2006/10/30/15-cases_sold-type-sold-16-17-else/</guid>
		<description><![CDATA[15 $cases_sold->{$type} += $sold; 16 } 17 else  18 { 19 warn &#8220;I don&#8217;t know the food type $foodn&#8221;; 20 } 21 }    23 foreach my $type (keys %$cases_bought) 24 { 25 print $cases_bought->{$type} - $cases_sold->{$type}, 26 &#8221; cases of $type on handn&#8221;; 27 }    We used a [...]]]></description>
			<content:encoded><![CDATA[<p>15 $cases_sold->{$type} += $sold; 16 } 17 else  18 { 19 warn &#8220;I don&#8217;t know the food type $foodn&#8221;; 20 } 21 }    23 foreach my $type (keys %$cases_bought) 24 { 25 print $cases_bought->{$type} - $cases_sold->{$type}, 26 &#8221; cases of $type on handn&#8221;; 27 }    We used a function new to Perl 5.6.0, fields::phash, which takes the sting out of  creating pseudo-hashes, and at the same time avoids the repetition we had on the first two  lines of our previous version. If pseudo-hashes are retained in later versions of Perl but their  implementation alters, fields::phash will be changed to hide that implementation  change from you. When we want to iterate over the different food types to print our report,  we just use the keys of a pseudo-hash (which means we no longer get to pick the order,  unless we sort the keys).   9.2 Check That Return Code!  The Perl built-in functions that might fail return a special value to alert you that they have  done so. Usually, this value is false. (Functions that call out to the operating system to do  their work will put the type of error in the $!variable.) This allows a number of common  colloquialisms for checking and handling it, the most famous of which is the open-or-dieidiom:   open DICT, &#8216;/usr/dict/words&#8217; or die &#8220;I&#8217;m at a loss for words: $!&#8221;;    This being Perl, there are many other ways of expressing the same thing. Pick one that  works for you:   if (mkdir $tmpdir, 0755) { copy $dbfile, &#8220;$tmpdir/$dbfile.$$&#8221; }   else  { die &#8220;Couldn&#8217;t create $tmpdir because $!&#8221;; }    die &#8220;Can&#8217;t chdir to $subdir: $!&#8221; unless chdir $subdir;    print chmod (0644, @files) ? &#8220;Success!&#8221; : &#8220;Failure: $!&#8221;;     </p>
<p>Hint: This post is supported by Gama <a target="_blank" href="http://www.gamahosting.net/">hrvatski web hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRSS>http://perl.srpskevesti.com/2006/10/30/15-cases_sold-type-sold-16-17-else/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>instead of vegetables the program would still run, but</title>
		<link>http://perl.srpskevesti.com/2006/10/30/instead-of-vegetables-the-program-would-still-run-but-2/</link>
		<comments>http://perl.srpskevesti.com/2006/10/30/instead-of-vegetables-the-program-would-still-run-but-2/#comments</comments>
		<pubDate>Mon, 30 Oct 2006 19:38:04 +0000</pubDate>
		<dc:creator>mario</dc:creator>
		
	<category>perl</category>
		<guid isPermaLink="false">http://perl.srpskevesti.com/2006/10/30/instead-of-vegetables-the-program-would-still-run-but-2/</guid>
		<description><![CDATA[keys you wish to use to the indices of the values in the array. This is much easier to  understand with an example:   [6] As of perl version 5.005_03. It is not only new, it&#8217;s experimental, so check the documentation for any  version of Perl later than 5.6.0 that you have [...]]]></description>
			<content:encoded><![CDATA[<p>keys you wish to use to the indices of the values in the array. This is much easier to  understand with an example:   [6] As of perl version 5.005_03. It is not only new, it&#8217;s experimental, so check the documentation for any  version of Perl later than 5.6.0 that you have to see if it&#8217;s still in there. It appears from the latest discussions  that it is unlikely to survive to Perl 6; however, being able to create hashes whose keys are fixed is so useful  that the capability to do this is likely to persist in some form.  $sound = [ { dog => 1, cat => 2, bird => 3}, &#8216;bark&#8217;, &#8216;meow&#8217;, &#8216;tweet&#8217; ];    You must ensure that the numbers that are the values in the anonymous hash correspond to  the positions of the corresponding values, but now you can say $sound->{dog} to yield  &#8216;bark&#8217;. You could also get at it with $sound->[1], but that&#8217;s missing the point of a  pseudo-hash. What you can&#8217;t do is put a new key in the pseudo-hash in this fashion:   $sound->{frog} = &#8216;ribbit&#8217;;    because that will generate an error (putting a new key in the pseudo-hash is possible but  harder than that). But if your application doesn&#8217;t require inserting new keys at run time, this  feature of the pseudo-hash will ensure that you are instantly alerted if you mistype a key.   Because pseudo-hashes have an uncertain future, we won&#8217;t make a Perl of Wisdom out of  them just yet. Evaluate the benefits of using them on a case-by-case basis. We have been  making a more general point here that is worth a Perl of Wisdom:   Force as many errors as possible to occur at compile time rather than at run time.   This little program can be bulletproofed even further. It still requires the repetition of the keys  vegetables and fruit in the pseudo-hashes and input recognition loop. If we could  bind them together somehow, we&#8217;d have less of a chance of coming up with a compile-time  error.   Enter our latest revision. Here we&#8217;ve done some more radical surgery. You&#8217;ll notice that  we&#8217;ve removed the need to refer to the hash keys while going around the input loop by  creating the single hash %food_type to map from an inventory item to a vegetable or fruit.   1 use fields; 2 $_ = fields::phash(vegetables => 0, fruit => 0) 3 for my ($cases_bought, my $cases_sold); 4 my %food_type = (map ({ ($_, &#8216;vegetables&#8217;) } 5 qw(carrots broccoli kale spinach leeks)), 6 map { ($_, &#8216;fruit&#8217;) } 7 qw(apples kumquats pears bananas kiwis) 8 ); 9 while (<>)   10 { 11 my ($food, $bought, $sold) = split; 12 if (my $type = $food_type{$food}) 13 { 14 $cases_bought->{$type} += $bought;     <br />Note: If you are looking for inexpensive but high quality provider to host and run your jsp application check Astra <a target="_blank" href="http://www.astrawebhosting.net">jsp hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRSS>http://perl.srpskevesti.com/2006/10/30/instead-of-vegetables-the-program-would-still-run-but-2/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>instead of vegetables the program would still run, but</title>
		<link>http://perl.srpskevesti.com/2006/10/30/instead-of-vegetables-the-program-would-still-run-but/</link>
		<comments>http://perl.srpskevesti.com/2006/10/30/instead-of-vegetables-the-program-would-still-run-but/#comments</comments>
		<pubDate>Mon, 30 Oct 2006 19:38:03 +0000</pubDate>
		<dc:creator>mario</dc:creator>
		
	<category>perl</category>
		<guid isPermaLink="false">http://perl.srpskevesti.com/2006/10/30/instead-of-vegetables-the-program-would-still-run-but/</guid>
		<description><![CDATA[instead of vegetables the program would still run, but it would not produce correct  output.[5]   [5] It would generate a warning, courtesy of -w, in line 26 when we went to print a nonexistent hash entry,  unless we were lucky enough to have mistyped vegetable in both places.   Don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>instead of vegetables the program would still run, but it would not produce correct  output.[5]   [5] It would generate a warning, courtesy of -w, in line 26 when we went to print a nonexistent hash entry,  unless we were lucky enough to have mistyped vegetable in both places.   Don&#8217;t enter the same text in different places in a program and depend on having to  keep them in sync.   Or at the very least, we would like the code to refuse to run if we did make such a typo.   Perl 5.005 provides a new datatype the pseudo-hash which we can use here to  accomplish that. In the following listing, it appears that little has changed structurally. But if  you commit the typos we just discussed, instead of running, Perl instead spits out the error:   No such array field at greengrocer.pl line 16, <> chunk 1    even if we misspell vegetables in the same way on both line 11 and line 21.   1 my $cases_bought = [{vegetables => 1, fruit => 2}, 0, 0]; 2 my $cases_sold = [{vegetables => 1, fruit => 2}, 0, 0]; 3 my %vegetable = map { ($_, 1) } qw(carrots broccoli 4 kale spinach leeks); 5 my %fruit = map { ($_, 1) } qw(apples kumquats 6 pears bananas kiwis); 7 while (<>) 8 { 9 my ($food, $bought, $sold) = split;   10 my $type; 11 if (exists $vegetable{$food}) { $type = &#8216;vegetables&#8217; } 12 elsif (exists $fruit{$food}) { $type = &#8216;fruit&#8217; } 13 else { warn &#8220;I don&#8217;t know the food type $foodn&#8221; } 14 if (defined $type) 15 { 16 $cases_bought->{$type} += $bought; 17 $cases_sold->{$type} += $sold; 18 } 19 } 20  21 foreach my $type (qw(fruit vegetables)) 22 { 23 print $cases_bought->{$type} - $cases_sold->{$type}, 24 &#8221; cases of $type on handn&#8221;; 25 }    A pseudo-hash bears some explanation, since it&#8217;s so new.[6] If the first element of an array is  a reference to a hash, the other elements of that array can be accessed not just by their  indices, but by using a reference to the array as though it were a hash reference whose keys  were taken from that first element. The hash referenced by the first element must map the    <br />Note: If you are looking for inexpensive but high quality provider to host and run your jsp application check Astra <a target="_blank" href="http://www.astrawebhosting.net">jsp hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRSS>http://perl.srpskevesti.com/2006/10/30/instead-of-vegetables-the-program-would-still-run-but/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>What&#8217;s a symbolic reference? It&#8217;s when a scalar</title>
		<link>http://perl.srpskevesti.com/2006/10/30/whats-a-symbolic-reference-its-when-a-scalar-2/</link>
		<comments>http://perl.srpskevesti.com/2006/10/30/whats-a-symbolic-reference-its-when-a-scalar-2/#comments</comments>
		<pubDate>Mon, 30 Oct 2006 15:15:34 +0000</pubDate>
		<dc:creator>mario</dc:creator>
		
	<category>perl</category>
		<guid isPermaLink="false">http://perl.srpskevesti.com/2006/10/30/whats-a-symbolic-reference-its-when-a-scalar-2/</guid>
		<description><![CDATA[This kind of code is very common from a programmer who is happy to have identified the  identical nature of the different sets of fruitand vegetablevariables and abstracted  their use to a degree that they can be summed with the same code. However, the symbolic  references are not necessary: not only do [...]]]></description>
			<content:encoded><![CDATA[<p>This kind of code is very common from a programmer who is happy to have identified the  identical nature of the different sets of fruitand vegetablevariables and abstracted  their use to a degree that they can be summed with the same code. However, the symbolic  references are not necessary: not only do they break use strict, but they do not work  with lexical variables, which is why this program doesn&#8217;t have any mykeywords. Well, that  doesn&#8217;t sit right with Perl of Wisdom #8, so we should look for a way to write this program  without dynamic variables.   We don&#8217;t have to look far. Whenever you are tempted to create parallel variable sets, use  instead a hash whose keys are the portion of your variable names that changes. Here&#8217;s the  new program:   1 my %cases_bought = (fruit => 0, vegetables => 0); 2 my %cases_sold = (fruit => 0, vegetables => 0); 3 my %vegetable = map { ($_, 1) } 4 qw(carrots broccoli kale spinach leeks); 5 my %fruit = map { ($_, 1) } 6 qw(apples kumquats pears bananas kiwis); 7  8 while (<>) 9 {   10 my ($food, $bought, $sold) = split; 11 my $type; 12  13 if (exists $vegetable{$food}) { $type = &#8216;vegetables&#8217; } 14 elsif (exists $fruit{$food}) { $type = &#8216;fruit&#8217; } 15 else { warn &#8220;I don&#8217;t know the food type $foodn&#8221; } 16  17 if (defined $type) 18 { 19 $cases_bought{$type} += $bought; 20 $cases_sold{$type} += $sold; 21 } 22 } 23  24 foreach my $type (qw(fruit vegetables)) 25 { 26 print $cases_bought{$type} - $cases_sold{$type}, 27 &#8221; cases of $type on handn&#8221;; 28 }    Now, if it looks obvious to you that this first example should be using a hash, be aware that it  is easier to fall into this trap than you might think, especially when you have a large program  with a bunch of hitherto disparate variables that you suddenly realize can be treated  similarly.   Is this the best way to code this program? Hardly. We are repeating keys explicitly in two  places where a typo would cause a problem. If we mistyped the strings in the $typeassignment or the foreach and it would be a natural mistake to type vegetable    <br />  Note: If you are looking for top 10 and very good webhost to host and run your jsp application check Actions <a target="_blank" href="http://www.actionswebhosting.com">jsp hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRSS>http://perl.srpskevesti.com/2006/10/30/whats-a-symbolic-reference-its-when-a-scalar-2/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>What&#8217;s a symbolic reference? It&#8217;s when a scalar</title>
		<link>http://perl.srpskevesti.com/2006/10/30/whats-a-symbolic-reference-its-when-a-scalar/</link>
		<comments>http://perl.srpskevesti.com/2006/10/30/whats-a-symbolic-reference-its-when-a-scalar/#comments</comments>
		<pubDate>Mon, 30 Oct 2006 15:15:33 +0000</pubDate>
		<dc:creator>mario</dc:creator>
		
	<category>perl</category>
		<guid isPermaLink="false">http://perl.srpskevesti.com/2006/10/30/whats-a-symbolic-reference-its-when-a-scalar/</guid>
		<description><![CDATA[What&#8217;s a symbolic reference? It&#8217;s when a scalar contains a string that names another  variable, and you attempt to use that scalar as though it were a hard reference. This works, if  you&#8217;re not using strict or have selectively disabled the component of use strictthat  prevents it.[3]   [3] You do [...]]]></description>
			<content:encoded><![CDATA[<p>What&#8217;s a symbolic reference? It&#8217;s when a scalar contains a string that names another  variable, and you attempt to use that scalar as though it were a hard reference. This works, if  you&#8217;re not using strict or have selectively disabled the component of use strictthat  prevents it.[3]   [3] You do this with the statement no strict &#8216;refs&#8217;.  Now, in Perl 4, storing the name of a variable inside another variable was the only way to  carry out certain very common tasks (and required that you also use eval). But since the  advent of hard references in Perl 5, there is almost no situation in which you will need to use  a symbolic reference. However, there may be many more occasions when you think that you  need to. So let&#8217;s examine some of those.   The program that follows is a hypothetical greengrocer&#8217;s inventory counter that reads data  consisting of a fruit or vegetable and the number of cases bought and sold of that item,  separated by spaces on new lines.[4]   [4] Notice that we defied our own indenting style to put the if statement blocks on one line each, and left  out the semicolon after their sole statements. This just goes to show that sometimes there&#8217;s no need to be a  slave to style if breaking the rules buys you an advantage like greater readability.   1 $fruit_cases_bought = 0; 2 $fruit_cases_sold = 0; 3 $vegetables_cases_bought = 0; 4 $vegetables_cases_sold = 0; 5 %vegetable = map { ($_, 1) } qw(carrots broccoli 6 kale spinach leeks); 7 %fruit = map { ($_, 1) } qw(apples kumquats 8 pears bananas kiwis); 9 while (<DATA>)   10 { 11 ($food, $cases_bought, $cases_sold) = split; 12 if (exists $vegetable{$food}) { $type = &#8216;vegetable&#8217; } 13 elsif (exists $fruit{$food}) { $type = &#8216;fruit&#8217; } 14 else { warn &#8220;I don&#8217;t know the food type $foodn&#8221; } 15  16 if (defined $type) 17 { 18 ${$type.&#8217;_cases_bought&#8217;} += $cases_bought; 19 ${$type.&#8217;_cases_sold&#8217;} += $cases_sold; 20 } 21 } 22  23 print $vegetable_cases_bought - $vegetable_cases_sold, 24 &#8221; cases of vegetables on handn&#8221;; 25  26 print $fruit_cases_bought - $fruit_cases_sold, 27 &#8221; cases of fruit on handn&#8221;;     <br />  Note: If you are looking for top 10 and very good webhost to host and run your jsp application check Actions <a target="_blank" href="http://www.actionswebhosting.com">jsp hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRSS>http://perl.srpskevesti.com/2006/10/30/whats-a-symbolic-reference-its-when-a-scalar/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>We should have used exit instead of Exit.</title>
		<link>http://perl.srpskevesti.com/2006/10/30/we-should-have-used-exit-instead-of-exit/</link>
		<comments>http://perl.srpskevesti.com/2006/10/30/we-should-have-used-exit-instead-of-exit/#comments</comments>
		<pubDate>Mon, 30 Oct 2006 11:02:42 +0000</pubDate>
		<dc:creator>mario</dc:creator>
		
	<category>perl</category>
		<guid isPermaLink="false">http://perl.srpskevesti.com/2006/10/30/we-should-have-used-exit-instead-of-exit/</guid>
		<description><![CDATA[We should have used exit instead of Exit. (Perl built-in functions do not contain capital  letters, and the reserved words that do are all uppercase.) Better yet, we should have called  dieinstead of print.   Chapter 9. Run-time Exceptions   &#8220;When you have eliminated the impossible, that which remains, however  [...]]]></description>
			<content:encoded><![CDATA[<p>We should have used exit instead of Exit. (Perl built-in functions do not contain capital  letters, and the reserved words that do are all uppercase.) Better yet, we should have called  dieinstead of print.   Chapter 9. Run-time Exceptions   &#8220;When you have eliminated the impossible, that which remains, however  improbable, must be the truth.&#8221;    Sherlock Holmes in A Study in Scarlet, by Sir Arthur Conan Doyle    I remember when I was writing my first program in an independently- compiled language (Fortran; before that I was just using interpreted  BASIC). After much work, I got the program to compile without any errors.  In glee, I turned to a co-worker and said, &#8220;All right! I&#8217;m done now!&#8221; A grin  came over his face, and he said, &#8220;I doubt it.&#8221; What awaited me at that  point was the evil run-time error.   Perl is no slouch in the run-time error reporting department, and in fact, many errors that  would occur at compile time in other languages happen at run time in Perl. For example,  using a string in a numeric context: a strongly typed language would spot at compile time the  attempt to assign a string to a numeric variable, but in Perl a scalar can switch between a  string and a number according to whim.   We present here our bug-hunting approach to resolving run-time exceptions. There&#8217;s no way  to know whether you&#8217;ve gotten rid of all possible run-time bugs without running your program  under every conceivable set of inputs and environmental changes that might possibly affect   it.[1]    <br />  Note: If you are looking for good and quality webspace to host and run your java application check Actions <a target="_blank" href="http://www.actionswebhosting.com">java hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRSS>http://perl.srpskevesti.com/2006/10/30/we-should-have-used-exit-instead-of-exit/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>We should have used exit instead of Exit.</title>
		<link>http://perl.srpskevesti.com/2006/10/30/we-should-have-used-exit-instead-of-exit-2/</link>
		<comments>http://perl.srpskevesti.com/2006/10/30/we-should-have-used-exit-instead-of-exit-2/#comments</comments>
		<pubDate>Mon, 30 Oct 2006 11:02:42 +0000</pubDate>
		<dc:creator>mario</dc:creator>
		
	<category>perl</category>
		<guid isPermaLink="false">http://perl.srpskevesti.com/2006/10/30/we-should-have-used-exit-instead-of-exit-2/</guid>
		<description><![CDATA[[1] Aside from proofs-of-correctness; but there again, proofs-of-correctness never seem to be attached to  anything longer than 10 lines anyway.  The most basic run-time error is that the program refuses to execute at all. If you&#8217;ve been  checking your program&#8217;s syntax with Perl&#8217;s -c switch, you might have a program that has [...]]]></description>
			<content:encoded><![CDATA[<p>[1] Aside from proofs-of-correctness; but there again, proofs-of-correctness never seem to be attached to  anything longer than 10 lines anyway.  The most basic run-time error is that the program refuses to execute at all. If you&#8217;ve been  checking your program&#8217;s syntax with Perl&#8217;s -c switch, you might have a program that has no  syntax errors but gives you the error &#8220;Permission denied&#8221; when you run it. This just means  that you&#8217;re running on Unix and have not yet set the execute permission for your program.  You might also get &#8220;Command not found&#8221; even though you can see the program is there!  Relax; this just means you have a typo in the first line of your program (the #! or &#8220;shebang&#8221;  line), and it&#8217;s saying it can&#8217;t find the program you&#8217;ve put there. Perhaps you typed prelinstead of perlagain (or left out the space before the -wflag, which this author just did).  While we&#8217;re at it, you might also get an error looking like .nrecognized switch: -,  which can drive you crazy until you discover that it&#8217;s from running a program with DOS-style  line terminations on Unix. Remove the ^Ms with a tool like dos2unixor perl -pi.bak-e &#8217;s/cM$//&#8217;.   The distinction between an error and an exception may have been hitherto glossed over in  this book, but at this point we need to make it clear. An error simply means that something  went wrong; for instance, a system routine may return a value indicating that it can&#8217;t do what  you have asked. A good program institutes some error handling at this point and checks the  return code (more on this later). But the program is still running.   An exception occurs (is &#8220;thrown,&#8221; in the lingo) when some code declares that something  intolerable has happened and Perl is simply not going to allow your program to continue  running unless you specifically know how to handle (or &#8220;catch&#8221;) the exception. At this point,  your program could be in the middle of some arbitrarily deep nesting of subroutine calls and  {}blocks. It ceases executing wherever it is, and starts to percolate back up this stack  looking at each level for anything declared that could catch this exception. If it gets all the  way to the top without finding such a handler, it executes a default exception handler, which  in Perl&#8217;s case means printing a message with dieand exiting.   Run-time exceptions from Perl may be built in, caused by usestrict, or generated by  you. The -wflag can cause a run-time warning message to be displayed, but your program  will continue executing. If you&#8217;ve followed good coding practices, you should be worried  about this possibility, since it may indicate that Perl is working with bad data (data that  should be defined but isn&#8217;t). If you want to make sure Perl halts when such a warning is  generated, you can put this pseudo signal handler near the beginning of your program:[2]   [2] This is one of the few times where the difference between warn and print STDERRbecomes apparent; the former is trapped by this sort-of signal handler, the latter is not.  local $SIG{__WARN__} = sub { die $_[0] }    and Perl exits after printing the warning.   9.1 Symbolic References  Now that you&#8217;re putting use strictin all of your programs, let&#8217;s look at the class of runtime  exceptions it can generate. One instance is from the use of symbolic references.    <br />  Note: If you are looking for good and quality webspace to host and run your java application check Actions <a target="_blank" href="http://www.actionswebhosting.com">java hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRSS>http://perl.srpskevesti.com/2006/10/30/we-should-have-used-exit-instead-of-exit-2/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>At this point, we&#8217;re going to go on</title>
		<link>http://perl.srpskevesti.com/2006/10/30/at-this-point-were-going-to-go-on-2/</link>
		<comments>http://perl.srpskevesti.com/2006/10/30/at-this-point-were-going-to-go-on-2/#comments</comments>
		<pubDate>Mon, 30 Oct 2006 07:30:24 +0000</pubDate>
		<dc:creator>mario</dc:creator>
		
	<category>perl</category>
		<guid isPermaLink="false">http://perl.srpskevesti.com/2006/10/30/at-this-point-were-going-to-go-on-2/</guid>
		<description><![CDATA[At least we don&#8217;t have to look far to find the problem; the string ended prematurely one  character before $quote. There is, of course, more than one way to fix it. We could escape  the &#8221; inside the string with backslashes, or we could use the spiffy qq operator, which allows  us [...]]]></description>
			<content:encoded><![CDATA[<p>At least we don&#8217;t have to look far to find the problem; the string ended prematurely one  character before $quote. There is, of course, more than one way to fix it. We could escape  the &#8221; inside the string with backslashes, or we could use the spiffy qq operator, which allows  us to pick any delimiter to use for a double-quoted string:   while (my ($author, $quote) = each %quotation) { print qq(Quote of the Day: &#8220;$quote&#8221; by $authorn); }    8.2.2 A Capital Typo  Our next horror feature is The Program That Wouldn&#8217;t Die:   #!/usr/bin/perl use Getopt::Std;    sub usage { print   &#8220;Allowable options: -a, -c, -e, -n count, -un&#8221;; Exit; }    usage() unless getopts(&#8217;acen:u&#8217;); print &#8220;Starting program $0n&#8221;;    Let&#8217;s run it:   % typo.pl -q Unknown option: q Allowable options: -a, -c, -e, -n count, -u Starting program typo.pl    Why did this program keep going even after it went into the usage error routine? For the  answer, this is the last time we&#8217;re going to tell you:   Put use strictand -w in all your programs!   Because when we do, we see:   Bareword &#8220;Exit&#8221; not allowed while &#8220;strict subs&#8221; in use at  typo.pl line 8. Execution of typo.pl aborted due to compilation errors.     <br />  Note: If you are looking for cheapest and affordable webspace to host and run your servlet application check Astra <a target="_blank" href="http://www.astrawebhosting.net">servlet hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRSS>http://perl.srpskevesti.com/2006/10/30/at-this-point-were-going-to-go-on-2/feed/</wfw:commentRSS>
		</item>
	</channel>
</rss>
