[19788] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1983 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 22 14:05:59 2001

Date: Mon, 22 Oct 2001 11: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: <1003773908-v10-i1983@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 22 Oct 2001     Volume: 10 Number: 1983

Today's topics:
    Re: accessing class-level variables (Mark Jason Dominus)
    Re: Calling a sub rutine in another package or module <simon.oliver@umist.ac.uk>
    Re: Good Literature <joe+usenet@sunstarsys.com>
    Re: Good Literature <joe+usenet@sunstarsys.com>
    Re: HELP: Regular expression and grep (Paul Shinn)
        IE4 onLoad in .pl pages (Justin)
    Re: IE4 onLoad in .pl pages <jeff@vpservices.com>
    Re: IO::Wrap -- Found it! <lmoran@wtsg.com>
        IO::Wrap <lmoran@wtsg.com>
    Re: need Regular Expression help <brian@jankoNOnet.SPAMcom.INVALID>
    Re: perl algorithm <jurgenex@hotmail.com>
    Re: problem with pods <edgue@web.de>
    Re: Reading two variables from a file (Mark Jason Dominus)
    Re: Remove duplicates from a logfile (Garry Williams)
    Re: requiring packages dynamically <mcook@dna.com>
    Re: Skipping following lines if the same (Mario Rizzuti)
    Re: Sorting a pipe delimited database <diehard@nospam.userve.co.uk>
        Splitting a string into an array of chars <fredboard@sus.mcgill.ca>
    Re: Splitting a string into an array of chars <clay@panix.com>
    Re: Splitting a string into an array of chars <Thomas@Baetzler.de>
    Re: Webpage Passwords <postmaster@127.0.0.1>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 22 Oct 2001 15:32:23 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: accessing class-level variables
Message-Id: <3bd43c06.3276$21a@news.op.net>

In article <c9c77658.0110220655.a81cc80@posting.google.com>,
Paul Faulstich <pfaulstich@llbean.com> wrote:
>I am running into problems accessing a child class's class-level
>variables from the parent class.  Essentially, I would like to have an
>inherited parent method refer to some variable and have it use the
>child's variable, not the parent's.
>
>"Class Context and the Object" in the Camel book touches on something
>close to this, but in the case described there, a method in the child
>class references the variable, rather than a method in the parent
>class referencing the variable.
>
>The best option I could come up with was to have every child class
>which overrides that variable also override a method to access the
>variable.

You'll have to do something like that.  You have declared
'%object_list' with 'my', which means it will be private to the file
in which it is declared.  Only a method that follows the declaration
'my %object_list' will be able to access %object_list.

>I can obviously hard-code it with packagename::, but I don't seem to
>be able to do something like $packagename:: because it interprets
>this as $(packagename::) rather than ($packagename)::

That won't work with the code you have below, but it can be made to
work.  The trick is to use something like

        %{$packagename . '::object_list'}

This avoids the problem you just described.  An easier way to do this is:

        %{"$packagename\::object_list"}


Here's a template for what you want to do:

        package Parent;

        sub find {
          my $self = shift;

          my $objects_ref;
          { no strict 'refs';
            my $class = ref $self || $self;
            $objects_ref = \%{"$class\::object_list"};
          }
          ... do something with $self and $objects_ref ...
        }

        package Daughter;

        ... inherits 'find' ...

Note that if you do this, you *must not* declare 'my %object_list'.
The variable %{"$class\::object_list"} is a global variable, and 'my
%object_list' is a different variable that happens to have the same
name.  If you declare '%object_list' with 'my', you will have two
different '%object_list' variables, and you will probably become
confused.

For example, the following will *not* work:

        package Parent;

        sub find {
          ... as above ...
        }
        
        class Daughter;

        my %object_list;    ## delete me

        sub add_object {
          my ($self, $name, $object) = @_;
          $object_list{$name} = $object;
        }

Here, Daughter::add_object stores the data into the %object_list
variable that is decalred in 'my %object_list'.  But Parent::find is
looking in the global package variable %Daughter::object_list, which
is different.  This will work if you delete the line 'my
%object_list'.  Then both methods will use the package variable.

I hope this was clear.


-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Mon, 22 Oct 2001 16:25:13 +0100
From: Simon Oliver <simon.oliver@umist.ac.uk>
To: sasha <sasha_lui@yahoo.com>
Subject: Re: Calling a sub rutine in another package or module
Message-Id: <3BD43A59.151F775E@umist.ac.uk>

