[19584] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1779 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 20 09:05:36 2001

Date: Thu, 20 Sep 2001 06:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1000991108-v10-i1779@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 20 Sep 2001     Volume: 10 Number: 1779

Today's topics:
    Re: ANNOUNCE: grepmail 4.51 released <epa98@doc.ic.ac.uk>
    Re: Combining messages sent to user <michealo@ozemail.com.au>
        Compile and install CPAN modules on win32 (Newbie)
    Re: copy STDERR to file (Rory)
    Re: copy STDERR to file (Rory)
    Re: installing modules in WinNT <whatever@nevermind.invalid>
        multi language html output <gustino2001@hotmail.com>
    Re: Perl access to Inportb / Outportb <ron@indra.com>
        Perl time transferred to Javascript ? <dummy@12u.com>
    Re: Perl time transferred to Javascript ? <em@online.no>
        Posting Guidelines for comp.lang.perl.misc ($Revision:  tadmc@augustmail.com
    Re: Problem with DBI+DBD MySQL, using fetchall_arrayref (Altair04)
        Problem with Object Oriented Perl <feric@gti-info.com>
    Re: Problem with Object Oriented Perl <Thomas@Baetzler.de>
        Problems with $ character <jocke30_gbg@hotmail.com>
    Re: Problems with $ character (Tad McClellan)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 20 Sep 2001 11:27:23 +0100
From: Edward Avis <epa98@doc.ic.ac.uk>
Subject: Re: ANNOUNCE: grepmail 4.51 released
Message-Id: <xn966ae2m44.fsf@owl.doc.ic.ac.uk>

David Coppit <newspost@coppit.org> writes:

>While I'm at it, I'd like to raise some awareness that Perl code
>isn't just about modules. This cross-posting, plus the lackluster
>script archive on CPAN (still no tarballs, after all these years!)
>indicate some sort of modules-only slant.

Probably because when you write a script or program, it isn't as
strongly associated with Perl.  The user doesn't need to know Perl to
use it, or even care what language it is implemented in.  There's no
real point, IMHO, to a collection of programs with no common feature
other than that they are written in Perl.  Except as a source of
examples and inspiration.

If a Perl program is good enough for general use it should get an
entry on Freshmeat or some other software archive.  No need to
ghettoize things...

-- 
Ed Avis <epa98@doc.ic.ac.uk>
Finger for PGP key


------------------------------

Date: Thu, 20 Sep 2001 17:32:41 +1000
From: "nathan" <michealo@ozemail.com.au>
Subject: Re: Combining messages sent to user
Message-Id: <yWgq7.1069$cu4.60026@ozemail.com.au>

here i made this for you, this will check if there are 3 lines in a file on
each line there has to be a message.
you must store messages to file.

sub message {
open(messages, "path/to/message/file") || die "I can't open file\n";
 @file = <messages>;
close(messages);

$max  = "3";
$num = "0";
foreach $line (@file) {
if ($max eq $num) {
$match = "1";
}
else {
$num = $num+1;
}
}
if ($match eq "1") {
open(messages, "path/to/message/file") || die "I can't open file\n";
 @msg = <messages>;
close(messages);
# now remove data from message file
open(removemsgs, ">path/to/message/file") || die "I can't open file\n";
close(removemsgs);

# mail rootine here @msg is your messages
}
}

Donnajeanne Liu <dliu2@umbc.edu> wrote in message
news:82751023.0109181043.24b07ff5@posting.google.com...
> How could I combine perl files so that only one message would be
> emailed to the user as opposed to three different messages.




------------------------------

Date: 20 Sep 2001 00:12:20 -0700
From: youradmirer@onebox.com (Newbie)
Subject: Compile and install CPAN modules on win32
Message-Id: <582bc82b.0109192312.3371e7d6@posting.google.com>

I hope that this short message will help many of you who like to
compile and install CPAN modules on Windows, but don't want to
experience the pain I have been through to get these modules installed
on Windows.

I have built many modules with VC++6.0, so it's highly recommended. In
my experience,WinNT could make life relatively easier compared to
other Windows OS's (ie Win9x/ME). Once you have VC++ installed on your
machine, copy the two files "nmake" and "vcvars32" from the "bin"
directory (normally in Microsoft Visual Studio/VC98/bin)to your path.
You can do this by setting the path field via Control Panel on WinNT
or autoexec.bat on Win9x/ME. Reboot your machine if you're running on
Win9x/ME. This updates your path to the executables.

Unzip and untar the module to your local disk (ex:
D:\Perl\packages\Tk). Change to this directory and start to create a
makefile by typing "perl Makefile.PL" (apparently, you must have Perl
installed on your machine).

Now you need to run "vcvars32" to set appropriate library/include
paths for VC++ compiler. After issuing this command, you should see
the changes simply by typing "SET". OK, open the main Makefile in the
current directory (created by perl Makefile.PL), search for "subdirs"
entries, they should look somewhat similar to this:
subdirs:
@[
      cd pTK
      ....
]
Remove all "@[" and "]" for all subdirs, otherwise, you can't make it
pass "nmake" for this error:
u1035: syntax error : expected ";" or "=" separator   (or something
like that).  In fact, during your compilation, you might see more of
this errors. Simply monitor the process and go to the subdirectory
that contains the makefile that has "@[" and ']" in there, remove all
of these symbols.
For example:
     cd pTk
     NMAKE all -nologo
makefile(393): u1035: syntax error: blah blah
Stop
You need to remove all the "@[" and " ]"  in the makefile under pTk
directory. Try "nmake" again, it should go through nicely.

Another annoying error message is "Too many parameters -- &&".  This
is because the command.exe shell can't handle "&&" syntax.  Simply
search for all "&&"s in your Makefile and break it into lines.
Ex:   cd pTk && $(MAKE) $(FLAGS)
=>    cd pTk
      $(MAKE) $(FLAGS)
      cd ..
You might want to check if the execution is sucessfull by testing
%errorno%, but most of the time it isn't necessary.

Those who like to install Tk on your machine might encounter another
error stating that _XRectInRegion cannot be found.  All you need to do
is move the line "extern XRectInRegion blah blah" in Xlib.h to
Xlib_f.h and recompile it.

Even when you think that you might get through with all of the
nuisance, you can unexpectedly see errors like "Sorry no HTML building
yet" etc.  I normally just ignore these extra baggages by taking them
out of the makefile.
Ex:  
all:  pure_all htmlifypods html => all: pure_all htmlifypods

Hope this saves you time.


------------------------------

Date: 20 Sep 2001 03:00:12 -0700
From: rory@campbell-lange.net (Rory)
Subject: Re: copy STDERR to file
Message-Id: <ba9de059.0109200200.12c952b2@posting.google.com>

> 	open SAVEERR, ">&STDERR";
> 	open STDERR, "> stderr.txt";
> 	warn "This goes to the file";
> 	open STDERR, ">&SAVEERR";
> 	warn "This goes to the old STDERR";
> 
> It works, apart from this warning:
> 
>    Name "main::SAVEERR" used only once: possible typo at test.pl line 

Great. That works - thanks! 

I didn't understand what perlfunc means when it states:

"...specify an EXPR beginning with ">&", in which case the rest of the
string is interpreted as the name of a filehandle (or file descriptor,
if numeric) which is to be duped and opened..."

This has given more clarity. It still seems pretty strange, though, to
open a "filehandle" against STDERR before redirecting it, so that it
can be restored!

Thanks again
Rory


------------------------------

Date: 20 Sep 2001 03:14:49 -0700
From: rory@campbell-lange.net (Rory)
Subject: Re: copy STDERR to file
Message-Id: <ba9de059.0109200214.797f6a73@posting.google.com>

> 	open SAVEERR, ">&STDERR";
> 	open STDERR, "> stderr.txt";
> 	warn "This goes to the file";
> 	open STDERR, ">&SAVEERR";
> 	warn "This goes to the old STDERR";
> 
> It works, apart from this warning:
> 
>    Name "main::SAVEERR" used only once: possible typo at test.pl line 

Great. That works - thanks! 

I didn't understand what perlfunc means when it states:

"...specify an EXPR beginning with ">&", in which case the rest of the
string is interpreted as the name of a filehandle (or file descriptor,
if numeric) which is to be duped and opened..."

This has given more clarity. It still seems pretty strange, though, to
open a "filehandle" against STDERR before redirecting it, so that it
can be restored!

Thanks again
Rory


------------------------------

Date: Thu, 20 Sep 2001 12:58:22 GMT
From: asif <whatever@nevermind.invalid>
Subject: Re: installing modules in WinNT
Message-Id: <3BA9E802.6000607@nevermind.invalid>

Eli the Bearded wrote:

> I'm not used to using perl on windows systems, so my problems might
> be naive, but....
> 
> I got a recent ActiveState perl. I tried to install it on a WinNT
> box with pkunzip. That seemed to fail horribly, it mangled the
> filenames to 8.3 in a bad way. So I downloaded winzip and tried
> again. That seems to work, perl can find modules now.
> 
> But ppm does not work. I need to install one non-standard module
> for an app to work: Time::HiRes.
> 
<snip/>


Unless there's a specific reason for not using it, download the MSI 
version.

I had similar problems with an NT install. Deleting everything, going to 
MS' site and getting the MSI application, downloading the MSI version of 
ASPerl and installing using the MSI installer solved 99.9% of my problems.

/whatever



------------------------------

Date: Thu, 20 Sep 2001 13:00:16 +0200
From: "Paul" <gustino2001@hotmail.com>
Subject: multi language html output
Message-Id: <3ba9ccb0$0$60726$6e365a64@newsreader02.highway.telekom.at>

hi,

maybe this is offtopic here but i wasn't sure where to post anyway

does anyone have an idea how i could realize a perl html output, containing
the language the user selected, without putting every text into a variable
like:

$text = ....; -> get value from text file
print <<"EOF";
<html>
 ....
<table ...>
$titel
$name
$text
</table>
 ....
EOF

i'd appreciate any hint even if it's not something like i mentioned above!

tnx in advance

paul







------------------------------

Date: Thu, 20 Sep 2001 06:28:39 -0600
From: Ron Reidy <ron@indra.com>
Subject: Re: Perl access to Inportb / Outportb
Message-Id: <3BA9E0F7.1A327E2B@indra.com>

Nial Stewart wrote:
> 
> I'm a hardware engineer who's recently discovered Perl.
> 
> It's really useful to be able to knock up quick test scripts to allow
> fast debugging before I've any software support. I recently sussed
> out how to drive the serial port, but I needed a method of driving
> an Inportb / Outportb type direct hardware access.
> 
> I'd read about XS, but as a hardware engineer that seemed to involve a
> lot of messing about with compilers/make files that I didn't have
> access to or experience of.
> 
> While reading through perldocs I read that you can capture whatever
> a programme sends to STDOUT by invoking it with backticks.
> 
> I wrote and compiled the following TurboC programme
> 
> /*   Inportb.c    */
> #include <bios.h>
> #include <stdio.h>
> #include <dos.h>
> main(int argc, char *argv[])
> {
> unsigned int input;
> char *termn;
> unsigned char result;
> input = strtol(argv[1],&termn,0); /* converts the input string to an int */
> result = inportb(input);
> printf("%d",result);
> return;
> }/* End of main Inportb.c */
> 
> This creates a minimal inportb.exe which inputs a byte from the address
> specified and prints it.
> 
> In a Perl script ...
> 
> $result = `inportb $address`;
> print "Address $address contains value $result";
> 
> ... works brilliantly.
> 
> The same method can be used for driving an outportb.
> 
> If anyone wants inportb.exe/outportb.exe send me an email, although
> for your own peace of mind it's probably better to build them
> yourself.
> 
> Nial Stewart.
Nial,

Look at Inline.pm - you can create on-the-fly C/C++, Pythin, etc. XS
code for Perl - A **very** cool module.

Good luck.
-- 
Ron Reidy
Oracle DBA
Reidy Consulting, L.L.C.


------------------------------

Date: Thu, 20 Sep 2001 12:36:54 GMT
From: "Peter Hansen" <dummy@12u.com>
Subject: Perl time transferred to Javascript ?
Message-Id: <Gplq7.228$n5b.170783744@news.telia.no>

Anyone who know how, if possible, to transfer data from perl-script to
Javascript-program?

I want to transfer the servers date&time to the Javascript-program on the
users machine - to be shure what time it is regardless of local
computerclock.

If possible, may you please show me the whole the Perl-script code pluss
interface to Javascript?
If not possible, any other ideas to let Javascript know what time it is,
regardless of the user computerclock?

Looking forward to your bright answer!

Petter.

(Please no direct mail to me, due to spam)





------------------------------

Date: 20 Sep 2001 14:52:16 +0200
From: Espen Myrland <em@online.no>
Subject: Re: Perl time transferred to Javascript ?
Message-Id: <87y9nauirj.fsf@espenboks.ws.nextra.no>

"Peter Hansen" <dummy@12u.com> writes:

> Anyone who know how, if possible, to transfer data from perl-script to
> Javascript-program?
> 
> I want to transfer the servers date&time to the Javascript-program on the
> users machine - to be shure what time it is regardless of local
> computerclock.
> 
> If possible, may you please show me the whole the Perl-script code pluss
> interface to Javascript?
> If not possible, any other ideas to let Javascript know what time it is,
> regardless of the user computerclock?
> 
> Looking forward to your bright answer!


        Just let perl generate java script.


print "html and javascriptcode bla bah", localtime(), "bla bla end_javascript_and_htmlcode";


--
espen



------------------------------

Date: Thu, 20 Sep 2001 12:23:38 GMT
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.2 $)
Message-Id: <edlq7.341201$VV1.24820484@bin1.nnrp.aus1.giganews.com>

