[23143] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5364 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 15 03:05:48 2003

Date: Fri, 15 Aug 2003 00:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 15 Aug 2003     Volume: 10 Number: 5364

Today's topics:
    Re: Extremely Basic mySQL question. <bart.lateur@pandora.be>
    Re: Extremely Basic mySQL question. (Tad McClellan)
    Re: finding subdirectories without parsing every file (James Willmore)
    Re: hand crafting soap for google api's (Tad McClellan)
    Re: hand crafting soap for google api's (Tad McClellan)
    Re: hand crafting soap for google api's <scripts_you-know-the-drill_@hudsonscripting.com>
    Re: hand crafting soap for google api's <scripts_you-know-the-drill_@hudsonscripting.com>
    Re: Help w/ BNB Survey Script <-- <uri@stemsystems.com>
    Re: Help w/ BNB Survey Script <-- (Tad McClellan)
    Re: Help w/ BNB Survey Script <-- (Tad McClellan)
    Re: how to autovivify a package from a string <uri@stemsystems.com>
    Re: Newbie question !! <simon@unisolve.com.au>
    Re: Perl and recursive copying? (Tad McClellan)
    Re: Please offer critique on my 2nd JAPH <uri@stemsystems.com>
    Re: Please offer critique on my 2nd JAPH <spamblock@junkmail.com>
    Re: Please offer critique on my 2nd JAPH <uri@stemsystems.com>
    Re: Please offer critique on my 2nd JAPH (Jay Tilton)
    Re: populating anonymous arrays inside for loop? <REMOVEsdnCAPS@comcast.net>
    Re: Question about "eval" security <bart.lateur@pandora.be>
    Re: Question about "eval" security (Randal L. Schwartz)
    Re: question regarding multiple args to sub  <bwalton@rochester.rr.com>
        regex diffs between perl 5.6.1 and 5.8.0? <Patrick_member@newsguy.com>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 15 Aug 2003 01:23:30 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Extremely Basic mySQL question.
Message-Id: <kfdojv425psvoavlv464i6f126naj23foq@4ax.com>

Ivan Marsh wrote:

>Typically all FTP transfers are binary these days. There's no reason, that
>I know of anyway, to use ASCII transfer specificly.

The fact that fields might contain CR characters after import? Or none,
where there originally were?

-- 
	Bart.


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

Date: Thu, 14 Aug 2003 23:25:15 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Extremely Basic mySQL question.
Message-Id: <slrnbjoo5b.8bh.tadmc@magna.augustmail.com>

Tyler Cruz <tylercruz@hotmail.com> wrote:

> don't you have anything better to do than just flame?


If you take cuts in line you should _expect_ that you will
be called on it.

It was _you_ who posted a non-Perl question in the Perl newsgroup.

That is socially unacceptable in Usenet society, you may get
yelled at or ostracized or both or neither or worse. _You_ rolled
the dice so don't whine about getting snake eyes.


Why don't we just have _one_ newsgroup with tens of thousands of
daily messages, then you wouldn't have to fire up 5 brain cells
to decide which one your question should be posted to?



[snip TOFU]

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


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

Date: 14 Aug 2003 18:12:52 -0700
From: jwillmore@cyberia.com (James Willmore)
Subject: Re: finding subdirectories without parsing every file
Message-Id: <e0160815.0308141712.67b4eac2@posting.google.com>

> Is there any way to get the subdirectories of a directory without
> having to sort through all the files in a directory?
> <snip>
> I've been using file::find to generate the directory tree but it's too
> slow. I think the problem is that it looks at each file in the
> directory. I'm not interested in what's in the directory, I just want
> to know what the subdirectories are.

Ah.... but how far down the parent directory do you wish to search?
File::Find has a 'finddepth' method and a multitude of options.

Post your code and maybe we can lend more assistance.

HTH

Jim


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

Date: Thu, 14 Aug 2003 23:31:47 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: hand crafting soap for google api's
Message-Id: <slrnbjoohj.8bh.tadmc@magna.augustmail.com>

Hudson <scripts_you-know-the-drill_@hudsonscripting.com> wrote:

> But...all the examples I found used soap::light and that is not
> in my @INC on my server.


That's OK, it does not need to be in (the default) @INC on your server.


   perldoc -q module

      How do I keep my own module/library directory?


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


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