The only problem I see is that Info.pm doesn't return a true value:

package Info;

sub showinfo{

my $number = 12;
print "Number is : $number \n";

}

1;

Also, I normally reserve -> notation for objects, preferring :: notation
for calling module subroutines.

#!/usr/local/bin/perl -w
use Info;

use strict;
my $anInfo = Info::showinfo();

--
  Simon Oliver


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

Date: 22 Oct 2001 11:18:00 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Good Literature
Message-Id: <m3r8rv7lg7.fsf@mumonkan.sunstarsys.com>

dave@dave.org.uk (Dave Cross) writes:

> I've been in contact with the author over the last couple of months
> and I'm currently working on a (very long) list of technical errors
> and suggestions on improvements. Jaqueline has already indicated that
> she'll be happy to include my fixes in the next edition. Hopefully,
> this will end up with another much improved beginners book on the
> bookshelves.

The litmus test is whether or not the author is capable of writing a 
secure form-to-email script.  In the various attempts proposed on that 
website, only the "bare-bones" mail-form.cgi script is reasonably
spam-safe,  simply because the mail headers are hard-coded into the
script.  It is also clear the author hasn't acquired the habits of 
someone familiar with Perl's taint-check mechanism: this is especially 
troubling in a CGI environment.

Moreover, none of the scripts there enable warnings, which 
means warnings coming from bogus tests like

    if ($form{widget} eq "") { dienice("blah") }

(that line would normally generate a warning when $form{widget} does
not exist) go blithely undetected.  That type of test is used
throughout the examples (cf chapter 5), and is *very* bad code, 
especially since the HTML standard permits browsers to ignore empty 
input widgets when constructing post data.  See (unwrapped url)

http://www.w3.org/TR/1998/REC-html40-19980424/interact/forms.html#h-17.13.2

for details.

I'm not even going to touch that hand-crafted url-decoder thing that
is somehow different, and never quite right, each time it is recoded.
That thing belongs in a Cracker Jack box, not in a book on CGI 
programming.

I can't see how anything short of a total rewrite would make this
book acceptible to Uri :) - does he still maintain a recommended 
book list?  The learn.perl.org site recommends _CGI Programming with Perl_
for beginners- surely that's a better resource than this book appears 
to be.  I imagine Lincoln Stein's new book on network programming is a 
bit too advanced for a beginner.


-- 
Joe Schaefer     "A man cannot be too careful in the choice of his enemies."
                                               --Oscar Wilde



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

Date: 22 Oct 2001 11:54:37 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Good Literature
Message-Id: <m3n12j7jr6.fsf@mumonkan.sunstarsys.com>

Joe Schaefer <joe+usenet@sunstarsys.com> writes:

> Moreover, none of the scripts there enable warnings, which 
> means warnings coming from bogus tests like
> 
>     if ($form{widget} eq "") { dienice("blah") }
> 
> (that line would normally generate a warning when $form{widget} does
> not exist) go blithely undetected.  That type of test is used
> throughout the examples (cf chapter 5), and is *very* bad code,
                                              ^^^^^^^^^^^^^^^^^^

Oops- my mistake!  It's not bad at all, since perl will still test
true for (undef eq "").   After reading the author's faulty "NOTE" in 
ch5 about the "difference" between ($x == 1) and ($x == "1"),  my anger 
overtook reason.  Very sorry about that.

-- 
Joe Schaefer     "If one studies too zealously, one easily loses his pants."
                                               --Albert Einstein



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

Date: 22 Oct 2001 16:34:07 GMT
From: pshinn@mail1.sas.upenn.edu (Paul Shinn)
Subject: Re: HELP: Regular expression and grep
Message-Id: <9r1hpv$9ma$1@netnews.upenn.edu>


   Hi Dave, thanks for the new code.  It works great!  I can see these 
new bits working out for me in a lot of other scripts, too.

					Paul

