472,954 Members | 1,728 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,954 software developers and data experts.

What am I missing?

Hi

Probably it is very obvious, but at this moment I cannot solve it. could you
please help me?

(1).

$ perl -e '$a="123234"; $a=~tr/23/ab/; print "$a\n"'
1abab4

Well, it is clear.

(2).

$ perl -e '$a="123234"; $b="ab"; $a=~tr/23/$b/; print "$a\n"'
1$b$b4

I understand this too - no interpolation.

but:
(3).

$ perl -e '$a="123234"; $b="ab"; eval "$a=~tr/23/$b/"; print "$a\n"'
123234

Shouldn't I get same as (1)? So how to do this?

TIA

Mariusz
Jul 19 '05 #1
2 1927
Wiadomo¶ć z dnia pi± 5. marca 2004 19:31, której autorem jest ManieQ,
zawierała:
(3).

$ perl -e '$a="123234"; $b="ab"; eval "$a=~tr/23/$b/"; print "$a\n"'
123234


I know now:
eval "\$a=~tr/23/$b/";

I missed backslash :-(

Mariusz

Jul 19 '05 #2
In article <c2**********@nemesis.news.tpi.pl>, ManieQ
<ma************@idea.net.CIACHNIJpl> wrote:
Hi

Probably it is very obvious, but at this moment I cannot solve it. could you
please help me?

[examples 1 & 2 snipped]
but:
(3).

$ perl -e '$a="123234"; $b="ab"; eval "$a=~tr/23/$b/"; print "$a\n"'
123234

Shouldn't I get same as (1)? So how to do this?


No, you shouldn't. You are sending eval the double-quoted string
"$a=~tr/23/$b/", which, after interpolation, becomes
'123234=~tr/23/ab/', which is an error. Print out the contents of the
variable $@:

perl -e '$a="123234"; $b="ab"; eval "$a=~tr/23/$b/"; print "$a $@\n"'
123234 Can't modify constant item in transliteration (tr///) at (eval
1) line 2, at EOF

Try this, instead, with braces instead of double quotes:

perl -e '$a="123234"; $b="ab"; eval {$a=~tr/23/$b/}; print "$a $@\n"'
1$b$b4

Note: this newsgroup is defunct. Try comp.lang.perl.misc in the future.
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: David MacQuigg | last post by:
I'm concerned that with all the focus on obj$func binding, &closures, and other not-so-pretty details of Prothon, that we are missing what is really good - the simplification of classes. There are...
5
by: SimpSity | last post by:
I am a complete noob, what book would be the best for complete begginers, u know the ones that could teach a a retarted neborn monkey to program C++ thats the kind of thing im looking for alotr of...
112
by: Andy | last post by:
Hi All! We are doing new development for SQL Server 2000 and also moving from SQL 7.0 to SQL Server 2000. What are cons and pros for using IDENTITY property as PK in SQL SERVER 2000? Please,...
1
by: Sarah | last post by:
Hello. I am using Microsoft.Office.Interop.Excel in a C# .NET project. I want to open an Excel application with a specific file name. I am currently opening it with this code: ...
1
by: bradleyc | last post by:
Definately need my eyes checked... Error:asstester.cpp(300,1):Declaration missing ; Error:asstester.cpp(300,1):Compound statement missing } void doModify() { clrscr(); char inputv,...
0
by: kris | last post by:
hi can any one help me out, i have written a code for Word Indexing using Dll's i think this is an incomplete code for WORD INDEX. I had encountered this error "Error! No index entries found"...
17
by: Justin Emlay | last post by:
I'm hopping someone can help me out on a payroll project I need to implement. To start we are dealing with payroll periods. So we are dealing with an exact 10 days (Monday - Friday, 2 weeks). ...
10
by: Protoman | last post by:
Could you tell me what's wrong with this program, it doesn't compile: #include <iostream> #include <cstdlib> using namespace std; class Everything { public: static Everything* Instance()
5
by: le0 | last post by:
Hello guys, Im really having a hard time doing this, I have a record set with the ItemNo field with the data type as Text. In the record that I have, I want to find the missing number in the...
20
by: mc | last post by:
I may be opening a can of worms and don't want to start a religious war, but... What features of Java do Java programmers miss when working in C#? Other than, of course, great portability. C#...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.