Date: Thu, 14 Aug 2003 23:39:39 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: hand crafting soap for google api's
Message-Id: <slrnbjop0b.8bh.tadmc@magna.augustmail.com>

Hudson <scripts_you-know-the-drill_@hudsonscripting.com> wrote:


> &print_prompt($query);


   perldoc -q "&"

      What's the difference between calling a function as &foo and foo()?


>     my $query_string = $query->param('domains');
>     my @domains = split(/\n/, $query_string);


You don't need a temporary variable:

   my @domains = split(/\n/, $query->param('domains'));


>         my $soap_request .= "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\">\n";
>         $soap_request .= "<SOAP-ENV:Body>\n";
>         $soap_request .= "<ns1:doGoogleSearch xmlns:ns1=\"urn:GoogleSearch\" \n";
>         $soap_request .= "SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n";
>         $soap_request .= "<key xsi:type=\"xsd:string\">***_your_key_here_***</key>\n";
>         $soap_request .= "<q xsi:type=\"xsd:string\">$keyword</q>\n";
>         $soap_request .= "<start xsi:type=\"xsd:int\">0</start>\n";
>         $soap_request .= "<maxResults xsi:type=\"xsd:int\">10</maxResults>\n";
>         $soap_request .= "<filter xsi:type=\"xsd:boolean\">true</filter>\n";
>         $soap_request .= "<restrict xsi:type=\"xsd:string\"></restrict>\n";
>         $soap_request .= "<safeSearch xsi:type=\"xsd:boolean\">false</safeSearch>\n";
>         $soap_request .= "<lr xsi:type=\"xsd:string\"></lr>\n";
>         $soap_request .= "<ie xsi:type=\"xsd:string\">latin1</ie>\n";
>         $soap_request .= "<oe xsi:type=\"xsd:string\">latin1</oe>\n";
>         $soap_request .= "</ns1:doGoogleSearch>\n";
>         $soap_request .= "</SOAP-ENV:Body>\n";
>         $soap_request .= "</SOAP-ENV:Envelope>";



Holy crap!

You really need to learn about "here-doc"s, see perlop.pod.

Look Ma! No backslashes!

   my $soap_request =<<ENDSOAP;
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body>
<ns1:doGoogleSearch xmlns:ns1="urn:GoogleSearch"
 ...
ENDSOAP



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


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

Date: Fri, 15 Aug 2003 02:53:42 -0700
From: Hudson <scripts_you-know-the-drill_@hudsonscripting.com>
Subject: Re: hand crafting soap for google api's
Message-Id: <kkapjv05vnfdd0aug1l9s8elpepilcv76f@4ax.com>

On Thu, 14 Aug 2003 23:31:47 -0500, tadmc@augustmail.com (Tad
McClellan) wrote:

>Hudson <scripts_you-know-the-drill_@hudsonscripting.com> wrote:
>
>> But...all the examples I found used soap::light and that is not
>> in my @INC on my server.
>
>
>That's OK, it does not need to be in (the default) @INC on your server.
>


ah...but I like doing it by hand! ;-)

(oh, and you should of seen me last week installing openssl in my
directory trying to get net::slleay working...hehe)


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

Date: Fri, 15 Aug 2003 03:01:33 -0700
From: Hudson <scripts_you-know-the-drill_@hudsonscripting.com>
Subject: Re: hand crafting soap for google api's
Message-Id: <afbpjv0ln2pt0coj2hf7mou1e3dagd1q83@4ax.com>

On Thu, 14 Aug 2003 23:39:39 -0500, tadmc@augustmail.com (Tad
McClellan) wrote:

>Hudson <scripts_you-know-the-drill_@hudsonscripting.com> wrote:
>
>
>> &print_prompt($query);
>
>
>   perldoc -q "&"
>
>      What's the difference between calling a function as &foo and foo()?

to tell you the truth, I really don't understand the cgi.pm and rather
like doing it by hand, but this is old code from last month.

