Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Do you know where your variables are?
 
PerlMonks  

RE: Re: Useless Program

by BBQ (Curate)
on Jun 01, 2000 at 20:17 UTC ( [id://15894]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Useless Program
in thread Useless Program

You're obviously right about the regex, but would you need it in the first place? If your file looks like
foo bar baz
and the input is "foo\n", why would you want to:
  • chop input trailing \n
  • chop each line's trailing \n
  • regex on /^ AND $/??
am I missing something, or isn't it just easier to say $name eq $_ and leave it at that?

#!/home/bbq/bin/perl
# Trust no1!

Replies are listed 'Best First'.
RE: RE: Re: Useless Program
by btrott (Parson) on Jun 01, 2000 at 20:24 UTC
    No, you're right--in this case, that's much easier, faster, and better. I suppose I was just giving general advice (quoting meta-characters, not escaping $, etc.).

    Of course, the easiest would probably be just to use tie and a DBM, as was mentioned (and for which the code was even provided).

      Actually, you'd make a better teacher than myself. :)

      I was sticking strictly to the problem at hand, while you were expanding it and recommending good practices. I tend to have a very focused-on-the-job frame of mind when I read other people's code. I'll be as stupid as a debugger. At any rate, the DBM suggestion makes more sense anyway. I was just being picky.

      #!/home/bbq/bin/perl
      # Trust no1!
RE: RE: Re: Useless Program
by ivory (Pilgrim) on Jun 01, 2000 at 23:12 UTC
    Well...if you don't use ^ and $ it could match a name that includes the name you are searching for...for example if $name = 'bob' it would match bobbie, bobby, etc... Just a thought... --Amber

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://15894]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.