Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: On Interviewing and Interview Questions

by demerphq (Chancellor)
on Aug 26, 2005 at 15:59 UTC ( [id://486901]=note: print w/replies, xml ) Need Help??


in reply to On Interviewing and Interview Questions

Unix: What is the difference between a wild-card and a regular expression? Write the wildcard ls *.c as a regular expression in ls | grep 'put your regular expression here'.

I'd grin and point out that trick questions aren't very nice, then tell you that there is no difference. A wildcard is a regular expression, it just happens to have different syntax from the regular expressions you use in perl or grep. I'd also ask you which version of grep you meant, and enquire as to whether or not it supported PCRE or not.

And IMO this isn't a "unix" question, grep has been ported to just about every OS, and likewise just about every OS has ways of using regular expressions to query the file system.

PS: apologies, I just hate it when people put trick questions into tests. Like many people I'm not particularly good in test situations at all, and I dont need the stress of second guessing the question on top of trying to get the right answer while dealing with the stress of the test enviornment.

---
$world=~s/war/peace/g

  • Comment on Re: On Interviewing and Interview Questions

Replies are listed 'Best First'.
Re^2: On Interviewing and Interview Questions
by herveus (Prior) on Aug 26, 2005 at 18:03 UTC
    Howdy!

    When I was interviewed for the job I currently hold, my boss-to-be asked several questions from a list. The first was "what is grep". The others were similar in their difficulty.

    When I remarked (after the fifth or sixth such question) that these were not difficult questions, she noted that they were not easy for everyone!

    The questions were meant to smoke out someone whose actual skills and knowledge were markedly at odds with what the CV appeared to claim, and some of the candidates for my position were apparently Not Up To Snuff. The questions were not meant to be trick questions, or tough questions. If they were difficult, it was a bad sign for the candidate.

    yours,
    Michael
Re^2: On Interviewing and Interview Questions
by eyepopslikeamosquito (Archbishop) on Aug 26, 2005 at 20:28 UTC

    I'd grin and point out that trick questions aren't very nice, then tell you that there is no difference. A wildcard is a regular expression, it just happens to have different syntax from the regular expressions you use in perl or grep. I'd also ask you which version of grep you meant, and enquire as to whether or not it supported PCRE or not.
    You'd score points for answering back because I enjoy robust debate during an interview. However, I would argue that wildcards and regular expressions are quite different: they have different meta characters (*?[] versus \^$[].|()?*+{}) and with different meanings for those meta characters. Moreover, wildcards are used by the shell to match existing filenames, while regular expressions are not so constrained.

    Mentioning different grep (and shell) versions and PCRE is a plus. A bigger plus would be to write down:

    ls | grep '\.c$'
    and note that this should work with all greps and Unix shells.

      they have different meta characters (*?[] versus \^$[].|()?*+{}) and with different meanings for those meta characters. Moreover, wildcards are used by the shell to match existing filenames, while regular expressions are not so constrained.

      Ok, and this is why i consider this partially to be a trick question, Ie one that brings up much more complex issues that it appears you realize.

      To me the glob syntax is just an impoverished regular expression language. Even glob uses similar terms to describe it. Ie, a glob pattern can be directly converted to your regex language of choice. It lacks alternation and proper quantifiers, but that doesn't make it any less regular, just less useful (but of more predictable performance).

      Anyway, I doubt I would have been so bashful in an interview scenario, I probably would have had to ask you for some clarification. "What is the difference between a wild-card and a regular expression?" to me is a pretty dodgy question. "The" difference? Umm. Which wild-card syntax and which regular expression syntax. Do you mean perl style (ir)regular-expressions or what? The second part of the question I think i would have got :-)

      ---
      $world=~s/war/peace/g

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-18 13:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found