>
>
>>         my $soap_request .= "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\">\n";
>>         $soap_request .= "<SOAP-ENV:Body>\n";
>>         $soap_request .= "<ns1:doGoogleSearch xmlns:ns1=\"urn:GoogleSearch\" \n";
>>         $soap_request .= "SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n";
>>         $soap_request .= "<key xsi:type=\"xsd:string\">***_your_key_here_***</key>\n";
>>         $soap_request .= "<q xsi:type=\"xsd:string\">$keyword</q>\n";
>>         $soap_request .= "<start xsi:type=\"xsd:int\">0</start>\n";
>>         $soap_request .= "<maxResults xsi:type=\"xsd:int\">10</maxResults>\n";
>>         $soap_request .= "<filter xsi:type=\"xsd:boolean\">true</filter>\n";
>>         $soap_request .= "<restrict xsi:type=\"xsd:string\"></restrict>\n";
>>         $soap_request .= "<safeSearch xsi:type=\"xsd:boolean\">false</safeSearch>\n";
>>         $soap_request .= "<lr xsi:type=\"xsd:string\"></lr>\n";
>>         $soap_request .= "<ie xsi:type=\"xsd:string\">latin1</ie>\n";
>>         $soap_request .= "<oe xsi:type=\"xsd:string\">latin1</oe>\n";
>>         $soap_request .= "</ns1:doGoogleSearch>\n";
>>         $soap_request .= "</SOAP-ENV:Body>\n";
>>         $soap_request .= "</SOAP-ENV:Envelope>";
>
>
>
>Holy crap!
>
>You really need to learn about "here-doc"s, see perlop.pod.
>
>Look Ma! No backslashes!
>
>   my $soap_request =<<ENDSOAP;
><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
><SOAP-ENV:Body>
><ns1:doGoogleSearch xmlns:ns1="urn:GoogleSearch"
>...
>ENDSOAP

yes, but with the ".=" method, you get to see all your request on one
page ;-)

I agree, through...backslashes suck....



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

Date: Fri, 15 Aug 2003 03:58:08 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Help w/ BNB Survey Script <--
Message-Id: <x71xvnzi5w.fsf@mail.sysarch.com>

>>>>> "LF" == Lori Fleetwood <chessql@highstream.net> writes:

  LF> I don't know how you've become so good with Perl with one half of your
  LF> brain apparently turned off: just because perl and usenet are not the
  LF> same does not mean that how people approach the two of them cannot be
  LF> compared.  You'd probably be a Perl god if you didn't think in such a
  LF> linear fashion all the time.  Perhaps you know this and the
  LF> frustration is why you can be such a d!ckhead at times.

but i AM a perl god. and you are not. nyah nyah nyah!!!

i bet that ticks you off but good. i am so uncivil.

and guess what, i am actually the social events coordinator for
yapc::NA. so my uncivil behavior is applauded by those who matter. you
unfortunately don't matter. as the other person replied to you, let's
see you post some answers here. and don't come back with that to me as i
have a proven (uncivil) track record of helping here. just check
google. 

:-)

uri, the perl god. bow down to my code!

<waiting for the inevitable mediocre comeback. just try, just try to
same something civil and witty. i triple dog dare ya!! i'll get you and
your little dog too! MUAHAHAHAHHAHA!>

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Thu, 14 Aug 2003 23:13:56 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Help w/ BNB Survey Script <--
Message-Id: <slrnbjong4.8bh.tadmc@magna.augustmail.com>

Uri Guttman <uri@stemsystems.com> wrote:

> i am actually the social events coordinator for
> yapc::NA.


Party on dude!


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


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

Date: Thu, 14 Aug 2003 23:27:33 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Help w/ BNB Survey Script <--
Message-Id: <slrnbjoo9l.8bh.tadmc@magna.augustmail.com>

Lori Fleetwood <chessql@highstream.net> wrote:
> Uri Guttman wrote:

> You'd probably be a Perl god 


But he _is_ one.

You've demonstrated that you don't really know much about
the Perl community quite clearly by this point.

You can stop now.


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


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

Date: Fri, 15 Aug 2003 04:02:29 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: how to autovivify a package from a string
Message-Id: <x7y8xvy3e2.fsf@mail.sysarch.com>

>>>>> "ES" == Eric Schwartz <emschwar@pobox.com> writes:

  ES> Uri Guttman <uri@stemsystems.com> writes:
  >> and most of them are not needed since perl is so dynamic. calling a
  >> scalar var some silly pattern name just because it can hold ANYTHING
  >> (which requires massive ugly pattern code in c++) is silly.

  ES> A pattern is just a way of thinking about a problem; it's not even an
  ES> algorithm.  I don't understand your apparent antipathy.

