[17379] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4801 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 3 00:05:28 2000

Date: Thu, 2 Nov 2000 21:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <973227907-v9-i4801@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 2 Nov 2000     Volume: 9 Number: 4801

Today's topics:
    Re: 1+(-1)=? can be 0 or 2, depending on context (Tony L. Svanstrom)
    Re: @ARGV and Absolute URL (BUCK NAKED1)
    Re: Beginner help with code <dsimonis@fiderus.com>
    Re: embedded variables in a file <m.nine.six@freesurf.ch>
    Re: embedded variables in a file (Tad McClellan)
    Re: garbage collecting hashes are slow (Gwyn Judd)
    Re: Getting NT Domain Full Names with Win32::NetAdmin <dave_at_hm@hotmail.com>
    Re: i'm in 'use vars' hell <michael-a-mayo@worldnet.att.net>
        mmm Simple but how? Newbie needs help <markscott@barclays.net>
    Re: mmm Simple but how? Newbie needs help (Jon Bell)
    Re: mmm Simple but how? Newbie needs help (Tad McClellan)
        Perl\Tk problem from newbie <flsq@home.com>
    Re: Removing carriage returns from cgi <harrisr@bignet.net>
    Re: Removing carriage returns from cgi (Tad McClellan)
    Re: Removing carriage returns from cgi (Ameen Dausha)
    Re: String manipulation?? <james@NOSPAM.demon.co.uk>
    Re: String manipulation?? <jeffp@crusoe.net>
        troubles with non-blocking win32::pipe <anthonyc@mincom.com>
        Zone to host data <peter.sundstrom@eds.com>
    Re: Zone to host data (NP)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 03 Nov 2000 04:45:15 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: 1+(-1)=? can be 0 or 2, depending on context
Message-Id: <1ejiaie.z95vk9srspqyN%tony@svanstrom.com>

Ren Maddox <ren.maddox@tivoli.com> wrote:

> Helmut.Richter@lrz-muenchen.de (Helmut Richter) writes:
> 
> > The output of the entire program is:
> > 
> > +++++old: coeff{i}=
> > +++++coe=+1, coeff{i}=1
> > +++++old: coeff{i}=1
> > +++++coe=-1, coeff{i}=2
> > +++++old: coeff{i}=
> > +++++coe=+1, coeff{i}=1
> > +++++old: coeff{i}=1
> > +++++coe=-1, coeff{i}=0
> 
> Not for me.  I get:
> 
> +++++old: coeff{i}=
> +++++coe=+1, coeff{i}=1
> +++++old: coeff{i}=1
> +++++coe=-1, coeff{i}=0
> +++++old: coeff{i}=
> +++++coe=+1, coeff{i}=1
> +++++old: coeff{i}=1
> +++++coe=-1, coeff{i}=0

Same here, using MacPerl version 5.20r4, patchlevel 5.004.
(If I hadn't been so lazy right now I'd test it on some other platforms
to, but... :)


     /Tony... me tired... me go sleep now...
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Thu, 2 Nov 2000 22:14:48 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: @ARGV and Absolute URL
Message-Id: <17178-3A023BB8-12@storefull-248.iap.bryant.webtv.net>

Hi Richard,
And thank you for your response.
 
> > dennis100@webtv.net writes: 
> > Here is the part of my script where I'm > > having a problem. Why
doesn't            > > $ARGV[0} work? 

> Richard=A0J.=A0Rauenzahn wrote:
> What exactly are you expecting @ARGV to do? 
> use LWP::Simple;
> use MIDI; 
>
getstore("http://downtowndisco.hypermart.net/mid/a-f/fifth_of_beethoven.mi=
d",
$file ); 
> my $o =3D MIDI::Opus->new( { 'from_file' =3D> $ARGV[0] } );
> my @tracks =3D $o->tracks; 
> print "$ARGV[0] Midi has ", scalar(@tracks), " tracks\n"; 
>What do you expect $ARGV[0] to 
> contain and why?

I thought that the URL that was delivered by getstore would
automatically be read into @ARGV, and I expected the first $ARGV[0] to
get the contents of the getstore URL, and I expected my 2nd $ARGV[0] to
print the URL.