Outline
   Before posting to comp.lang.perl.misc
      Must
       - Check the Perl Frequently Asked Questions (FAQ)
       - Check the other standard Perl docs (*.pod)
      Really Really Should
       - Lurk for a while before posting
       - Search a Usenet archive
      If You Like
       - Check Other Resources
   Posting to comp.lang.perl.misc
      Is there a better place to ask your question?
       - Question should be about Perl, not about the application area
      How to participate (post) in the clpmisc community
       - Carefully choose the contents of your Subject header
       - Use an effective followup style
       - Speak Perl rather than English, when possible
       - Ask perl to help you
       - Do not re-type Perl code
       - Provide enough information
       - Do not provide too much information
       - Do not post binaries, HTML, or MIME
      Social faux pas to avoid
       - Asking a Frequently Asked Question
       - Asking a question easily answered by a cursory doc search
       - Asking for emailed answers
       - Beware of saying "doesn't work"
       - Sending a "stealth" Cc copy
      Be extra cautious when you get upset
       - Count to ten before composing a followup when you are upset
       - Count to ten after composing and before posting when you are upset
-----------------------------------------------------------------

Posting Guidelines for comp.lang.perl.misc ($Revision: 1.2 $)
    This newsgroup, commonly called clpmisc, is a technical newsgroup
    intended to be used for discussion of Perl related issues (except job
    postings), whether it be comments or questions.

    As you would expect, clpmisc discussions are usually very technical in
    nature and there are conventions for conduct in technical newsgroups
    going somewhat beyond those in non-technical newsgroups.

    This article describes things that you should, and should not, do to
    increase your chances of getting an answer to your Perl question. It is
    available in POD, HTML and plain text formats at:

     http://mail.augustmail.com/~tadmc/clpmisc.shtml

    For more information about netiquette in general, see the "Netiquette
    Guidelines" at:

     http://andrew2.andrew.cmu.edu/rfc/rfc1855.html

    A note to newsgroup "regulars":

       Please do not use the existence of these guidelines as a
       "license to flame" or other meanness. It is possible that
       a poster is not aware of the things discussed here. Let's
       give them the benefit of the doubt, and just help them learn
       how to post, rather than assume that they do know and are
       being the "bad kind" of Lazy.

    A note about technical terms used here:

       In this document, we use words like "must" and "should" in the 
       very precise sense that they're used in technical conversation 
       (such as you're likely to encounter in this newsgroup). When 
       we say that you *must* do something, we mean that if you don't
       do that something, then it's very unlikely that you're going to 
       get much benefit from using this group.  We're not trying to boss
       you around; we're just trying to convey the point without using 
       a lot of words.

    Do *NOT* send email to the maintainer of these guidelines. It will be
    discarded unread. The guidelines belong to the newsgroup so all
    discussion should appear in the newsgroup. I am just the secretary that
    writes down the consensus of the group.

Before posting to comp.lang.perl.misc
  Must

    This section describes things that you *must* do before posting to
    clpmisc, in order to maximize your chances of getting meaningful replies
    to your inquiry and to avoid getting flamed for being lazy and trying to
    have others do your work.

    The perl distribution includes documentation that is copied to your hard
    drive when you install perl. Also installed is a program for looking
    things up in that (and other) documentation named 'perldoc'.

    You should either find out where the docs got installed on your system,
    or use perldoc to find them for you. Type "perldoc perldoc" to learn how
    to use perldoc itself. Type "perldoc perl" to start reading Perl's
    standard documentation.

    Check the Perl Frequently Asked Questions (FAQ)
        Checking the FAQ before posting is required in Big 8 newsgroups in
        general, there is nothing clpmisc-specific about this requirement.
        You are expected to do this in nearly all newsgroups.

        You can use the "-q" switch with perldoc to do a word search of the
        questions in the Perl FAQs.

    Check the other standard Perl docs (*.pod)
        The perl distribution comes with much more documentation than is
        available for most other newsgroups, so in clpmisc you should also
        see if you can find an answer in the other (non-FAQ) standard docs
        before posting.

    It is *not* required, or even expected, that you actually *read* all of
    Perl's standard docs, only that you spend a few minutes searching them
    before posting.

    Try doing a word-search in the standard docs for some words/phrases
    taken from your problem statement or from your very carefully worded
    "Subject:" header.

  Really Really Should

    This section describes things that you *really should* do before posting
    to clpmisc.

    Lurk for a while before posting
        This is very important and is expected regardless of what newsgroup
        you are visiting. Lurking means to simply monitor a newsgroup for a
        period of time until you become very familiar with local customs.
        Think of a newsgroup as foreign culture. Each newsgroup has its own
        specific customs and rituals. Get to know those customs and rituals
        well before you participate. This will help you to avoid
        embarrassing social situations. Consider yourself to be a foreigner
        at first!

    Search a Usenet archive
        There are tens of thousands of Perl programmers. It is very likely
        that your question has already been asked (and answered). See if you
        can find where it has already been answered.

        One such searchable archive is:

         http://groups.google.com/advanced_group_search

  If You Like

    This section describes things that you *can* do before posting to
    clpmisc.

    Check Other Resources
        You may want to check in books or on web sites to see if you can
        find the answer to your question.

        But you need to consider the source of such information: there are a
        lot of very poor Perl books and web sites, and several good ones
        too, of course.

Posting to comp.lang.perl.misc
    There can be 200 messages in clpmisc in a single day. Nobody is going to
    read every article. They must decide somehow which articles they are
    going to read, and which they will skip.

    Your post is in competition with 199 other posts. You need to "win"
    before a person who can help you will even read your question.

    These sections describe how you can help keep your article from being
    one of the "skipped" ones.

  Is there a better place to ask your question?

    Question should be about Perl, not about the application area
        It can be difficult to separate out where your problem really is,
        but you should make a conscious effort to post to the most
        applicable newsgroup. That is, after all, where you are the most
        likely to find the people who know how to answer your question.

        Being able to "partition" a problem is an essential skill for
        effectively troubleshooting programming problems. If you don't get
        that right, you end up looking for answers in the wrong places.

        It should be understood that you may not know that the root of your
        problem is not Perl-related (the two most frequent ones are CGI and
        Operating System related), so off-topic postings will happen from
        time to time. Be gracious when someone helps you find a better place
        to ask your question by pointing you to a more applicable newsgroup.

  How to participate (post) in the clpmisc community

    Carefully choose the contents of your Subject header
        You have 40 precious characters of Subject to win out and be one of
        the posts that gets read. Don't waste them. Take care while
        composing them, they are the key that opens the door to getting an
        answer.

        Spend them indicating what aspect of Perl others will find if they
        should decide to read your article.

        Do not spend them indicating "experience level" (guru, newbie...).

        Do not spend them pleading (please read, urgent, help!...).

        Do not spend them on non-Subjects (Perl question, one-word
        Subject...)

        For more information on choosing a Subject see "Choosing Good
        Subject Lines":

         http://www.perl.com/CPAN-local/authors/Dean_Roehrich/subjects.post

        Part of the beauty of newsgroup dynamics, is that you can contribute
        to the community with your very first post! If your choice of
        Subject leads a fellow Perler to find the thread you are starting,
        then even asking a question helps us all.

    Use an effective followup style
        When composing a followup, quote only enough text to establish the
        context for the comments that you will add. Always indicate who
        wrote the quoted material. Never quote an entire article. Never
        quote a .signature (unless that is what you are commenting on).

        Intersperse your comments *following* the sections of quoted text
        that your comments apply to. Failure to do this is called "Jeopardy"
        posting because the answer comes before the question.

        Reversing the chronology of the dialog makes it much harder to
        understand (some folks won't even read it if written in that style).
        For more information on quoting style, see:

         http://www.geocities.com/nnqweb/nquote.html

    Speak Perl rather than English, when possible
        Perl is much more precise than natural language. Saying it in Perl
        instead will avoid misunderstanding your question or problem.

        Do not say: I have variable with "foo\tbar" in it.

        Instead say: I have $var = "foo\tbar", or I have $var = 'foo\tbar',
        or I have $var = <DATA> (and show the data line).

    Ask perl to help you
        You can ask perl itself to help you find common programming mistakes
        by doing two things: enable warnings (perldoc warnings) and enable
        "strict"ures (perldoc strict).

        You should not bother the hundreds/thousands of readers of the
        newsgroup without first seeing if a machine can help you find your
        problem. It is demeaning to be asked to do the work of a machine. It
        will annoy the readers of your article.

        You can look up any of the messages that perl might issue to find
        out what the message means and how to resolve the potential mistake
        (perldoc perldiag). If you would like perl to look them up for you,
        you can put "use diagnostics;" near the top of your program.

    Do not re-type Perl code
        Use copy/paste or your editor's "import" function rather than
        attempting to type in your code. If you make a typo you will get
        followups about your typos instead of about the question you are
        trying to get answered.

    Provide enough information
        If you do the things in this item, you will have an Extremely Good
        chance of getting people to try and help you with your problem!
        These features are a really big bonus toward your question winning
        out over all of the other posts that you are competing with.

        First make a short (less than 20-30 lines) and *complete* program
        that illustrates the problem you are having. People should be able
        to run your program by copy/pasting the code from your article. (You
        will find that doing this step very often reveals your problem
        directly. Leading to an answer much more quickly and reliably than
        posting to Usenet.)

        Describe *precisely* the input to your program. Also provide example
        input data for your program. If you need to show file input, use the
        __DATA__ token (perldata.pod) to provide the file contents inside of
        your Perl program.

        Show the output (including the verbatim text of any messages) of
        your program.

        Describe how you want the output to be different from what you are
        getting.

        If you have no idea at all of how to code up your situation, be sure
        to at least describe the 2 things that you *do* know: input and
        desired output.

    Do not provide too much information
        Do not just post your entire program for debugging. Most especially
        do not post someone *else's* entire program.

    Do not post binaries, HTML, or MIME
        clpmisc is a text only newsgroup. If you have images or binaries
        that explain your question, put them in a publically accessible
        place (like a Web server) and provide a pointer to that location. If
        you include code, cut and paste it directly in the message body.
        Don't attach anything to the message. Don't post vcards or HTML.
        Many people (and even some Usenet servers) will automatically filter
        out such messages. Many people will not be able to easily read your
        post. Plain text is something everyone can read.

  Social faux pas to avoid

    The first two below are symptoms of lots of FAQ asking here in clpmisc.
    It happens so often that folks will assume that it is happening yet
    again. If you have looked but not found, or found but didn't understand
    the docs, say so in your article.

    Asking a Frequently Asked Question
        It should be understood that you may have missed the applicable FAQ
        when you checked, which is not a big deal. But if the Frequently
        Asked Question is worded similar to your question, folks will assume
        that you did not look at all. Don't become indignant at pointers to
        the FAQ, particularly if it solves your problem.

    Asking a question easily answered by a cursory doc search
        If folks think you have not even tried the obvious step of reading
        the docs applicable to your problem, they are likely to become
        annoyed.

        If you are flamed for not checking when you *did* check, then just
        shrug it off (and take the answer that you got).

    Asking for emailed answers
        Emailed answers benefit one person. Posted answers benefit the
        entire community. If folks can take the time to answer your
        question, then you can take the time to go get the answer in the
        same place where you asked the question.

        It is OK to ask for a *copy* of the answer to be emailed, but many
        will ignore such requests anyway. If you munge your address, you
        should never expect (or ask) to get email in response to a Usenet
        post.

        Ask the question here, get the answer here (maybe).

    Beware of saying "doesn't work"
        This is a "red flag" phrase. If you find yourself writing that,
        pause and see if you can't describe what is not working without
        saying "doesn't work". That is, describe how it is not what you
        want.

    Sending a "stealth" Cc copy
        A "stealth Cc" is when you both email and post a reply without
        indicating *in the body* that you are doing so.

  Be extra cautious when you get upset

    Count to ten before composing a followup when you are upset
        This is recommended in all Usenet newsgroups. Here in clpmisc, most
        flaming sub-threads are not about any feature of Perl at all! They
        are most often for what was seen as a breach of netiquette. If you
        have lurked for a bit, then you will know what is expected and won't
        make such posts in the first place.

        But if you get upset, wait a while before writing your followup. I
        recommend waiting at least 30 minutes.

    Count to ten after composing and before posting when you are upset
        After you have written your followup, wait *another* 30 minutes
        before committing yourself by posting it. You cannot take it back
        once it has been said.

AUTHOR
    Tad McClellan <tadmc@augustmail.com> and many others on the
    comp.lang.perl.misc newsgroup.



------------------------------

Date: 20 Sep 2001 00:05:17 -0700
From: altair_04@altavista.com (Altair04)
Subject: Re: Problem with DBI+DBD MySQL, using fetchall_arrayref and dereferencing with random function
Message-Id: <54d5ca0a.0109192305.cc9cdb5@posting.google.com>

Shame on meeeeeeeeeeeeeeeeeeeeeeeeeeeee

Thanks a lot :)


------------------------------

Date: Thu, 20 Sep 2001 11:44:14 +0200
From: "François" <feric@gti-info.com>
Subject: Problem with Object Oriented Perl
Message-Id: <9ocdna$hcl$1@d03.completel.fr>

Hello,

I'm a beginner with Object Oriented Programming with Perl and am having a
problem at the base.  When I create 2 objects of a same class, the 2
instances contain the same information even though the constructor is
different.  I have made a small example to illustrate this

#############
program test.pl
#############

use Team;

my $t1 = "Penguins";
my $t2 = "Bulls";

my $tObj1 = new Team($t1);
my $tObj2 = new Team($t2);

printf "Team1: %s\nTeam2: %s\n",$tObj1->getName,$tObj2->getName;

#############
Class Team.pl
#############

package Team;

sub new {
  my ($self) = {};
  bless $self;
  $self->initialize($_[1]);
  return $self;
}
sub initialize {
  my $self = shift;
  $self{NAME} = $_[0];
}

sub getName {
  my $self = shift;
  return $self{NAME};
}
1;

#############
Execution Result
#############
Team1: Bulls
Team2: Bulls

I don't understand why team 1 isn't named Penguins.  In fact, even though I
create 2 different instances (or so it seems) when I modify one of the two,
the other one is also modified.  Does anybody know what I'm doing wrong .

Thank you

François




------------------------------

Date: Thu, 20 Sep 2001 11:58:55 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Problem with Object Oriented Perl
Message-Id: <j3fjqt8aisp9uformasn365n87rsolel4r@4ax.com>

Salut,

On Thu, 20 Sep 2001, "François" <feric@gti-info.com> wrote:
>I'm a beginner with Object Oriented Programming with Perl and am having a
>problem at the base.  When I create 2 objects of a same class, the 2
>instances contain the same information even though the constructor is
>different.  I have made a small example to illustrate this

You should "use strict;" - that would've alerted you to the problems
your code has:

>sub new {
>  my ($self) = {};
>  bless $self;
>  $self->initialize($_[1]);
>  return $self;
>}

Try instead:

sub new {
  my $proto = shift;
  # get proper classname
  my $class = ref( $proto ) || $proto;
  my $self = {};

  # important for derived classes that
  # don't implement their own constructor  
  bless $self, $class;

  $self->{'NAME'} = shift;

  return $self;
}

and

>sub getName {
>  my $self = shift;
>  return $self{NAME};
>}

sub getName {
  my $self = shift;
  # $self is a hash ref, not a hash!
  return $self->{'NAME'};
}

>I don't understand why team 1 isn't named Penguins.  In fact, even though I
>create 2 different instances (or so it seems) when I modify one of the two,
>the other one is also modified.  Does anybody know what I'm doing wrong .

Yey. You were creating a hash ref for each object, but then you stored
your data in a global hash %self. "use strict" would have given you a
warning that told you that %self wasn't defined.

HTH,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


------------------------------

Date: Thu, 20 Sep 2001 09:15:11 +0200
From: "JJ" <jocke30_gbg@hotmail.com>
Subject: Problems with $ character
Message-Id: <9oc50n$ns8$1@vg170.it.volvo.se>

Hi,

Problem 1.
Step 1.1: I have a perl script that collects table names from a Oracle
database.
Step 1.2: In that script it then execute another perl script with the table
as argument, that extracts the table (data and structure).

The table name from step 1.1 can contain the character '$' such as
'MLOG$_WI_PISECTIONUS'. When executing the second script it says:
"Table MLOG does not exist"

Earlier when I executed those scripts on Linux it worked with the fix in the
first script:
$replace='\$';
while(@row = $sth->fetchrow_array())
{
  $tmp = $row[0];
  # fix the '$' in the table name if it exist
  $tmp =~ s/\$/$replace/g; ## <<<== The fix <<<<
  push @tables, $tmp;
}

# For each table, dump the data
foreach $table ( @tables )
{
  $outfile = "$dataDir$table$dumpFileExtension";
  print "Dumping table $table for schema $dbSchema\n";
  $command = "./oracledump_to_mySQL.pl --add-drop-table -u $dbSchema -p
$password $database $table >> $outfile";
  system($command);
}

Now when have moved it to Solaris this doesn't work.
Why?


Problem 2:
I also need to execute a system command '. $SOEORA_SETUP dtim1t' but here is
the '$' character again and it doesn't work.
How can I solve this and execute it in my Perl script?


Best regards
Joacim Jarkeborn






------------------------------

Date: Thu, 20 Sep 2001 12:51:07 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Problems with $ character
Message-Id: <slrn9qjmrk.8ve.tadmc@tadmc26.august.net>

JJ <jocke30_gbg@hotmail.com> wrote:
>

>The table name from step 1.1 can contain the character '$' such as
>'MLOG$_WI_PISECTIONUS'. When executing the second script it says:
>"Table MLOG does not exist"
>

>  $tmp = $row[0];

This will escape punctuation characters too:

   $tmp = quotemeta $row[0];


>  $command = "./oracledump_to_mySQL.pl --add-drop-table -u $dbSchema -p
>$password $database $table >> $outfile";

>Now when have moved it to Solaris this doesn't work.
>Why?


I dunno, but you can usually convince shells to ignore metacharacters
by enclosing them in single quotes. I'd try that.

   ... $database $table >> '$outfile'";


>Problem 2:
>I also need to execute a system command '. $SOEORA_SETUP dtim1t' but here is
>the '$' character again and it doesn't work.
                                ^^^^^^^^^^^^

What does that mean?

Note that whatever $SOEORA_SETUP does will go away when the
system() call is done. The environment changes it makes won't 
be there for subsequent system calls.


>How can I solve this and execute it in my Perl script?


The same way that you would solve it on the command line without perl.

You have a shell question rather than a perl question. You can
test this by print()ing $command, then copy/paste it at the
shell prompt and see if it works.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 1779
***************************************


home help back first fref pref prev next nref lref last post