because the concept is oversold and reeks of emperor's new clothes. as i
said perl doens't even need most of the patterns. i program in perl. i
use to do massive amounts in c. i like perl since i don't have to do all
those insane workarounds (AKA patterns) in c to get complex stuff done.

  ES> The classic factory pattern implementation would wrap that table with
  ES> a function called CreateFoo(); that's hardly overkill.  Anyway, you
  ES> need some string to index that hash with, and using a factory pattern
  ES> doesn't require the user to know the details of how it's generated.

so call it a wrapper. i just don't like the term pattern as approporated
by the GoF. i didn't like the book. period. i felt it was preaching to
the choir and not teaching me anything.

  >> late binding and polymorphism are built in and do all the hard work.

  ES> They're helpful, surely, but a Command pattern is useful (especially
  ES> when keeping multilevel undo-redo stacks no matter when binding is
  ES> done, and polymorphism doesn't remove the need for it.  Adapter
  ES> patterns are pretty much always going to be required when you have an
  ES> existing class whose interface doesn't match that of the environment
  ES> you want to use it in.

i may use them but i call them solutions or algorithms or designs but
not patterns. see MJD's take on this at plover.com. i should read the
original pattern language book by alexander which i hear is really about
patterns and not oddly named coding designs.

  ES> Because if he's trying to do what I think he's trying to do, then a
  ES> factory would help.  If he's not, then nevermind.  Either way, more
  ES> clarification will help.

which is what we both have asked for and not received.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 15 Aug 2003 11:25:34 +1000
From: Simon Taylor <simon@unisolve.com.au>
Subject: Re: Newbie question !!
Message-Id: <bhhcta$28l0$1@otis.netspace.net.au>

Wesley Tam wrote:

> What is the different between ??
> 
> #!/usr/bin/perl -w
> and 
> #!/usr/bin/perl

When you add -w you're asking the perl compiler to warn you about
things in your code that may be errors.

When used with the "use strict" pragma, you'll find that perl will
catch lots of errors before they get out of hand.

Make a point of starting any program with:

#!/usr/bin/perl -w

use strict;

- or -

#!/usr/bin/perl

use strict;
use warnings;

> I'm newbie, I just start to learn perl

Welcome to perl.

Simon Taylor



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

Date: Thu, 14 Aug 2003 23:52:17 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl and recursive copying?
Message-Id: <slrnbjopo1.8ei.tadmc@magna.augustmail.com>

James Willmore <jwillmore@cyberia.com> wrote:

> use vars qw/$joe $bill/;


   You should always prefer lexical variables over package
   variables, except when you can't.


And you can, but you aren't, and you should:

   my( $joe, $bill );


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


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

Date: Fri, 15 Aug 2003 04:10:49 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Please offer critique on my 2nd JAPH
Message-Id: <x7vfszy306.fsf@mail.sysarch.com>

>>>>> "DO" == David Oswald <spamblock@junkmail.com> writes:

  DO> Perhaps I should build the string up to bytes from a series of
  DO> bits, to avoid such a long literal, which contributed to the JAPH
  DO> exceeding the four line tradition.

just don't get abigail started on that japh theme. she will fry your
brane with her japh-fu. :)

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Thu, 14 Aug 2003 21:41:15 -0700
From: "David Oswald" <spamblock@junkmail.com>
Subject: Re: Please offer critique on my 2nd JAPH
Message-Id: <vjop8eltsv9kf8@corp.supernews.com>


"Uri Guttman" <uri@stemsystems.com> wrote in message
news:x7vfszy306.fsf@mail.sysarch.com...
> >>>>> "DO" == David Oswald <spamblock@junkmail.com> writes:
>
>   DO> Perhaps I should build the string up to bytes from a series of
>   DO> bits, to avoid such a long literal, which contributed to the JAPH
>   DO> exceeding the four line tradition.
>
> just don't get abigail started on that japh theme. she will fry your
> brane with her japh-fu. :)
>

Lol.  She is the reigning JAPH queen, isn't she?

This one was at least as difficult to implement, and definately less
efficient than my first JAPH, which parsed morse code and translated it into
Just Another Perl Hacker, while fitting within the four-line requirement.  I
thought that this use of chomp was really the key to having found 'yet
another way to do it', so to speak.  The kooky regexp and use of things like
$/ and $&, and unpack instead of more conventional conversions were just
icing.  The real engine is chomp, put to an unusual task.

If I were to re-write it, I would change from the ;: motif to a bitwise
motif, counting bits instead of bytes, essentially.  Problem is that would
start to look too much like ascii in the first place.

