Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9229261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:31:41+00:00 2026-06-18T05:31:41+00:00

Mac Os X does not have the useful linux command rename , which has

  • 0

Mac Os X does not have the useful linux command rename, which has the following format:

rename 'perl-regex' list-of-files

So here’s what I have put together but it does not rename any files ($new is always the same as $file):

#!/usr/bin/env perl -w
use strict;
use File::Copy 'move';

my $regex=shift;
my @files=@ARGV;

for my $file (@files)
{
    my $new=$file;
    $new =~ "$regex";    # this is were the problem is !!!
    if ($new ne $file) 
    {
        print STDOUT "$file --> $new \n";
        move $file, ${new} or warn "Could not rename $file to $new";
    }
}

It is as if I am not passing the regexp and if I hard code it to

$new =~ s/TMP/tmp;

it will work just fine…
Any thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:31:42+00:00Added an answer on June 18, 2026 at 5:31 am
    $operator = 's/TMP/tmp/';
    print $operator; 
    

    doesn’t magically evaluate the operator, so it should be no surprise that

    $operator = 's/TMP/tmp/';
    $x =~ $operator; 
    

    doesn’t either. If you want to evaluate Perl code, you’re going to have to pass it to the Perl interpreter. You can access it using eval EXPR.

    $operator = 's/TMP/tmp/';
    eval('$x =~ '.$operator.'; 1')
       or die $@;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Why does Mac's $find not have the option -printf? Not sure what
I am an Objective-C newbie, who still does not have a Mac, but still
I have not found a reason why Mac's find does not have the option
I get command not found error in Mac by the following command md5sum *.java
I figured out that CUDA does not work in 64bit mode on my mac
Below is some sample code. The window does not resize (python3.2, on a Mac,
Does anyone have experience writing professional OpenGL games on Windows? For the Mac, due
Mac OSX 10.6.4 Nexus One Android 2.2 The command adb devices will list my
Does any operating system provide a mechanism (system call — not command line program)
PHP does not have built-in image editing capability, but many projects use the GD

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.