LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-04-2006, 09:22 AM   #1
Joe_Zhu
Member
 
Registered: Dec 2003
Distribution: Debian, RedHat
Posts: 32

Rep: Reputation: 15
Question what is "strict subs "


i have many digital photo files with IMGP as prefix and i want to change them to other file name. i try to use rename, i follow the manual and type in my console as below,
rename IMGP B IMGP????
it return to me like this

Bareword "IMGP" not allowed while "strict subs" in use at (eval 1) line 1.

i have no idea of this error message, anyone can help ??
thanks!
Joseph

Last edited by Joe_Zhu; 02-04-2006 at 09:23 AM.
 
Old 02-04-2006, 09:47 AM   #2
sipsipi
Member
 
Registered: Dec 2005
Location: Chicago
Distribution: Fedora and Redhat
Posts: 86

Rep: Reputation: 15
It sounds like a perl issue. Try updating perl, perl modules...

also google file renaming, there is alot of scripts and gui apps.

I prefer using mv and sed in a script
 
Old 02-04-2006, 03:23 PM   #3
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 51
If you use strict in Perl, strings must have some kind of quotes around them.
 
Old 02-04-2006, 04:02 PM   #4
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Quote:
...and type in my console as below, rename IMGP B IMGP
From your description here, I'm guessing that you found a script called rename that is actually a PERL program someone wrote to rename files. That script may internally call PERL's builtin rename() function to do it's work (speculation). The builtin rename() function takes two parameters and your example invokation shows three: "IMGP", "B", and "IMGP" again. So I really can't tell exactly what you're doing here, but I can explain barewords despite my lack of this understanding:

---

In PERL, a bareword is a word - a string of text not considered a subroutine name, reserved word, etc. - that is not surrounded by quotes. That's probably more confusing than the error message PERL gave you in the first place!

What it's saying is that you gave it this: IGMP, but it wants something more like this: "IGMP" or this: 'IGMP'. Normally barewords will work, and only generate warnings, unless you also have in the code use strict. This forces barewords and other things to escalate from warnings into fatal errors.

If you can post the actual PERL script you are using, not just how you are calling it, then I can tell you more about why you might be getting this error and how to fix it. Also a little more background on what you are trying to do. Something like "I have files named xxx.tiff that I want to rename to prefix_xxx.tif and they are scattered across several subdirectories."
 
1 members found this post helpful.
Old 05-03-2011, 04:32 PM   #5
cbemerine
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Rep: Reputation: 1
Example that might help others in understanding strict subs

This is very confusing to new users so I do not believe it would hurt to have some more information for those looking to learn more about Linux and how it works. Thank you @haertig, your response has helped me, I needed the reminder today.

