Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: grep problems and file copying issues

by reptile (Monk)
on Jul 10, 2000 at 15:09 UTC ( #21771=note: print w/ replies, xml ) Need Help??


in reply to grep problems and file copying issues

The first argument to grep should be either an expression or a block of code, which evaluates to true or false depending on the value grep sets to $_ for each of the array. In other words, what you want is something like:

grep(/$cdLabel/o, @dbFile); # or the equivilant in a code block grep { /$cdLabel/o } @dbFile;

Since you're using the grep EXPR, ARRAY version of grep, it's trating $cdLabel as an expression which will always evaluate to true (unless of course $cdLabel contains a false value).

As for creating the backup, there doesn't seem to be anything wrong with the way you're doing it. However, you could look into the Shell module (comes in the standard distribution) which enables a set of shell commands portably within perl (like echo, cp, ps, etc), and then just cp($dbFileName, "$dbFileName.BAK");

But to each his own. What you have will work just fine.

local $_ = "0A72656B636148206C72655020726568746F6E41207473754A"; while(s/..$//) { print chr(hex($&)) }


Comment on Re: grep problems and file copying issues
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (14)
As of 2014-12-19 16:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (90 votes), past polls