Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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($&)) }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://21771]
[choroba]: talking about golfing, I did Pascal's triangle in 51 characters ;-)
[choroba]: and 99 bottles of beer in 217

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2017-10-22 20:10 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (275 votes). Check out past polls.