FWIW, the script above will work fine if I change the ARGV's to a
filehandle, but I need to read in URL's that are not on my server...
thus the LWP getstore.

Regards,
Dennis



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

Date: Thu, 02 Nov 2000 10:51:10 -0500
From: Drew Simonis <dsimonis@fiderus.com>
Subject: Re: Beginner help with code
Message-Id: <3A018D6E.F2EC2E4@fiderus.com>

Michael Segulja wrote:
> 
> I query the main table (mp3main) on artist.  This returns a list of all
> the artists if I print this out to STDOUT.  However, they are listed
> multiple times, so I then want to take those artists and insert them
> into a temporary table with a UNIQUE INDEX so duplicates will not be
> inserted.  Then I will run a query on the temporary table and send that
> output to the web page.  It is partly working because I get my
> AUTO_INCREMENT artistid field up to 105, which is correct for the
> number of unique artists I have.  However, that artist column is empty,
> and I don't know why.
> 

<snip>

> my $statement = "SELECT artist FROM mp3main";

This isn't a Perl problem, its a SQL problem.

my $statement = "SELECT DISTINCT artist FROM mp3main";

Don't over complicate things.


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

Date: Fri, 03 Nov 2000 04:25:01 +0100
From: "m.nine.six" <m.nine.six@freesurf.ch>
To: Tad McClellan <tadmc@metronet.com>
Subject: Re: embedded variables in a file
Message-Id: <3A02300C.112974F2@freesurf.ch>

Tad McClellan wrote:
> 
> On Fri, 03 Nov 2000 00:16:45 +0100, m.nine.six <m.nine.six@freesurf.ch> wrote:
> >Tad McClellan wrote:
> >>
> >> On Thu, 02 Nov 2000 13:27:05 +0100, m.nine.six <m.nine.six@freesurf.ch> wrote:
> >>
> >> >i have some vars embedded in the text file i wishes to read... and when
> >> >i print the contents, those vars are just printing as $var, rather than
> >> >the contents of $var...
> >>
> >> You seem to be missing the distinction between what is code
> >> and what is data.
> >>
> >> Perl FAQ, part 4:
> >>
> >>    "How can I expand variables in text strings?"
> >
> >this faq suggests me that i should use regex matching. and i thinks
> >that's not the best way to do this.
> 
> OK, perhaps.
> 
> But you can't just say "not the best way" without justifying it
> somehow.
> 
> What is not good about it?
> 
> What is good about your proposed alternative?
> 
> >anyway i found a way and i have the opinion that this should go into
> >this faq.
> 
> Never in a hundred million years should that go in the FAQ.

ok i believe you.

i guess also that you are a little bit excited about suggestion.

those are the reasons why i told it's better:

- it's only one line of code
- i guess it's also faster than the regex matching and replacing.
- with the regex matching i can't have '$' sign in the text. if i would
do that the regex matching would be more complicated.
- i also thought about the security. as far as i know this `eval
"qq/$str/"` line doesn't execute the perlfunc and user defined functions
in it. so "cracker" could not even change a string or an array. (i could
be wrong).

> 
> In the general case though, it may open the door for a cracker.