An alternative way to get rename to work, in spite of the perl strict subs messaqe would be to use the 's' option with rename command as follows. (For this example, lets assume you want to rename IMGP to B. I agree with @haertig that what the original poster was trying to do was unclear, perhaps rename IMGP.B to just IMGP, who knows.) Either single quotes (') or double quotes (") are required for the command to work.

rename 's/IMGP/B/' IMGP

The above assumes the user has correct file and subdirectory access to effect change to the file in question. Running an 'ls -alF' will show you the rights for the subdirectory (folder) in question and the file 'B' which the above file changed from 'IMGP' if the above command ran successfully.

I too ran into this with the current Ubuntu...made a mental note to verify which version of the 'rename' perl script/command was being used by the Linux distro I am on at a given time. Unfortunately neither -V or -v option revealed any version information, instead I received an 'Unknown option:' message, in spite of the help showing:

Usage: rename [-v] [-n] [-f] perlexpr [filenames]


Made me curious to which 'rename' script/command was being accessed when 'rename -v' did not provide a version number as expected. Here is how you can do that, regardless of which Linux distro you are using.

From a Command Prompt/Terminal Window, do the following:

sudo -i ~ Become root/superuser 'sudo -i' and enter the [sudo] password.
cd / ~ Go to the root directory 'cd /' (use a 'pwd' command to verify your current directory)
find . -name rename ~ run 'find . -name rename' or 'find . -name "*rename*"' (do not include the single quotes) to determine where the replace script/command exists on your current Linux system. Make sure you include the minus sign (-) before the 'name' parameter, no spaces between - and name or you will not get what you want to see, but instead get almost everything on your hard drive.

For my current Ubuntu version, Ubuntu 10.04.1 LTS, (lsb_release -d) whose root is Debian, squeeze/sid, (cat /etc/debian_version) I found the following:

root@zareason-breeze:/# pwd
/
root@zareason-breeze:/# find . -name rename
./var/lib/dpkg/alternatives/rename
./etc/alternatives/rename
./usr/bin/rename


Next I checked my PATH using the 'env' command to determine which of those 'rename' scripts/commands was encountered first.


root@zareason-breeze:/# env
.
.
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games


Based on this information I know that I am encountering the 'replace' script/command in location /usr/bin before any of the others listed. (Being mindful that I was root/superuser (sudo) here, I checked the path for my user account as well and it was the same. Had anyone placed a 'rename' script in any of the following:

/usr/local/sbin
/usr/local/bin
/usr/sbin


that 'rename' script/command would have run before the 'rename' command in /usr/bin. Something a rootkit might do with other scripts/commands so that you would not know it was there. FYI.

An alternative way is to use the 'which' script/command to see which one (rename) is accessed, however the reader should be aware that I have experienced cases where 'which' did not work, probably because the command/script I was looking for was not in my PATH, thus the method above with 'find' and 'env' will always find what you are looking for, especially if you become root(superuser/sudo/su) and search from the root directory (/). (Windows users might be familiar with their Root directory for their 'C' drive being C:/>, similar concept, though not exactly identical as you have D:/> and perhaps more. In Linux every drive, subdirectory, folder is mounted from the root directory of /...many users find this concept confusing at first.)


root@zareason-breeze:/# which rename
/usr/bin/rename


I plan to use Arch, CentOS, Fedora, Gentoo, Knoppix, Slackware, TinyCore, in addition to Debian (Ubuntu/Mint)...remember there are well over 26 different Linux root distros, its just that Debian and Red Hat are the two most commonly used, at least for servers, based on the statistics I have seen. For instance the root Linux distro for Ubuntu is Debian. The root distro for Linux Mint is Ubuntu. The root distro for CentOS is Redhat, just as Fedora's root distro is Redhat. Do not let my usage of 'root' with respects to parent - child relationships among distros confuse you compared to sudo (root/superuser) access. They are different.

To see the root distro for the Linux you are currently using, use this Graphic: http://upload.wikimedia.org/wikipedi...a/Gldt1009.svg.

Two Unix/Linux distros not shown on that graphic that I use (or plan too) are 'BSD' and 'busybox' (busybox Linux is used for DD-WRT and many other embedded devices, smart handhelds, etc...). Many people forget that Gnu is not Linux and Linux is built with/on top of Gnu. FYI. Personally I started with Sun, Solaris, Redhat and Mandrake back in the late 1990s, but that is another story.

I hope that the information and commands used to get that information that I have provided here will help other Linux users learn a little more about the version of Linux they are currently using. One thing is for sure, when I searched for 'strict subs' related to Linux, this post was among the top search results listed.

As for today, 2011, 5 years after the posting of this question on LinuxQuestions, whose information is still valid today, I believe adding additional information is "relevant" as the google search I performed listed this forum post in the top two listed. I certainly needed the reminder. So many people will should find the additional command and related information relevant as well.

The more I learn, I realize there is so much more to learn! That is a very good thing!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 01:03 AM
what is "sticky bit mode" , "SUID" , "SGID" augustus123 Linux - General 10 08-03-2012 04:40 AM
Telling people to use "Google," to "RTFM," or "Use the search feature" Ausar General 77 03-21-2010 11:26 AM
"Xlib: extension "XFree86-DRI" missing on display ":0.0"." zaps Linux - Games 9 05-14-2007 03:07 PM
Can't install "glibmm" library. "configure" script can't find "sigc++-2.0&q kornerr Linux - General 4 05-10-2005 02:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration