Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^6: Regex help/ Lua parse

by marquezc329 (Scribe)
on Oct 27, 2012 at 18:52 UTC ( #1001222=note: print w/replies, xml ) Need Help??

in reply to Re^5: Regex help/ Lua parse
in thread Regex help/ Lua parse

Aaah. I see. It seems much more obvious to me with the reduced regexes. I've never used such extensive regexes and I think I may have been letting myself get overwhelmed and distracted by the length and complexity of these statements in comparison to the shorter more basic code I've been learning with. So in essence,
if (x = y) { print x; }
and, in simple situations
if (x = y) { print x; }
are ok, but
if (x = y) { print x; }
is not. In this stripped down form I can see how the last example, although interpreted properly by Perl, can look like a random  if (x = y) and an unrelated block of { print x; }. I'm not entirely sure of what kind of examples you are asking for, but from this node:
if ($Age < 13) && ($Age > 0)) { print "What are you doing here, $firstName? This Web site is strictly PG-13. Shame on you for being so naughty as to come here!"; } elsif ($Age < 18) && ($Age > 12)) { print "Not to long ago, we’d have have chased you away from our Web site. But now that you’re a teenager and mature enough for PG-13 materials, we’re glad to see you $firstName."; }
has the same qualities as my code and could be cleaned up (focusing on the indentation and curly braces) by saying:
if (($Age < 13) && ($Age > 0)) { print "content"; } elsif (($Age < 18) && ($Age > 12)) { print "content"; }
or even:
if (($Age < 13) && ($Age > 0)) { print "content"; } elsif (($Age < 18) && ($Age > 12)) { print "content"; }
Thank you again for taking time out to help me grasp the fundamentals. Please let me know if I am missing your point. I enjoy Perl (and learning programming in general) and feel I have been progressing rather quickly, but I want to squash bad habits and form a good foundation in style and understanding before moving to some of the more complex concepts and modules in Perl.

Replies are listed 'Best First'.
Re^7: Regex help/ Lua parse
by kcott (Chancellor) on Oct 28, 2012 at 07:42 UTC

    Another book you may be interested is Perl Best Practices Standards and Styles for Developing Maintainable Code. Amongst all its other good advice, this has an entire chapter devoted to guidelines for code layout.

    Be aware that this book provides guidelines; not rules. Also, as it was released in 2005, it won't make references to features added in more recent versions of Perl (perlhist provides a history of Perl releases, if you're interested).

    -- Ken

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1001222]
[james28909]: no matter how i prepare the paths. oh well. looks like ill just have to start wsl perl from scratch
[Corion]: james28909: You can get a list of all modules on your Windows Perl via the autobundle command in the cpan shell. But that likely lists many more modules than you actually want. I recommend a clear separation and installing modules on ...
[Corion]: ... both Perls separately. I use cpanfiles or Makefile.PL for that - listing all modules for an application there allows me to install them via cpanm . or cpan . automatically without any further interaction

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2018-05-23 17:21 GMT
Find Nodes?
    Voting Booth?