more generaly you are right. it could be a very dangerous backdoor.
(even if i don't know how.)

> 
> Go ahead and use it, maybe we'll hear about you on the 6 o'clock news...
> 

damn. i don't have a tv. so i can't watch myself. heheh... sorry was a
joke...

> >this will work and print the $line as "/home/user/template";
> 
> "will work" does not imply "better".

yes, i know.

> 
> Give a reason or two for your assertions please.
> 

by the way: as i guess you are a good perl coder. so could you tell me
the difference between eval {} and eval "" ?? in this case i wrote eval
"" works and eval {} does not. i would like to know why....


thanks a lot for your feedback and your opinion.
best regards,
alias m.nine.six.


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

Date: Thu, 2 Nov 2000 22:27:22 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: embedded variables in a file
Message-Id: <slrn904c4q.128.tadmc@magna.metronet.com>


[ Please do not send me any more stealth Cc'd email messages
  (or any email messages at all)

  Thank you.
]

On Fri, 03 Nov 2000 04:25:01 +0100, m.nine.six <m.nine.six@freesurf.ch> wrote:
>Tad McClellan wrote:

>> Never in a hundred million years should that go in the FAQ.
>
>ok i believe you.
>
>i guess also that you are a little bit excited about suggestion.


No. I am appalled at the suggestion. 


>those are the reasons why i told it's better:
>
>- it's only one line of code


So is a pattern match.


>- i guess it's also faster than the regex matching and replacing.
   ^^^^^^^

Guesses do not go in FAQs.

Do some benchmarking and _know_ if it is faster.

I very seriously doubt that it is faster.


>- with the regex matching i can't have '$' sign in the text. 


Yes you can.

You just put a backslash character in front of it.


>if i would
>do that the regex matching would be more complicated.


If you would do what? Put in a dollar sign? Adding a backslash
character _would_ be a very tiny bit more complicated, it's only
one character after all.


>- i also thought about the security. as far as i know this `eval
                                      ^^^^^^^^^^^^^^^^

You have not yet thought about security enough.

Go do some more of that  :-)


>"qq/$str/"` line doesn't execute the perlfunc and user defined functions
>in it. so "cracker" could not even change a string or an array. (i could
>be wrong).


"could be"?. Guesses do not go in FAQs. Get a grip on reality.

   eval "qq/$str/"

Whether or not that is dangerous depends on where the value
of $str came from, which you have not shared with us.


>> In the general case though, it may open the door for a cracker.
>
>more generaly you are right. it could be a very dangerous backdoor.
>(even if i don't know how.)
            ^^^^^^^^^^

People that don't know stuff do not write FAQs. People that
know stuff write FAQs (that's why your "solution" isn't in
there).

It's nice of you to try and help, but you are not qualified
enough yet. Learn a bit more Perl first.


Since you don't know how that code could be dangerous, I'll
show you how:

-----------------
#!/usr/bin/perl -w
use strict;

my $str = '$ARGV[ print "Kaboom!!"]';

eval "qq/$str/";
-----------------

Now imagine if it was

   unlink <* .*>

there instead of a print().

Like what you see?

String eval is evil. Everyday programmers should not even know
that it exists, let alone use it.



>could you tell me
>the difference between eval {} and eval "" ?? 


In addition to what you have doubtless already read about
eval() in perlfunc.pod, I can add this:


   One of them is the kind of eval() that you can use,
   and one of them is the kind that you cannot use.

   :-)


>in this case i wrote eval
>"" works and eval {} does not. i would like to know why....


I cannot troubleshoot imaginary code yet. Sorry.


But neither form of eval() is appropriate for

   expanding variables in text strings


(though some of the FAQ answers _do_ use eval. twice even)


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


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

Date: Fri, 03 Nov 2000 02:28:38 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: garbage collecting hashes are slow
Message-Id: <slrn9048mi.a8t.tjla@thislove.dyndns.org>

I was shocked! How could Fulko Hew <fulko@wecan.com>
say such a terrible thing:
>My app generates and clears a large number of hashes.

>If you do the single sets, (on my machine) each set takes about
>55 usec.  Adding the clear statement ups the loop time to 800 usec.

I don't get the same results as you with virtually the same code. Can
you post the script you use the do the benchmarking?

By the way, my informal testing suggest using undef on the hash is a
little quicker than assigning an empty list to the hash while not
clearing it at all is the quickest. Slowest of all is having %b a
lexically scoped variable using my() and letting it go out of scope but
the difference between all of them is not as huge as you say.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
You have acquired a scroll entitled 'irk gleknow mizk'(n).--More--

This is an IBM Manual scroll.--More--

You are permanently confused.
		-- Dave Decot


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

Date: Thu, 02 Nov 2000 19:58:38 -0800
From: Dave E <dave_at_hm@hotmail.com>
Subject: Re: Getting NT Domain Full Names with Win32::NetAdmin
Message-Id: <3A0237EE.98D0B66E@hotmail.com>



"Dr. Strangepork" wrote:

> I can get users' full names with Win32::NetAdmin::GetUsers($PDC,
> FILTER_NORMAL_ACCOUNT , \%Users), but considering I have almost 8,000
> user accounts in my domain, I'd rather not get the entire user database
> just to match one user's fullname.  Is there an easier way to get the
> fullname of a user account?
>
> --
> Rick Kasten, MCSE         SysAdmin Consultant
> Collective Technologies   http://www.colltech.com

