[15947] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3360 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 14 18:31:21 2000

Date: Wed, 14 Jun 2000 15:31:09 -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: <961021869-v9-i3360@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 14 Jun 2000     Volume: 9 Number: 3360

Today's topics:
    Re: Opening a file for realtime monitoring (Tad McClellan)
        Pattern matching - case sensitive/insensitive (A.J. Norman)
    Re: Pattern matching - case sensitive/insensitive <Peter.Dintelmann@dresdner-bank.com>
    Re: Pattern matching - case sensitive/insensitive (Rafael Garcia-Suarez)
        Perl 5.6 bug? <newspost@coppit.org>
    Re: Perl 5.6 bug? <rootbeer@redcat.com>
    Re: Perl and .htaccess (brian d foy)
        Perl code formatter <jwing@pliantsystems.com>
    Re: Perl code formatter (Steven Smolinski)
        perl returning hash of my variables tlars@my-deja.com
    Re: Perl Search |more option <rootbeer@redcat.com>
    Re: Perl Search |more option law_40@my-deja.com
    Re: perl system call problems, VSS cmd line <lr@hpl.hp.com>
    Re: Perl Threads <dan@tuatha.sidhe.org>
    Re: Perlmagick and CGI <rootbeer@redcat.com>
    Re: Please help!  Win2000 server/perl issue   <rootbeer@redcat.com>
    Re: Problem with regexp (Tad McClellan)
    Re: Problem with regexp (Tad McClellan)
    Re: Problem with regexp <lr@hpl.hp.com>
        push question law_40@hotmail.com
    Re: push question <tony_curtis32@yahoo.com>
    Re: push question <care227@attglobal.net>
    Re: push question <lauren_smith13@hotmail.com>
    Re: pw() function question law_40@my-deja.com
        Question: any ASP parser available? <ekliao@mediaone.net>
    Re: Question: any ASP parser available? <glauber.ribeiroNOglSPAM@experian.com.invalid>
    Re: Quick Network Ping : Can't make Net::Ping work? <rootbeer@redcat.com>
    Re: Registry Editing - A living hell.... <Thomas.Kratz@lrp.de.nospam>
    Re: Remote .htpasswd editting <rootbeer@redcat.com>
        Repleace "/" with "\" <marcNOmaSPAM@loosli.ws.invalid>
    Re: Repleace "/" with "\" <lr@hpl.hp.com>
    Re: Script to calculate a future date? <lr@hpl.hp.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 14 Jun 2000 10:45:59 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Opening a file for realtime monitoring
Message-Id: <slrn8kf6l7.4al.tadmc@magna.metronet.com>

On Wed, 14 Jun 2000 14:34:04 GMT, Ilja Tabachnik <billy@arnis-bsl.com> wrote:
>In article <3947747F.AF682DB6@epicrealm.com>,
>  Paul Eckert <peckert@epicrealm.com> wrote:

>> open INF, "tail -f $fn |" or die "Couldn't fork() tail process...:
>$!";
>> while (<INF>) {

>> }
>> close (INF);
>
>IMHO it could be better not to start en external 'tail'
>but just use File::Tail module.


And you should be checking the return value of the close() too.


Perl FAQ, part 8:

   "Why doesn't open() return an error when a pipe open fails?"


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


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

Date: 14 Jun 2000 16:45:09 +0100
From: nja@le.ac.uk (A.J. Norman)
Subject: Pattern matching - case sensitive/insensitive
Message-Id: <8i89a5$55p1@owl.le.ac.uk>

I'm writing a program to search an array, with the option of doing
/$pattern/ or /$pattern/i depending on user input.  Is there a neater
way of doing this than:

while (<INFILE>)
{
  if ($sensitive)
  {
    print if (/$pattern/);
  }
  else
  {
    print if (/$pattern/i);
  }
}