Dave




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

Date: Fri, 15 Aug 2003 04:59:40 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Please offer critique on my 2nd JAPH
Message-Id: <x7adaby0qr.fsf@mail.sysarch.com>

>>>>> "DO" == David Oswald <spamblock@junkmail.com> writes:

  DO> "Uri Guttman" <uri@stemsystems.com> wrote in message
  DO> news:x7vfszy306.fsf@mail.sysarch.com...
  >> >>>>> "DO" == David Oswald <spamblock@junkmail.com> writes:
  >> 
  DO> Perhaps I should build the string up to bytes from a series of
  DO> bits, to avoid such a long literal, which contributed to the JAPH
  DO> exceeding the four line tradition.
  >> 
  >> just don't get abigail started on that japh theme. she will fry your
  >> brane with her japh-fu. :)
  >> 

  DO> Lol.  She is the reigning JAPH queen, isn't she?

well, she has done some amazing ones and gave a talk on them at yapc.


  DO> If I were to re-write it, I would change from the ;: motif to a
  DO> bitwise motif, counting bits instead of bytes, essentially.
  DO> Problem is that would start to look too much like ascii in the
  DO> first place.

counting bits would be tricky unless you used unpack (5.8 supports bits)
or vec. but it would be much shorter than your string and probably look
very odd (plenty of 8 bit stuff so \xNN would be needed). you could try
to only use 7 bits or printing chars and only parts of the bits. the
problem is the requirement for contiguous bits to encode the char. that
leaves out too many chars. there may be other ways to encode it like bit
slices across multiple chars.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 15 Aug 2003 05:29:55 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Please offer critique on my 2nd JAPH
Message-Id: <3f3c6d94.288615043@news.erols.com>

"David Oswald" <spamblock@junkmail.com> wrote:
: "Uri Guttman" <uri@stemsystems.com> wrote in message
: news:x7fzk4ynkf.fsf@mail.sysarch.com...
: >
: > by tradition, japhs have to fit in 4 lines so they can be signatures. my
: > quick guess without even looking is that you encoded the chars by the
: > number of : or ; in a row.
: 
: Your quick guess is accurate.  I figured that would be guessed.  The trick
: was using chomp as the counting device rather than some other more common
: method.

It's the most interesting use of chomp()'s return that I've seen.
Probably the only use, for that matter.

: Perhaps I should build the string up to bytes from a series of bits,

Hrmmm...I think you're onto something there.

$_=";;::::;;:;;;;:;:::;;;:;;;::;;:;;::;::;::::;::;:::::;;:;;::::::;
;;;;;;:;;:;;;;:;:::;;;:;;;::;;::;;;;;;;:::::::;:;;;:::;:::;;::;::;;
;;;:;::;;;;:;;:;:;;:;;:;:::;:::::;;;:::::::;:;;::::;:;;;:;;:;::;;::
;;;::;";s e$/eeg;vec($s,$p+=chomp,1)=1while($/)=/((.)\2*)$/;print$s



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

Date: Thu, 14 Aug 2003 20:49:33 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: populating anonymous arrays inside for loop?
Message-Id: <Xns93D7DE0AEAD43sdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Matija Papec <mpapec@yahoo.com> wrote in 
news:368ljv8ku5ah1gb9m5mujtk7a8id5mkc9u@4ax.com:

> 
> Symbolic references are deprecated for a number of reasons and you'll be

Deprecated?  This is news to me....

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPzw8MWPeouIeTNHoEQKvIQCdHb+WT/osMLkFcevGe82P70P2rmIAn3B2
r7kDZhqD0L+jZAJ/h0iMGA2t
=KV05
-----END PGP SIGNATURE-----


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

Date: Fri, 15 Aug 2003 01:10:19 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Question about "eval" security
Message-Id: <qfcojvksv256k3qpomf75mmsk3b1ap5pb8@4ax.com>

H. Nakanishi wrote:

>Would something like:
>
>eval qq/"$userinput"/;
>
>work?

Not if the input contains quotes.

>What I want is just to allow variable interpolation but not any
>executions.

Then perhaps String::Interpolate can be of use. See CPAN.

> I want to make sure that this is OK as far as security.

Not really... as Randal Schwartz demonstrated. You could look into
safe.pm AKA safe on your local system with perldoc, or on CPAN

-- 
	Bart.


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