Hi Rick,

Win32API::Net::UserGetInfo($server, $user, 2, \%info);
will do the trick.

    David...



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

Date: Fri, 03 Nov 2000 03:48:50 GMT
From: "Michael Mayo" <michael-a-mayo@worldnet.att.net>
Subject: Re: i'm in 'use vars' hell
Message-Id: <CAqM5.17972$xJ4.875767@bgtnsc06-news.ops.worldnet.att.net>


"Brian McDonald" <mcdonabNO@SPAMyahoo.com> wrote in message
news:Zd4M5.11940$Wq1.7704488@nnrp5-w.sbc.net...
> what method will allow me to *not* have to explicitly name every
variable in
> the 'use vars' declaration? ...a method that does not require me to
create a
> single global variable by way of a hash? (which reminds me... why is
this
> done? what is the value of the giant hash?)

    I tend to agree with you that a hash is not the correct solution
to this problem.  A hash is best thought of as a data structure made
up of a collection of _related_ or _similar_ key/value pairs.  If you
don't want the safety features imposed by 'use strict vars',
explicitly don't use strict vars.  If you want to declare a lot of
variables neatly in one place, place them into a separate package and
export the variables. IMHO, using a hash as a means of sneaking around
'use strict vars' is bad style.

    You wouldn't consider stuffing a bunch of unrelated values into a
linked list just because you didn't feel like declaring the variables.
Using a hash for the same job is almost as confusing.

    So, I would say that the preferred perl solution is either
a)turning off strict vars or b)declaring the vars in a separate
package and exporting them.

                   -Mike




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

Date: Fri, 3 Nov 2000 02:23:09 -0000
From: "mark" <markscott@barclays.net>
Subject: mmm Simple but how? Newbie needs help
Message-Id: <3a02212b@news.jakinternet.co.uk>

Apologies in advance for not getting the picture!!!

I'm very new to perl and CGI, and in simple terms What's the
main difference between Perl and CGI? What is the factor that clicks
in to say "Ha Perl Script or Ha ha! CGI Script?

Okay the next problem has been sending me up the wall. Ive spent too
much time going in circles and I'm looking for a rope to help me out!
(Thanks if you think I should be Hanged)

All I want to do is from a web page, get the visitors IP time stamp it and
append to a html doc that I can view. But the visitor does not have to
activate this action. (possibly onload, not sure of correct code)
Ive checked most of the FAQ and there seems at the moment too many different
examples of each individual area of code I'm working on. And when I try
and patch them together I get soup!!

Thank you if you can help and when I get to be an expert (Dreaming)
I will guide you and help you. Please help thanks Mark...




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

Date: Fri, 3 Nov 2000 04:08:56 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: mmm Simple but how? Newbie needs help
Message-Id: <G3FKux.7M3@presby.edu>

In article <3a02212b@news.jakinternet.co.uk>,
mark <markscott@barclays.net> wrote:
>
>I'm very new to perl and CGI, and in simple terms What's the
>main difference between Perl and CGI? 

CGI is a *protocol*, a set of rules that define how an HTTP client (i.e. a
Web browser) communicates with an application (a "CGI script") on an HTTP
server, that the server runs on request by the client.  Both the client
and the CGI script must follow must follow the rules of the CGI protocol
in order for communication to take place properly.

Perl is a general-purpose programming language which can be used to write
CGI scripts, among many other things.  Other languages (e.g. C and C++)
are also used for writing CGI scripts.  Perl is commonly used for CGI
scripts because it happens to have strong text-manipulation facilities
(pattern-matching etc.).  But there are a lot of Perl scripts that have
nothing to do with CGI.  I myself have worked with Perl for several years,
but have not (so far) written a single CGI script.

