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

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]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (1)
As of 2018-05-27 23:38 GMT
Find Nodes?
    Voting Booth?