Date: Thu, 14 Aug 2003 17:18:33 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: "H. Nakanishi" <hisao@physics.purdue.edu>
Subject: Re: Question about "eval" security
Message-Id: <445f34d2c4f1b5a949b64b787e94a11f@news.teranews.com>

>>>>> "H" == H Nakanishi <hisao@physics.purdue.edu> writes:

H> Thanks to Randal and Richard for their help. I will use:
H> $userinput =~ s/\$(\w+)/${$1}/g;

H> instead. Are there any problems with this?

Yes, don't use soft references!  Don't mix user data with program
data.

Create a hash %vars, and populate it with your user data.  Then use:

        $userinput =~ s/\$(\w+)/$vars{$1}/g;

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Fri, 15 Aug 2003 02:06:16 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: question regarding multiple args to sub 
Message-Id: <3F3C4014.5080809@rochester.rr.com>

ktom wrote:

 > I have to subs in which i am attempting to pass multiple args to and i
 > have managed to get it to work, after spending all afternoon trying to
 > get my brain around it.  I still don't have my brain around and the
 > solution seems absurd!!
 >
 > below are snippets...
 >
 > 1st call:
 >
 >         &printVec( \@spline, \@indx, \@port1 );

----------^

Any more (that is, with Perl's less than many years old), you shouldn't 
use the & in your call unless you actually want the specific 
functionality it provides.  See:

    perldoc perlsub

for details.


 >          }
 >
 > 1st working sub:
 >
 > sub printVec {
 > #our @spline;
 > #   my (@spline,@indx,@port) = @_ ;
 > #   print "pre @$spl, @$indx, @$port\n";
 > #   print "spline @spline\n";
 >    my ($spl,$indx,$port) = @_ ;
 >    my @prt = @$port ;
 >    my @ndx = @$indx ;
 >    my @spline = @$spl ;


These latter three statements are OK if you actually want to make a copy 
of the three arrays in your sub.  It is not necessary, and, if the 
purpose of your sub is to modify values in the arrays, won't work unless 
you copy the modified values back to the arrays before you return.  You 
can instead access elements of the arrays as, for example:

    $$port[3]='something or other';
    @$indx[3..6]=(4..7);
    $val=$$spl[23];

or you can use notation like:

    $port->[3]='something or other';

etc if you prefer a "cleaner" implementation (at least according to some 
definition of "clean").


 >
 >
 > 2nd call:
 >
 >       &printTset( \@indx, $vect, $cmmnt ) ;
 >       }
 >
 > 2nd working sub:
 >
 > sub printTset {
 >    my ( $indx, $vct, $cmt) = @_ ;
 >    my @ndx = @$indx;
 >    my $vect = $vct;
 >    my $cmmnt = $cmt;


Again, you don't have to make local copies of the data unless that is 
really what you want to do.  In this case, passing the scalars directly 
is fine, since they will always have just a single value in @_.


 >
 > if i don't use the \ on the passed parameters, it seems to merge them
 > all into one big array.. blahh.


Yep.  That's the way Perl's argument calling semantics work.  It's a 
feature, not a bug or problem :-).


 >
 > this seems like a lot of code, seemingly redundant to my wee perl mind,
 > to pass values to a subroutine.


Well, it isn't that much overhead when writing the code -- one extra $ 
or @ for each time you want to reference an item.  Plus don't forget you 
can also pass hashes, globs, and references (and maybe some other stuff 
I'm forgetting or don't know about) this way too.  And of course, hashes 
of arrays of hashes, etc etc.


 >
 > what magic am i missing or is this just the way it is???


Nope, that's the way it is.  Except you shouldn't make local copies 
unless there is a good reason why.


 ...

-- 
Bob Walton

-- 
Bob Walton



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

Date: 14 Aug 2003 22:13:07 -0700
From: Patrick Flaherty <Patrick_member@newsguy.com>
Subject: regex diffs between perl 5.6.1 and 5.8.0?
Message-Id: <bhhq530ttk@drn.newsguy.com>

Hi,

Back in 5.6.1, the following succeeded in stripping out all x1a garbage chars
from a set of files:

  perl -p0777 -i.bu -e 's/\X1a+$//g' house.lis

I run the same thing under 5.8.0 and it has no effect.

Doesn't compile or puke.  But doesn't remove the garbage chars either.

From what little I've read, there do appear to be noticable differences between
pre-5.8 and 5.8.+

  pat



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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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 5364
***************************************


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