>What is the factor that clicks
>in to say "Ha Perl Script 

If it's written in Perl, it's a Perl script.

>or Ha ha! CGI Script?

If it runs on an HTTP server and conforms to the CGI protocol, it's a CGI
script.

-- 
Jon Bell <jtbell@presby.edu>                        Presbyterian College
Dept. of Physics and Computer Science        Clinton, South Carolina USA
[ Questions about newsgroups?  Visit http://www.geocities.com/nnqweb/  ]
[                or ask in news:news.newusers.questions                ]


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

Date: Thu, 2 Nov 2000 22:56:11 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: mmm Simple but how? Newbie needs help
Message-Id: <slrn904dqr.128.tadmc@magna.metronet.com>

On Fri, 3 Nov 2000 02:23:09 -0000, mark <markscott@barclays.net> wrote:

>Apologies in advance for not getting the picture!!!


Not getting the picture is not something you need to apologize for.

Not checking the Perl FAQ before posting to the Perl newsgroup,
now _that_ is something you should apologize for.

If you plan to be on Usenet, you should visit the
  news.announce.newusers   newsgroup.


>I'm very new to perl and CGI, 

Type:

   perldoc -q CGI

   "Where can I learn about CGI or Web programming in Perl?"

   [ list of URLs ]

The FAQs are your friends. Find FAQs. Read them.



>and in simple terms What's the
>main difference between Perl and CGI? 


One is an apple and one is an orange.

One is a general purpose programming language and one is
an interface specification.

They are so dissimilar that they cannot be compared.


>What is the factor that clicks
>in to say "Ha Perl Script 


Perl is most often used in non-CGI environments, but since
it is a general purpose programming language, you can write
programs that communicate using the Common Gateway Interface
with it too.


>or Ha ha! CGI Script?


CGI is an interface. A specification of how the communication
between the computers involved works.

You can write programs in just about any language that use
the Common Gateway Interface.

You get to choose whatever programming language you like
to write CGI programs in.

Many people choose to use Perl for that too.



I suggest learning one thing at a time.

First learn how to program in Perl (from the command line).

Then, after you are comfortable with Perl programming, turn
your attention to CGI programming with Perl.


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


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

Date: Fri, 03 Nov 2000 02:13:28 GMT
From: Shawn and Francine <flsq@home.com>
Subject: Perl\Tk problem from newbie
Message-Id: <3A021F64.1A1214AB@home.com>

I have just begun to learn Perl/Tk and am having a problem with the
snipet below.  I can't seem to load
$temp to with the value stored in $window.  I am sure it something
simple, could someone please
throw me a bone?


Thanks in advance

<snip>
use Tk;

$Text = $frame0 -> Entry(-textvariable=>\$window);
$Mult = $frame2 -> Button(-text=>"X",
     -command =>sub{$temp=$window},
     -command =>sub{$state=1},
     -command =>sub{$window=""});
$Text = $frame0 -> Entry(-textvariable=>\$window);
$Enter = $frame4 -> Button(-text => "Enter",
       -command =>\&do_it);

MainLoop:

sub do_it
{
     if($state = 1)
     {
          $window=$temp*$window;
          $state=0;
     }
}




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

Date: Thu, 2 Nov 2000 21:53:52 -0500
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: Removing carriage returns from cgi
Message-Id: <t04a4t5p11c2b2@corp.supernews.com>

John <gods-apollo@home.com> wrote in message
news:9noM5.45612$E85.1153991@news1.sttls1.wa.home.com...
> I have an input form with several <textareas>.
>
> Here is the code I pull it down with.
>
> unless (@mailingaddress = $query->param('mailingaddress'))
> {
>  print_empty("Mailing Address");
> }
> for ($i=0; $i < @mailingaddress; $i++)
> {
>  $mailingaddres[$i] =~ s/\\/&#92;/g;
>  chomp($mailingaddress[$i]);
> }
>
> When I go to write mailingaddress to a file.. I get those damned ^M
all over
> the place.
>
> I can't seem to take those out.. I though chomp would have done it.  I
used
> =~ s/\n/<BR>/g .. when I use =~ s/\n//g ... that doesn't seem to do a
damn
> thing.
>

I believe that ^M is represented by \r not \n.
RH

> Anyone know how to take the ^M out from the input into an array?
>
> John
>
>




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

Date: Thu, 2 Nov 2000 20:41:37 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Removing carriage returns from cgi
Message-Id: <slrn9045uh.uk.tadmc@magna.metronet.com>

On Fri, 03 Nov 2000 01:17:57 GMT, John <gods-apollo@home.com> wrote:

>for ($i=0; $i < @mailingaddress; $i++)
>{
> $mailingaddres[$i] =~ s/\\/&#92;/g;
> chomp($mailingaddress[$i]);
>}


You are writing C code in Perl. Hair will grow on the palms of
your hands if you don't stop that:

   foreach my $address ( @mailingaddress ) {
      $address =~ s/\\/&#92;/g;
      chomp $address;
   }

or even

   foreach ( @mailingaddress ) {
      s/\\/&#92;/g;
      chomp;
   }


No index variable to manage. No chance of messing up the indexing,
Perl does the indexing for you.


>I can't seem to take those out.. I though chomp would have done it.  


What did you see/read that made you think chomp would help?


>I used
>=~ s/\n/<BR>/g .. when I use =~ s/\n//g ... that doesn't seem to do a damn
>thing.


Because \n is the linefeed character, not the carriage return character.


>Anyone know how to take the ^M 

^M is just how Unixish systems display it. The character's official
(ASCII) name is "carriage return".

\r is a carriage return in Perl's double-quotish places,
such as a pattern.


>out from the input into an array?


   tr/\r//d foreach @mailingaddress;


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


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

Date: Fri, 03 Nov 2000 03:37:55 GMT
From: ameen @ dausha . net (Ameen Dausha)
Subject: Re: Removing carriage returns from cgi
Message-Id: <3a0232b0.1618037@news>

The answer is:

$mailingaddress =~ s/\r//sg;

The \r is the carriage return, part of the MS-DOS newline group
(\n\r).

"perldoc perlr" I believe is what gives you the manpage on Regex.

On Fri, 03 Nov 2000 01:17:57 GMT, "John" <gods-apollo@home.com> spat:

>I have an input form with several <textareas>.
>
>Here is the code I pull it down with.
>
>unless (@mailingaddress = $query->param('mailingaddress'))
>{
> print_empty("Mailing Address");
>}
>for ($i=0; $i < @mailingaddress; $i++)
>{
> $mailingaddres[$i] =~ s/\\/&#92;/g;
> chomp($mailingaddress[$i]);
>}
>
>When I go to write mailingaddress to a file.. I get those damned ^M all over
>the place.
>
>I can't seem to take those out.. I though chomp would have done it.  I used
>=~ s/\n/<BR>/g .. when I use =~ s/\n//g ... that doesn't seem to do a damn
>thing.
>
>Anyone know how to take the ^M out from the input into an array?
>
>John
>
>



Ben Wilson (a.k.a. Ameen, Last of the Dausha)
____________________________
-"Ever heard of Aristotle . . . Plato . . . Socrates?!"
-"Yes."
-"Morons!"


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

Date: Fri, 3 Nov 2000 02:24:19 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: String manipulation??
Message-Id: <ant030219568fNdQ@oakseed.demon.co.uk>

In article <Pine.GSO.4.21.0011021711440.25313-100000@crusoe.crusoe.net>,
Jeff Pinyan <URL:mailto:jeffp@crusoe.net> wrote:
>
> On Nov 2, Murx Cedarstorm said:
> >
> >    open(readFile, $_[0]) || die;
> >    $_[1] = <readFile>;
> >    close(readFile);
> >
> > and it's called like this:
> >
> >    &_read("template.dat",@template);
> >
> 
> The problem is that you are trying to populate an array in a way that will
> not work.  My guess is @template is empty, and you are trying to fill it
> with the lines in the file.  You COULD do it like this:
> 
>   sub _read {
>     open FILE, "< $_[0]" or die "can't read $_[0]: $!";
>     @{ $_[1] } = <FILE>;
>     close FILE;
>   }
> 
>   _read("foo.bar", \@array);

If the subroutine definition included a prototype of ($\@) then he would
not have to remember to put a \ in front @array each time. He could also
use Tom's clever typeglob assignment to avoid the messy dereference syntax
in the subroutine. It might look something like this *untested* code:

    sub _read ($\@) {
        my $filename = shift;
        local *ary = shift;
        local *FILE;

        open FILE, "< $filename" or die "Can't read $filename: $!";
        @ary = <FILE>;
        close FILE;
    }
  
    _read "foo.bar", @array;

Here the @array is passed by reference implicitly in the call, and in
the sub the local name of @ary can be used simply as a normal array.
If I've got that correct, then it seems you can have your cake and eat
it too in Perl. :-)