Dave Tweed (dtweed@acm.org) wrote:
: Paul Shinn wrote:
: >       if ($pattern =~ /$header/) {  #there is something wrong here

: Sure is. Try this:

:         if ($header =~ /$pattern/) {

: Also, several things can be simplified and/or made more robust:
: * chomp the patterns once at the beginning, rather than on each pass
:   through the loop
: * check both opens for errors, close LIST when done with it
: * remove extraneous quotes
: * don't strip the newline from the sequence if you're just going to
:   put it back on when you print it
: * don't split the sequence at all, in fact

: #!perl -w
: #pulls the sequences that match the names in the file

: ($seqs, $list)=@ARGV;

: open LIST, $list or die;
: chomp (@search = <LIST>);
: close LIST;

: open SEQS, $seqs or die;
: $/ = ">";
: <SEQS>;
: while (<SEQS>) {
:    my $header = (split "\n")[0];
:    print ">$_" unless grep $header =~ /$_/, @search;
: }
: close SEQS;

: -- Dave Tweed


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

Date: 22 Oct 2001 09:57:53 -0700
From: amiwebguy@yahoo.com (Justin)
Subject: IE4 onLoad in .pl pages
Message-Id: <19caa707.0110220857.2722c5e1@posting.google.com>

Please help,

I've created a wait page that is opened between two perl pages, one
being a form, and the other displaying results after database
interaction.
I can get this to work in all browsers except for IE4.  The action is
triggered from a Javascript onLoad event in the body tag.  This seems
to work fine in the wait page which is just straight HTML, but in the
Perl pages it doesn't.
I'm starting to think this may be a Perl or browser issue since when I
put the onLoad event in the last image on the page it fires correctly.
 For some reason IE4 doesn't seem to completely load the pages.  I've
made sure that I do have close head, body, and html tags.  Any ideas?

Thanks,

Justin 
amiwebguy@yahoo.com


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

Date: Mon, 22 Oct 2001 10:18:48 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: IE4 onLoad in .pl pages
Message-Id: <3BD454F8.C42B7EEB@vpservices.com>

Justin wrote:
> 
> I can get this to work in all browsers 

Perl has nothing to do with browsers or how they behave, see a newsgroup
about browsers or CGI.

> triggered from a Javascript onLoad event in the body tag

Perl has nothing to do with Javascript, see a newsgroup about Javascript
or CGI.

> I'm starting to think this may be a Perl or browser issue 

It can not possibly be a perl issue since all perl does is print what
you tell it to.  If you've told it to print something the browser
doesn't like, then find out what the browser likes and print that.

>  I've
> made sure that I do have close head, body, and html tags.

As you mention, those are HTML tags and have nothing to do with perl. 
See a newsgroup about HTML or CGI.

I am not telling you all this to be picky about what is perl and what
isn't, but rather because unless you learn to distinguish where your
problems lie, you will never be able to fix them.

And please do not respond that since your script is written in perl it
is therefore a perl issue.  Perl is only the intermediary and irrelevant
to what the browser expects to see.

-- 
Jeff



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

Date: Mon, 22 Oct 2001 11:48:25 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: IO::Wrap -- Found it!
Message-Id: <bpf8tt039db3qgdtb361knp11pf1kljh2d@4ax.com>

On Mon, 22 Oct 2001 11:18:28 -0400, Lou Moran <lmoran@wtsg.com> wrote
wonderful things about sparkplugs:

Viva CPAN... found it on my Linux box, it's IO::Stringy

CPAN let me use IO::Wrap for the install and then got me the right
mod. 

>>use IO::Wrap; $output = wraphandle($output);
>
>In a recent thread someone (BG) was kind enough to write out some code
>for me and it has the above line in it.  
>
>What module is this a part of, or is it it's own module?  Trying to
>find this via PPM with no luck


--
TMTOWTDI: My way tends to be wrong...
lmoran@wtsg.com


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

Date: Mon, 22 Oct 2001 11:18:28 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: IO::Wrap
Message-Id: <i3e8ttg3qf28ikjhthi4lo0bnfu2c9qti3@4ax.com>

>use IO::Wrap; $output = wraphandle($output);

In a recent thread someone (BG) was kind enough to write out some code
for me and it has the above line in it.  

What module is this a part of, or is it it's own module?  Trying to
find this via PPM with no luck

--
TMTOWTDI: My way tends to be wrong...
lmoran@wtsg.com


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

Date: Sun, 21 Oct 2001 02:00:21 GMT
From: "Brian Janko" <brian@jankoNOnet.SPAMcom.INVALID>
Subject: Re: need Regular Expression help
Message-Id: <V_pA7.2122$v93.183034@bin4.nnrp.aus1.giganews.com>

There were lines of code, further up, which were removing spaces.  So now
I'm trying to rework the program so it will not accept spaces in the middle
of the address as valid.  The original problem, (although I explained it
quite poorly in my first post), is solved.  I just have to further work on
the program.

Brian



"peter pilsl" <pilsl_@goldfisch.at> wrote in message
news:3bd20ff5@e-post.inode.at...
> Brian Janko wrote:
>
> > I just found the spot in my code where I am allowing the spaces through,
> > so the problem has becoem a moot point.
> >
>
> so it was not the code you shared with us ?
>
> best,
> peter
>
>
> --
> peter pilsl
> pilsl_@goldfisch.at
> http://www.goldfisch.at
>
>




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

Date: Mon, 22 Oct 2001 08:45:29 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: perl algorithm
Message-Id: <3bd43f22@news.microsoft.com>

"Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
news:slrn9t7r5l.cnu.mgjv@martien.heliotrope.home...
> On Mon, 22 Oct 2001 02:09:59 -0700,
> Jürgen Exner <jurgenex@hotmail.com> wrote:
> > "F. Xavier Noria" <fxn@retemail.es> wrote in message
> > news:9r0fud$nu801@news1s.iddeo2.es...
> >> On Mon, 22 Oct 2001 01:33:35 GMT, Bob Walton <bwalton@rochester.rr.com>
> > wrote:
> >>
> >> : while(<DATA>){
> > No idea what you are talking about. DATA *is* a file handle, typically
> > pointing to a file on the disk although it might point to other
resources
> > (pipes, sockets, ... ), too. And it is also the usual way.
>
> Nono. It _typically_ points to the current source file, just after the
> __DATA__ token (and/or __END__ in the top level script). The user can
> re-open it to some other file.
>
> See the perldata documentation for a description.

I stand correct.  TIAOMTYDKA (There is always one more [trick|trap] you
don't know about)
Thanks a lot!

jue




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

Date: Mon, 22 Oct 2001 17:14:42 +0200
From: Edwin =?iso-8859-1?Q?G=FCnthner?= <edgue@web.de>
Subject: Re: problem with pods
Message-Id: <3BD437E2.4A69975D@web.de>



Rafael Garcia-Suarez wrote:

> That's a space, isn't it ?

Yes it was. Thx.


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

Date: Mon, 22 Oct 2001 15:37:04 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Reading two variables from a file
Message-Id: <3bd43d1f.32ab$19e@news.op.net>

[Mailed and posted]

In article <9r0jq9$gpg$1@newstoo.ericsson.se>,
Peter <peter_laranc@yahoo.com> wrote:
>Thanks for your answer, but it dident worked. Maybe i dident explained well.
>Because each time i read one line from the file, this lines could  contains
>IP address and hostname, i want to save IP address in one variable and host
>name in other.

But I did save the IP address in one variable and the host name in another.

In my code:

        my ($ip, $host) = split;
        if (defined $ip) {
          print "The IP is : ",$ip," and the host name is  : ",$host," \n";
        } else {
          print "The input data did not contains IP and hostname \n";
        }          

The IP address is saved in $ip, and the host name is saved in $host.


>if ($data =~ m/^((\d+)\S(\d+)\S(\d+)\S(\d+))\S+(\s*)$/)
>
>Problem is that, there is some thing wrong with my if condition, so it only
>tacking care of IP address, that means i can only write my $Ip = $1, But i
>dont know what should i add or change to get the hostname in $2 or other $.

Maybe the host name is in $6.  

$2 would be the *second* pair of (...), which is the (\d+) at the very
beginning:

>if ($data =~ m/^((\d+)\S(\d+)\S(\d+)\S(\d+))\S+(\s*)$/)
                 1111111111111111111111111111
                  22222  33333  44444  55555    66666


-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Mon, 22 Oct 2001 15:17:54 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Remove duplicates from a logfile
Message-Id: <slrn9t8e52.oua.garry@zfw.zvolve.net>

On Mon, 22 Oct 2001 09:36:30 GMT, Andrew Cady <please@no.spam> wrote:
> garry@ifr.zvolve.net (Garry Williams) writes:
>> 
>> Yes, if I understand that you simply want to print the first
>> occurrence of each unique IP address.
>> 
>> Here's a way: 
>> 
>>   $ perl -ne 'print unless $seen{ (split)[4] }++' log_file
>> 
>> Hope this helps.  
> 
> That prints the whole line, not just the IP address.
> 
> perl -lne 'print unless $seen{ $_ = (split)[4] }++'

While this is a clever way to get just the IP address printed, the OP
showed that he wanted the whole line.  

Here's the relevant part of <C1KA7.37706$ev2.44251@www.newsranger.com>:

> @IPLogArray = <LOGFILE>;
> ...
> @IPLogArrayCopy=@IPLogArray;    # Copy the original array
> ...
> print @IPLogArrayCopy;

-- 
Garry Williams


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

Date: Mon, 22 Oct 2001 09:29:02 -0700
From: "Malcolm Cook" <mcook@dna.com>
Subject: Re: requiring packages dynamically
Message-Id: <9r1hbn$q6i3r$1@ID-66718.news.dfncis.de>

Sure:

use UNIVERSAL::require; #get it from CPAN if need be
require "One::Two::$_" foreach qw(Foo Bar);

Regards,
--
Malcolm Cook
(858) 623-7654
BioInformatics
PPGx, Inc

"Marc Tardif" <intmktg@gloria.cam.org> wrote in message
news:Pine.LNX.4.10.10110201355140.7528-100000@gloria.cam.org...
> Is there a portable way to require a package after
> building its name dynamically? For example:
>
> foreach (qw(Foo Bar)) {
> my $package = "One::Two::$_";
> require $package;
> }
>
> The problem with the above is that since $package
> is a scalar, require expects an explicit path to
> the package name so I'd have to declare $package
> as:
>
> my $package = "/path/One/Two/$_.pm";
>
> Unfortunately, this is not portable and rather
> limited compared to letting Perl use the @INC
> array. So is there a way around this problem?
>
> Marc
>




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

Date: 22 Oct 2001 10:48:44 -0700
From: mariorizzuti@yahoo.com (Mario Rizzuti)
Subject: Re: Skipping following lines if the same
Message-Id: <42f3ee2.0110220948.f8711e2@posting.google.com>

kenlaird@yahoo.com (Laird) wrote in message news:<94a02505.0110040112.3dd9557d@posting.google.com>...
> Hi everyone,
> 
> I've got this array
> 
> aaa
> aaa
> bbbbb
> cccc
> cccc
> c
> ddd
> ddd
> fff
> fff
> fff
> ffff
> ffff
> 
> 
> and would like to transform it into this
> 
> 
> aaa
> bbbbb
> cccc
> c
> ddd
> fff
> ffff
> 
> 
> skipping following lines if the same.
> But only following lines.
> 

(untested)

while (<IN>) { 
   $_ eq $old ? next : print "$_\n";
   $old = $_;
}


or, if you rather

@data = <IN>;
for (@data) { 
   $_ eq $old ? next : print "$_\n";
   $old = $_;
}


---
Mario Rizzuti


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

Date: Mon, 22 Oct 2001 16:45:32 +0100
From: "Diehard Duck" <diehard@nospam.userve.co.uk>
Subject: Re: Sorting a pipe delimited database
Message-Id: <1003765535.16080.0.nnrp-14.9e98e2c7@news.demon.co.uk>


"Thomas Bätzler" <Thomas@Baetzler.de> wrote in message
news:p4d8ttcim4m5brldema5jgv0d70ijah4kh@4ax.com...
> On Mon, 22 Oct 2001, "Diehard Duck" <diehard@nospam.userve.co.uk> wrote:
> >I just want to sort the fields.  If you would like to re-write the
script,
> >I'm sure the author won't mind.  You can download it free of charge from
> >http://www.web-bazaar.com/cgi/db_doctor.html
> >
> >If anyone could solve my sort problem I'd be very grateful.
>
> Try this fix (new lines indicated by leading '+'):
>
> [...]
>  open (DATABASE, "$datafile") || die print "$datafile: $!";
>  @data=<DATABASE>;
>  close (DATABASE);
>
> + @data = map { $_->[1] }
> +     sort { $a->[0] <=> $b->[0] }
> +        map { [(split /\|/, $_)[13], $_] }  @data;
>
>  $counter = 1;
>
>  foreach $data(@data)
>  {$search_data{$counter} = $data; $counter++;}
> [...]
>
> You may have to substitute your own sorting code for the plain <=> given
> here.
>

OK...

That didn't specifically work (as you said it may not) but it's pointed me
in a new direction...I'll be back to let you know how I get on/ask for more
help!

Cheers,
DD




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

Date: Mon, 22 Oct 2001 15:12:15 GMT
From: "Frederic SOUSTRA" <fredboard@sus.mcgill.ca>
Subject: Splitting a string into an array of chars
Message-Id: <jHWA7.13084$mD5.1107090@carnaval.risq.qc.ca>

How do i split a string into an array of characters?




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

Date: 22 Oct 2001 15:21:29 GMT
From: Clay Irving <clay@panix.com>
Subject: Re: Splitting a string into an array of chars
Message-Id: <slrn9t8ebp.1i9.clay@panix3.panix.com>

In article <jHWA7.13084$mD5.1107090@carnaval.risq.qc.ca>, Frederic SOUSTRA 
wrote:

> How do i split a string into an array of characters?

perldoc -f split

-- 
Clay Irving <clay@panix.com>
If all men knew what others say of them, there would not be four friends
in the world. 
- Blaise Pascal 


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

Date: Mon, 22 Oct 2001 17:27:39 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Splitting a string into an array of chars
Message-Id: <qee8tts5blnuiajr2m8582fiiqu06suuc0@4ax.com>

On Mon, 22 Oct 2001, "Frederic SOUSTRA" <fredboard@sus.mcgill.ca> wrote:

>How do i split a string into an array of characters?

"Use split for clarity and unpack for efficiency" - Joseph N. Hall in
"Effective Perl Programming".

See the perlfunc manpage ("perldoc -f split", "perldoc -f unpack") for
details on split and unpack.

The basic usage is "my @chars = split //, $string;". 

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: Mon, 22 Oct 2001 16:15:07 +0100
From: Anthony Peacock <postmaster@127.0.0.1>
Subject: Re: Webpage Passwords
Message-Id: <3BD437FB.AFC88908@127.0.0.1>

Diehard Duck wrote:
> 
> "Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
> news:slrn9t85jo.cnu.mgjv@martien.heliotrope.home...
> > On Mon, 22 Oct 2001 13:30:26 +0100,
> > Diehard Duck <diehard@nospam.userve.co.uk> wrote:
> > >
> > > "Scott Bell" <news@scottbell.org> wrote in message
> > > news:FmSA7.54149$sF.4733750@news2-win.server.ntlworld.com...
> > >> I wish to create a CGI script that allows users to create accounts. Is
> > > there
> > >> a way of getting the popup box in internet browsers that asks for the
> > > login
> > >> name and password via a CGI script?
> > >>
> > >
> > > I'm not sure of the code to do this, but I think what you need to do is
> > > allow users to set up accounts from a script on a webpage.  The script
> > > writes username/password to a .htaccess file in the root of the folder
> you
> > > want restricted.  Then when anyone tries accessing that folder
> > > (www.foo.com/restricted for example) they must have signed up to have
> > > access.
> >
> > Now, this is the sort of (bad) answer you can expect when you ask an
> offtopic
> > question like this. This has nothing at all to do with Perl, and
> > therefore should not be asked in a Perl newsgroup.
> >
> 
> Could Perl not be used to sign people up and to write to the .htaccess file?
> Then all Scott has to do is find out about .htaccess files, in, as you
> suggest, comp.infosystems.www.  I don't see how this has 'nothing to do with
> perl'.  Take a look at what he wants to achieve overall, and try and be
> helpful, and if you feel this has nothing to with Perl, at least explain
> why. Not everyone is necessarily as clued up as you are! I'm sure even you
> had to ask questions once that seem dumb now.

Your are missing the point.  Yes Perl can be used to do this, and I do
it all the time.

However, without knowing what Web server the OP is using the Perl bit is
irrelevant.  Also the OP needs to learn how the security features of his
web server work before he can even attempt to use Perl to solve his
problem.  He is better off asking his question in one of the WWW related
groups first, then coming back here when he has a Perl problem.

Secondly your advice is wrong.

Your advice assumes that the OP is using Apache, and even then is
wrong.  So not only has he not learnt any Perl but he now has some wrong
advice about Apache security configs.


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

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


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