Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Problem with quotes

by nighthawk_
on Sep 08, 2002 at 20:08 UTC ( #196087=snippet: print w/replies, xml ) Need Help??
Description: How to handle quotes
in a self reference scenario.
Dear Monks, I've a problem using quotes in a self reference scenario. The situation in my script is, that, if you want to insert the code from sub b and sub c into sub a (between quotes), you will get some props to keep to code printed out looking absolutely equal to the code listed above. Please can show me someone a proper solution, where this condition halts. Or a solution, so that the script above prints its code with single parenthesis around it. Thanks a lot in advance. nighthawk_
#!usr/bin/perl

# Just insert the code from sub b and sub c in sub a where the tree do
+ts are.
sub a {    my $input = shift; return 'sub b{...}; sub c(...)'; }
sub b { my $input = shift; return 'sub a { my $input = shift; return \
+''.$input.'\';}'.$input.';';}
sub c { my $input = shift; print $input.'print &c(&b(&a()));';}
print &c(&b(&a()));
Replies are listed 'Best First'.
Re: simple perl viri
by shotgunefx (Parson) on Sep 08, 2002 at 22:27 UTC
    Why? This isn't even clever, or eye opening. (Not that would make it cool to post but at least it might have some sort of value on a Perl site).

    Spend your time on something better.

    -Lee

    "To be civilized is to deny one's nature."
Re: simple perl viri
by ichimunki (Priest) on Sep 09, 2002 at 15:10 UTC
    First, the singular form of "virus" is "virus", not "viri". Second, the plural form of "virus" is "viruses", not "virii". Third, there is a cogent discussion of this issue at Morality of posting Perl "virus" code and perhaps how to protect against such viruses at Virus protection for Perl scripts.

    Fourth, I don't see why this node should be reaped-- at least let the author take the downvotes. The code is still here, and anybody with half a clue and minimal knowledge of Perl could figure it out anyway. Just for the mental exercise... This script avoids doing a lot of things a good virus might: checking to see if it's root and infecting core modules; checking to see if a script is too small and not infecting it-- a virus() function in a 100 line script might be visible, in a 5000 line script it might go unnoticed; building the function into a BEGIN or END block and shoving it in the middle somewhere (even better if "middle" is in the middle of a big block of POD, if the documentation is stable, a programmer doing maintenance might never look there); then, the sheer size of the added code makes it easy to spot, but this just as easily could've been a fairly concise obfuscated snippet... the sort of thing we might pass off if we saw it in someone else's script (like stuff we downloaded) as either advanced wizardry or cargo-cult code. Finally, this code is not cross-language, but it could easily be modified to work from and infect other scripting languages.

    To me, the very idea that we should try to keep a lid on this stuff is counter-productive. Anybody using scripting languages in a professional or other setting where security is a concern needs to be *very* aware of the danger of using foreign code. In fact, as a frequent user of CPAN modules, I have to ask: how hard is it to get a CPAN account? Could someone easily make a throwaway identity and upload a trojaned module? Is someone reviewing all of the code posted to CPAN? It's hardly responsible to spout off things like "use the module" to folks who are busy reinventing the wheel (at least non-core-module wheels) if there is a real security risk involved in doing so.

Re: simple perl viri
by Juerd (Abbot) on Sep 08, 2002 at 21:06 UTC

    Please do not post destructive code.

    Keep the monastery shitless.

    - Yes, I reinvent wheels.
    - Spam: Visit eurotraQ.
    

Re: simple perl viri
by Marza (Vicar) on Sep 09, 2002 at 05:11 UTC

    Very basic at best. You might have had better acceptance if you wrote this up as a tutorial. But I would not waste your time to "learning" this subject.

    Update:

    This is not even original work. This is a version of the Padd virus.

Re: Why did you change the original post?
by Marza (Vicar) on Sep 11, 2002 at 23:26 UTC

    If you are going to change the post. You should make a note as to what you did.

    It is bad form to change the original post like this. As the replies no longer make sense.

    If you are trying to make a new question. You have to create a new one. You can't simple erase an old one.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://196087]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2020-11-28 02:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?