-- 
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



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

Date: Thu, 2 Nov 2000 21:37:22 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: String manipulation??
Message-Id: <Pine.GSO.4.21.0011022136250.25313-100000@crusoe.crusoe.net>

[posted & mailed]

[Or else Tom Christiansen will eat me alive.]

On Nov 3, James Taylor said:

>> > and it's called like this:
>> >
>> >    &_read("template.dat",@template);
>> 
>>   _read("foo.bar", \@array);
>
>If the subroutine definition included a prototype of ($\@) then he would
>not have to remember to put a \ in front @array each time. He could also
>use Tom's clever typeglob assignment to avoid the messy dereference syntax
>in the subroutine. It might look something like this *untested* code:

Only if he used the non-& method of calling functions.  Once you use &,
all prototype bets are off.

-- 
Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/





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

Date: Fri, 3 Nov 2000 14:10:46 +1000
From: "Anthony Carbone" <anthonyc@mincom.com>
Subject: troubles with non-blocking win32::pipe
Message-Id: <8ttdrh$2s9$1@sol.mincom.oz.au>

Hi,

I'm having troubles trying to create a new server instance NON-BLOCKING
named pipe using the Win32::Pipe module from Roth.
The problem is that when I specify non-blocking using the following method
call :-
$Pipe = new Win32::Pipe( "bec_pipe_3336" , NMPWAIT_NOWAIT ,
PIPE_TYPE_BYTE );
and use the following method call to connect :-
if ($Pipe->Connect()) {
        $data = $Pipe->Read();
 .
 .
 .
}
It blocks !
Because I am running a service that has other things to do, it cannot afford
to block on the named pipe and wait indefinitely.
The 'NMPWAIT_NOWAIT' option is on roth's webpage and  I tracked debugged it
down to the Create function call (presumably in the DLL that comes with it),
where it converts these strings into numerics and passes it. I also checked
the MSDN to see if non-blocking is supported and it is so I cannot work out
why it won't create a non-blocking pipe.

