Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^5: Uninitialized value in concatenation (.) or string?

by starbolin (Hermit)
on May 11, 2008 at 00:18 UTC ( [id://685917]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Uninitialized value in concatenation (.) or string?
in thread Uninitialized value in concatenation (.) or string?

I am very sorry to dump on your code like that jbush82. I realize not everyone codes at the same level and I try to dole out the advice in digestible pieces but I let pc88mxer get under my skin and you got caught in the crossfire.

As to your code, have you implemented some of the other suggestions given to clean up your code?

Perl has powerful list operators map, grep shift, unshift, push and pop. Studying the perldocs for these would help to unleash the power of perl to you. One book that has a particularly good treatment of these is "Intermediate Perl" by Schwartz, d foy, and Phoenix. They explain list operators better that I ever could.

In general, to build and add or remove from lists use push, pop, shift and unshift. To change, diplay or copy every element of a list use map(). To create a new list with selected element of a previous list use grep(). Use foreach() if it is the side-effects of operations on the list that are important and use map() and grep() if it's the returned elements of the list that are important.

Any time, in your code, you need to search a collection of items based on a name you should be thinking hash. Perl's hash datatype provides a powerful and efficient method of storing named containers that would take at least a page of C code to emulate. See perldata and perlreftut

I wrote a similar piece of code to check the md5 hash on a list of files where I use some of the list operators. The code is written for unix and doesn't need to keep a list of matches as yours needs but I think the techniques used there would translate well to your requirements. Note particularly that no indexing variables are used.


s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}

Replies are listed 'Best First'.
Re^6: Uninitialized value in concatenation (.) or string?
by jbush82 (Novice) on May 11, 2008 at 06:32 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://685917]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-25 05:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found