I have the following perl one-liner to convert /path/to/file.txt
to /path/to/
echo "/path/to/file.txt" | perl -pe 's{(.*)}{File::Basename->dirname($1)}ge'
but I'm missing something in my invocation of File::Basename->dirname()
, causing the following error:
Can't locate object method "dirname" via package "File::Basename" (perhaps you forgot to load "File::Basename"?) at -e line 1, <> line 1.
What am I missing?
(I know I can just use dirname
from bash but I'm trying to do something more complicated with perl than what this stripped down example shows).