Any help or examples would be very much appreciated.

thanks

anthonyc






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

Date: Fri, 3 Nov 2000 16:35:43 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Zone to host data
Message-Id: <8ttc0h$1fp$1@hermes.nz.eds.com>

I'm looking to convert zone data to host data, eg:

foo1.foo.com    IN A    192.1.1.1
foo2.foo.com    IN A    192.1.1.2
bar.foo.com      IN CNAME foo1.foo.com

would become

192.1.1.1    foo1.foo.com  bar.foo.com
192.1.1.2    foo2.foo.com

I'm unsure which way to approach this.  I need to keep the data in the same
order, so I was thinking of using the Tie::IxHash module and then use
hostname as the key.  Does this seem like a sensible approach?




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

Date: Fri, 03 Nov 2000 04:42:50 GMT
From: nvp@spamnothanks.speakeasy.org (NP)
Subject: Re: Zone to host data
Message-Id: <enrM5.41623$UP5.624980@news6.giganews.com>

peter.sundstrom@eds.com wrote:
: I'm looking to convert zone data to host data, eg:
: 
: foo1.foo.com    IN A    192.1.1.1
: foo2.foo.com    IN A    192.1.1.2
: bar.foo.com      IN CNAME foo1.foo.com

You could always use Net::DNS (as one suggestion).

-- 
Nate II


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4801
**************************************


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