Ideally I'd like to be able to extend this by having multiple options for the
pattern matching as a string and doing something like

  print if (/$pattern/$options);

-- 
Andrew Norman, Leicester, England
nja@le.ac.uk || andrew.norman@le.ac.uk
http://www.le.ac.uk/engineering/nja/


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

Date: Wed, 14 Jun 2000 17:59:11 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: Pattern matching - case sensitive/insensitive
Message-Id: <8i8a3o$3t21@intranews.dresdnerbank.de>

    Hi,

    have you thought on using 'eval' to build your code
    depending on the user input?
    Especially your while loop may be a little bit slow if you
    make the same decision ('if') for every line.

    Best regards,

        Peter Dintelmann







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

Date: Wed, 14 Jun 2000 16:04:17 GMT
From: garcia_suarez@hotmail.com (Rafael Garcia-Suarez)
Subject: Re: Pattern matching - case sensitive/insensitive
Message-Id: <slrn8kfbfb.76b.garcia_suarez@rafael.kazibao.net>

A.J. Norman wrote in comp.lang.perl.misc:
>I'm writing a program to search an array, with the option of doing
>/$pattern/ or /$pattern/i depending on user input.  Is there a neater
>way of doing this than:
>
>while (<INFILE>)
>{
>  if ($sensitive)
>  {
>    print if (/$pattern/);
>  }
>  else
>  {
>    print if (/$pattern/i);
>  }
>}

You can do:
  $pattern = "(?i)$pattern" if $sensitive;
and then :
  while (<INFILE>) { print if /$pattern/o; }
See the perlre man page, look for "embedded pattern-match modifiers".
The bonus is that you can use the /o modifier to your regexp, so the
pattern is compiled only once.

Note that allowing any pattern from user input can be a major security
hole. Don't use that in CGI programs.

-- 
Rafael Garcia-Suarez


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

Date: Wed, 14 Jun 2000 11:39:41 -0400
From: David Coppit <newspost@coppit.org>
Subject: Perl 5.6 bug?
Message-Id: <Pine.GSO.4.21.0006141136570.25488-100000@mamba.cs.Virginia.EDU>

Hi all,

I have the following code in some mail processing software:

  if (defined($header) && ($header =~ /^(Subject:.*)$/im))
  {
   ... do stuff ...
  }

When run with "use strict", "use diagnostics", and -w, Perl 5.6 says:

Use of uninitialized value in pattern match (m//) at /home/david/test
        line 901, <GEN0> chunk 155 (#1)

    (W uninitialized) An undefined value was used as if it were already defined.
  It was
    interpreted as a "" or a 0, but maybe it was a mistake.  To suppress this
    warning assign a defined value to your variables.

I don't get it. $header is defined, so what variable is the warning referring
to?

Thanks,
David



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

Date: Wed, 14 Jun 2000 10:50:35 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl 5.6 bug?
Message-Id: <Pine.GSO.4.10.10006141046290.5301-100000@user2.teleport.com>

On Wed, 14 Jun 2000, David Coppit wrote:

>   if (defined($header) && ($header =~ /^(Subject:.*)$/im))
>   {
>    ... do stuff ...
>   }
> 
> When run with "use strict", "use diagnostics", and -w, Perl 5.6 says:
> 
> Use of uninitialized value in pattern match (m//) at /home/david/test
>         line 901, <GEN0> chunk 155 (#1)

> I don't get it. $header is defined, so what variable is the warning
> referring to?

It may be mistaken about the line number; sometimes the internal codes
have been optimized so that the undefined value is actually referenced on
another line. This should probably be considered a bug, albeit a minor
one.

Could the first thing inside the if-block be a pattern match? Or could
there be an elsif-test which uses a pattern match?

Of course, this could be a true bug. If so, you should be able to reduce
it to a small, self-contained test case which you can report with perlbug.
Good luck with it!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 14 Jun 2000 13:27:46 -0500
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Perl and .htaccess
Message-Id: <brian-1406001327460001@32.sanjose-08-09rs16rt.ca.dial-access.att.net>

In article <yND15.143$C02.78014@news.pacbell.net>, "Trevor Sky Garside" <trevor@trevorsky.com> wrote:

>"Bob Tate" <btate@primary.net> wrote in message
>news:1GC15.3868$bc4.262822@news1.primary.net...
>> I am trying to find out if there is a way in Perl to provide a website
>user
>> to a secured website using .htaccess procedures to be able to "Logoff" by
>> clicking a button.  This would remove the reference stored in memory of
>the
>> browser to be removed so that if the user were to click "Refresh" they
>would
>> be asked again to provide the user name/password as if it was there first
>> time.
>>
>> Anyone know if this can be done and how?

>If this can be done, it is not with Perl. 

it can be done with Perl.

-- 
brian d foy
Perl Mongers <URI:http://www.perl.org>
CGI MetaFAQ 
  <URI:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>



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

Date: Wed, 14 Jun 2000 11:30:24 -0400
From: John Wingenbach <jwing@pliantsystems.com>
Subject: Perl code formatter
Message-Id: <3947A510.982B6A86@pliantsystems.com>

Is there any app that can take in a perl script and output the same script in
some decent format?  Some kind of pretty printer?  I have some nicely obfuscated
code that i would like to auto clean up.

--
John C. Wingenbach
Pliant Systems, Inc.
Sr. Systems Administrator
Work: (919) 405-4627
Fax:  (919) 405-4544





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

Date: Wed, 14 Jun 2000 16:42:10 GMT
From: sjs@yorku.ca (Steven Smolinski)
Subject: Re: Perl code formatter
Message-Id: <slrn8kfde4.11n.sjs@john.sympatico.ca>

John Wingenbach <jwing@pliantsystems.com> wrote:
>Is there any app that can take in a perl script and output the same script in
>some decent format?  Some kind of pretty printer?  I have some nicely obfuscated
>code that i would like to auto clean up.

perldoc -q pretty

should answer some of ytour questions.

Steve


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

Date: Wed, 14 Jun 2000 21:34:16 GMT
From: tlars@my-deja.com
Subject: perl returning hash of my variables
Message-Id: <8i8ton$i2e$1@nnrp1.deja.com>

I'd like to write a perl module such that I can copy the values of all
package level "my" variables (assume module has only one package) into
a hash and return a ref to the hash.

package Test;

my one = "hello";
my two = "hi";
my three = "howdy";

sub returnAllVariables {
  ...code here...
}

--------
somewhere in program
--------

 $href = Test::returnAllVariables();

 #now
 # $href->{one} is "hello"
 #$href->{two} is "hi"
 #$href->{three} is "howdy"

I really don't need to use "my" variables. I could use package scoped
dynamic vars.  However, I'd like to make the variables invisible
outside the package or  make the variables constants.  I know that my
is any easy way to make the variables invisible. Not sure how to make
the vars constant.  "use constant" did not seem like it would work in
this case.

Basically, I'm trying to mimic the properties files in Java.  Any ideas.

Thanks,

tlars


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 14 Jun 2000 10:43:24 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl Search |more option
Message-Id: <Pine.GSO.4.10.10006141042150.5301-100000@user2.teleport.com>

On Wed, 14 Jun 2000, Jimmy Humphrey wrote:

> I was wondering what might be a good way to sort search listings by the
> first "10" or something to that degree when returning a large amount of
> listings.  Should I just print out my first 10, and then have the
> program remember to next time just print out 11-21 or something to that
> degree? Or is there a perl, or CGI.pm way of stacking such information
> without having to query a database each time?

I think you could use the methods in Randal's second Web Techniques
column, which explains how to do something like what you want. Hope this
helps!

   http://www.stonehenge.com/merlyn/WebTechniques/

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 14 Jun 2000 18:00:20 GMT
From: law_40@my-deja.com
Subject: Re: Perl Search |more option
Message-Id: <8i8h78$7s4$1@nnrp1.deja.com>

ls -t | tail -n 10 (last ten by time created from bottom)
or
ls -t | head -n 10 (last ten by time created from top)

In article <394795A7.576EBCED@blackhole-designs.com>,
  Jimmy Humphrey <jimmy@blackhole-designs.com> wrote:
>
> I was wondering what might be a good way to sort search listings by
the
> first "10" or something to that degree when returning a large amount
of
> listings.  Should I just print out my first 10, and then have the
> program remember to next time just print out 11-21 or something to
that
> degree? Or is there a perl, or CGI.pm way of stacking such information
> without having to query a database each time?
>
> This would work kinda like "ls |more" in unix.  I created something
> where you do a for i; loop, but I was thinking there must be an easier
> way.
>
> Jimmy
>
> --
> Jimmy Humphrey <jimmy@blackhole-designs.com>
> Web Designer - Black Hole Designs - http://www.blackhole-designs.com
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 14 Jun 2000 11:25:52 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: perl system call problems, VSS cmd line
Message-Id: <MPG.13b16e07ca6057c598ab76@nntp.hpl.hp.com>

In article <jhleksc8d892pfbm43bodiaiptvukoql3s@4ax.com> on Wed, 14 Jun 
2000 12:28:26 +0200, Abe Timmerman <abe@ztreet.demon.nl> says...
> On Wed, 14 Jun 2000 08:11:17 GMT, DEarl@NewYorker.DE (David Earl) wrote:
> > On Tue, 13 Jun 2000 08:58:09 -0700, Tom Phoenix <rootbeer@redcat.com> wrote:
> > > On Tue, 13 Jun 2000 invinfo@my-deja.com wrote:
> > > > Most of the script runs fine up until this line
> > > > system "E:\Progra~1\VSS\Win32\ss Add tiny.pm -Y -C";
> > > 
> > > Did you realize that there are no backslashes in that command? It may be
> > > hard to believe, but if you change 'system' to 'print' you may see what I
> > > mean.
> > 
> > Huh?  You must mean foreslashes, since there is nothing but
> > backslashes in there.
> 
> Did you actualy replace the 'system' with 'print' before you posted your
> message?
> Output:
> 	E:Progra~1VSSWin32ss Add tiny.pm -Y -C

And, using Perl 5.6.0 with '-w', warnings about invalid escape 
sequences.  Wonderful, wonderful, wonderful!

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 14 Jun 2000 15:08:43 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Perl Threads
Message-Id: <%dN15.475$Zg4.3056@news1.rdc1.ct.home.com>

Marco Natoni <blah@nospam.com> wrote:
> Rich,

> Rich Robinson wrote:
>> I'm looking into multithreading with Perl.  Firstly - is it
>> possible?  I've found no information on the subject so far.

>   Its depend on the Perl version you are using.  A good way to check
> that is to type

> 	$ perldoc -m Thread

> at the command line. Version 5.005_03 (built for i386-linux) does not
> answer (No documentation found for "Thread") while Version 5.6.0 (built
> for MSWin32-x86-multi-thread) results in good a Thread.pm explanation. 

That's because the Thread module wasn't installed by default with perl
5.005_0x unless you were building it with threads. As of 5.6.0 it's always
installed, though it doesn't work unless you build perl threaded. You
still, though, have the docs available.

>> Secondly - is it efficient, or would I be better off doing it with 
>> C or Java?  (Multithreading being particularly easy to program 
>> in Java)

From a programming standpoint it's pretty efficient. From a runtime
standpoint it's not, giving you a pretty big hit (20% or so) for the
capability. This penalty may be reduced at some point in the future, but
there's nothing definite on the horizion at the moment.

					Dan


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

Date: Wed, 14 Jun 2000 10:06:09 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perlmagick and CGI
Message-Id: <Pine.GSO.4.10.10006141005260.5301-100000@user2.teleport.com>

On Wed, 14 Jun 2000 bann3094@my-deja.com wrote:

> when I run the script from the command line the script
> works fine, but if I run the script as a CGI, 

When you're having trouble with a CGI program in Perl, here's a handy
troubleshooting guide to get you back on track. 

   http://www.smithrenaud.com/public/troubleshooting_CGI.html

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 14 Jun 2000 10:07:22 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Please help!  Win2000 server/perl issue  
Message-Id: <Pine.GSO.4.10.10006141006530.5301-100000@user2.teleport.com>

On Wed, 14 Jun 2000, Ron Dippold wrote:

> Subject: Please help!  Win2000 server/perl issue  

When you're having trouble with a CGI program in Perl, here's a handy
troubleshooting guide to get you back on track. 

   http://www.smithrenaud.com/public/troubleshooting_CGI.html

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 14 Jun 2000 10:16:31 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Problem with regexp
Message-Id: <slrn8kf4tv.48e.tadmc@magna.metronet.com>

On Wed, 14 Jun 2000 12:52:41 GMT, Antti-Jussi Korjonen <Antti-Jussi.Korjonen@sonera.com> wrote:
>
>$temp1 should be extracted from $string1 so that all that remains
>is '\nfourth test'. doesn't work.


>my $temp1 = "first test\nsecond test\nthird [test]";
>my $temp2 = "first test\nsecond test\nthird"; ^
>                                              |
>$string1 =~ s/$temp1//;                       |
>                                              |
># why doesn't this match [test] ---------------


Because the pattern wants one of "t", "e", or "s" at that
position, and the string it is matching against has a "["
at that position, so no match.

Square brackets are meta in regexes (they specify a "character class").

You need to escape (backslash) them if you want to match
a literal square bracket:


   $string1 =~ s/\Q$temp1//; # or "$temp1 = quotemeta $temp1;" before the match


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


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

Date: Wed, 14 Jun 2000 10:41:03 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Problem with regexp
Message-Id: <slrn8kf6bv.4al.tadmc@magna.metronet.com>

On Wed, 14 Jun 2000 14:23:25 GMT, Rafael Garcia-Suarez <garcia_suarez@hotmail.com> wrote:

>in a regexp, you should escape it with a backslash.
>  my $temp1 = "first test\nsecond test\nthird \[test\]";


There still is no backslash in $temp1.

Print it out and see.


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


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

Date: Wed, 14 Jun 2000 11:47:23 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Problem with regexp
Message-Id: <MPG.13b173128181b8598ab77@nntp.hpl.hp.com>

In article <CIM15.102$%Q.6973@nntp1.onemain.com> on Wed, 14 Jun 2000 
07:34:55 -0700, Trevor Sky Garside <trevor@trevorsky.com> says...

 ...

> my $temp1 = "first test\nsecond test\nthird \\[test\\]";

 ...

> $string1 =~ s/$temp1//;

 ...

> See how I forced there to be a \ in front of both bracket characters?

For the record, there is no need to escape the ']', because ']' has 
metasemantics only as the second-or-later character in a character 
class, and escaping the '[' means that there is no character class 
present.

> I should mention that I'm pretty sure there's a function available to turn a
> string into something usable as part of a regular expression, but I can't
> remember what that is, or how it is used.  Anyhow, for this example, adding
> the escape character seems to fix things.

perldoc -f quotemeta

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 14 Jun 2000 20:21:39 GMT
From: law_40@hotmail.com
Subject: push question
Message-Id: <8i8pfu$ekp$1@nnrp1.deja.com>

I have an array $array="1 2 3 4 5 6";

if i want to append an element to the array by way of the push command,
so that $array ="1 2 3 4 5 6";

how can I do that?  I tried

push @array, "6";

with this command, $array="1 2 3 4 5" and @array="6";

when I try

push $array, "6";

errors occur...


any suggestions?


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 14 Jun 2000 15:34:13 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: push question
Message-Id: <878zw8j92y.fsf@limey.hpcc.uh.edu>

>> On Wed, 14 Jun 2000 20:21:39 GMT,
>> law_40@hotmail.com said:

> I have an array $array="1 2 3 4 5 6"; if i want to

Err, no, that's a string, not an array.

> append an element to the array by way of the push
> command, so that $array ="1 2 3 4 5 6";

Another string.

> how can I do that?  I tried
> push @array, "6";

$array (sic) is a string.  @array is undefined before
this.

(And why the double quotes around 6?)

> with this command, $array="1 2 3 4 5" and @array="6";

> when I try
> push $array, "6";
> errors occur...

$array is a string, not an array.

    my @arr = (1, 2, 3, 4, 5);
    push @arr, 6;
    
    print "@arr\n";
    print join(', ', @arr), "\n";

The following will be of help:

perldoc perldata
perldoc perldsc



hth
t
-- 
"Trying is the first step towards failure"
                                           Homer Simpson


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

Date: Wed, 14 Jun 2000 16:37:52 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: push question
Message-Id: <3947ED20.FF69535A@attglobal.net>

law_40@hotmail.com wrote:
> 
> I have an array $array="1 2 3 4 5 6";

I see you have bad habits.  $array ne @array.  Don't use a scalar where
you intend to have an array context =)

@array = qw/1 2 3 4 5 6/;

> if i want to append an element to the array by way of the push command,
> so that $array ="1 2 3 4 5 6";

print $array; would return 1 2 3 4 5 6.  

> push @array, "6";
> 
> with this command, $array="1 2 3 4 5" and @array="6";

Logic tells _me_ that this is because $array is, as mentioned,
an entirely different beast than @array.  So the push() is working,
but it is not, as expected, impacting $array.  There is a mnemonic
to help you.  $ is like S for scalar, while @ is like A for array.

> when I try
> 
> push $array, "6";
> 

Hmm. Don't use a scalar where you mean an array.  But I've said 
that already.


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

Date: Wed, 14 Jun 2000 13:50:09 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: push question
Message-Id: <8i8r4l$oq1$1@brokaw.wa.com>


<law_40@hotmail.com> wrote in message news:8i8pfu$ekp$1@nnrp1.deja.com...
> I have an array $array="1 2 3 4 5 6";

That is not an array.  It is a scalar that contains the string "1 2 3 4 5
6".

> if i want to append an element to the array by way of the push command,
> so that $array ="1 2 3 4 5 6";
>
> how can I do that?  I tried
>
> push @array, "6";
>
> with this command, $array="1 2 3 4 5" and @array="6";

No, @array = 1.  $array[0] = "6".

> when I try
>
> push $array, "6";
>
> errors occur...
>
>
> any suggestions?

Obtaining a basic understanding of Perl's variables should be your first
priority.

perldoc perldata

(Type the above line into a command prompt)

Once you have a firm grasp of what the differences between scalars and
arrays are, try:

perldoc -f push

While you are at it, type

perldoc perldoc

too.

Lauren




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

Date: Wed, 14 Jun 2000 15:03:42 GMT
From: law_40@my-deja.com
Subject: Re: pw() function question
Message-Id: <8i86s0$v25$1@nnrp1.deja.com>

Thanks for the help, I really appreciate it!
In article <8i6hgu$e3v$1@brokaw.wa.com>,
  "Lauren Smith" <lauren_smith13@hotmail.com> wrote:
>
> Ivo Zdravkov <ivoz@starmail.com> wrote in message
> news:3946c394_2@news.nwlink.com...
> >
> > <law_40@my-deja.com> wrote in message news:8i6b5v$kf4
$1@nnrp1.deja.com...
> > >
> > > @array=qw($text);
> > >
> > > it does not work.  @array only gets assigned @array[0]=$text...
> > >
> > > any suggestions?
> >
> > @array=split (/\w+/, $text);
> >
>
> Close, but you have the logic backwards.  The OP wants to split on
spaces,
> not on words.
>
> @array = split (/\s+/, $text);
>
> Lauren
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 14 Jun 2000 15:14:03 -0500
From: Eric Liao <ekliao@mediaone.net>
Subject: Question: any ASP parser available?
Message-Id: <qkpfkso267cqqhvti5u6ilbab12kqffbo9@4ax.com>

Hi All,

My work requires parsing *.asp files for identifying and extracting
certain text strings for the purposes of translation (into foreign
languages).  Is there any ASP parser out there that is
available/useful for such purposes?  Any input welcome.  Thanks.

-Eric


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

Date: Wed, 14 Jun 2000 14:40:07 -0700
From: glauber <glauber.ribeiroNOglSPAM@experian.com.invalid>
Subject: Re: Question: any ASP parser available?
Message-Id: <2f979490.51ad87f9@usw-ex0102-016.remarq.com>

ASP is a Microsoft bastard^H^H^H^H^H^H^Happlication of HTML, so
anything you can use to parse HTML will apply.

I suggest you go to http://www.cpan.org or
http://search.cpan.org and look for HTML parsers.


good luck!

glauber

* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: Wed, 14 Jun 2000 09:51:40 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Quick Network Ping : Can't make Net::Ping work?
Message-Id: <Pine.GSO.4.10.10006140950130.5301-100000@user2.teleport.com>

On Wed, 14 Jun 2000, Robert Chalmers wrote:

> I tried the code example here on the cpan site, but can't get it to do
> anything?

> use Net::Ping;
> 
> 
>     $p = Net::Ping->new();
>     print "$host is alive.\n" if $p->ping($host);


Perhaps you forgot to set $host? Is it really that simple?

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 14 Jun 2000 19:57:37 +0200
From: "Thomas Kratz" <Thomas.Kratz@lrp.de.nospam>
Subject: Re: Registry Editing - A living hell....
Message-Id: <3947cae9.0@juno.wiesbaden.netsurf.de>


Dan Richfield wrote in message ...
>
>I have had serious problems with perl registry editing for a long
>time, and i finally figured out how to get what I needed done with
>Win32:Registry.  So I upgraded to the latest perl (ActiveState 5.6),
>and now my old code doesnt work at all.. I tried to figure out
>TieRegistry, but that is a damn nightmare.  The examples in the
>activestate documentation always seemed to work, but whenever i would
>change the path to access a key other than within the
>LMachine/Software/Microsoft tree, it wouldnt return any data.  I am
>not a expert, but i did follow all instructions perfectly and double
>checked everything.  If someone would be kind enough to get me on the
>right track with the basic commands in TieRegistry before i kick
>through all the walls in my house, it would be greatly appreciated.
>
>Dan

Ok, but only to save those innocent walls ;-)

The following script changes the nameserver entries on a remote machine

-- cut here --

use Win32::TieRegistry(Delimiter => '/', ArrayValues => 1);


sub PrintParam {
   my($Str) = @_;

   $NSList = $CCSS->{"Tcpip/Parameters//NameServer"}->[0];
   $Search = $CCSS->{"Tcpip/Parameters//SearchList"}->[0];

   print "===$Str===\n";
   print "NameServer:        $NSList\n";
   print "SearchList:        $Search\n";
}

# main

$| = 1;

$nodename  = shift;

$NS_New     = 'aaa.bbb.ccc.ddd eee.fff.ggg.hhh';
$Search_New = 'search.com sub.search.com';

foreach $arg (@ARGV) {
   if ($arg eq "/w") {$write = 1;}
}

$CCSSPath = "//$nodename/LMachine/SYSTEM/CurrentControlSet/Services/";

$CCSS = $Registry->{$CCSSPath};
die("Could not connect to $nodename") unless $CCSS;

$CCSS->SplitMultis(1);

if ($write) {
   $CCSS->{"Tcpip/Parameters//NameServer"} = $NS_New;
   $CCSS->{"Tcpip/Parameters//SearchList"} = $Search_New;
   PrintParam("CHANGED!");
} else {
   PrintParam("UNCHANGED!");
}





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

Date: Wed, 14 Jun 2000 09:47:48 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Remote .htpasswd editting
Message-Id: <Pine.GSO.4.10.10006140947310.5301-100000@user2.teleport.com>

On Wed, 14 Jun 2000 tpaulakis@businessedge.com wrote:

> I've been forever searching on the web for a perl script that lets an
> authenticated user change his password (and his password alone)
> without compromising the security of the other .htpasswd entries.

If there's a module which does what you want, it should be listed in
the module list on CPAN. If you don't find one to your liking, you're
welcome and encouraged to submit one! :-)  Hope this helps!

    http://search.cpan.org/
    http://www.cpan.org/

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 13 Jun 2000 23:47:03 -0700
From: Marc Loosli <marcNOmaSPAM@loosli.ws.invalid>
Subject: Repleace "/" with "\"
Message-Id: <105d972d.86aa30bd@usw-ex0104-026.remarq.com>

Hi,
I am currently facing a problem of replacing "/" with "\".

Also, if I do this:
$in = "C:/dir/dir/file";
xxxxxxxxxxxxxxxxxxxxxxxxxx
print $in; #now print c:\dir\dir\file


If anyone has the idea how to deal with the "/", would you
please reply to this newsgroup? Thank you very much for the help.

Best Regards
Marc Loosli



* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: Wed, 14 Jun 2000 12:47:06 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Repleace "/" with "\"
Message-Id: <MPG.13b181198fdb15d198ab7b@nntp.hpl.hp.com>

In article <105d972d.86aa30bd@usw-ex0104-026.remarq.com> on Tue, 13 Jun 
2000 23:47:03 -0700, Marc Loosli <marcNOmaSPAM@loosli.ws.invalid> 
says...
> I am currently facing a problem of replacing "/" with "\".
> 
> Also, if I do this:
> $in = "C:/dir/dir/file";
> xxxxxxxxxxxxxxxxxxxxxxxxxx
> print $in; #now print c:\dir\dir\file
> 
> 
> If anyone has the idea how to deal with the "/", would you
> please reply to this newsgroup? Thank you very much for the help.

To replace / with \, use the tr (translate) operator described in 
perlop.

    $in =~ tr%/%\\%;

But ask yourself why you want to do this.  Except for the primitive 
command interpreters, forward slashes work just as well as backslashes 
for the Windows/DOS file systems (one of the Best-Kept Secrets).

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 14 Jun 2000 11:53:09 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Script to calculate a future date?
Message-Id: <MPG.13b1746a49156fc598ab78@nntp.hpl.hp.com>

In article <8i81lr$obd$1@tron.sci.fi> on Wed, 14 Jun 2000 16:34:53 
+0300, René Hertell <news@hertell.remove.t_h_i_s.com> says...
> I'm new to perl, and I would need help with calculating a future date.
> e.g.
> 14.06.2000 + 14 would return 28.06.2000
> 28.06.2000 + 4 would return 02.07.2000
> 28.12.2000 + 4 would return 01.01.2001
> 
> can someone help me with this, e.g. if you know where I could find a ready
> script for this purpose

perlfaq4: "How can I take a string and turn it into epoch seconds?"

perlfaq4: "How do I find yesterday's date?"

   Use your imagination to adapt the latter answer to your needs.  :-)

perldoc Time::Local

perldoc -f localtime

perldoc -f sprintf

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

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


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