[17096] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4508 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 3 18:05:44 2000

Date: Tue, 3 Oct 2000 15:05:17 -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: <970610717-v9-i4508@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 3 Oct 2000     Volume: 9 Number: 4508

Today's topics:
    Re: Add on nobull@mail.com
    Re: Blank line appending data to file <nige@npay.freeserve.co.uk>
    Re: converting \codes <lr@hpl.hp.com>
    Re: converting \codes (Sean McAfee)
        Easy installation of modules <zoo.tv@btinternet.com>
    Re: Easy installation of modules <elaine@chaos.wustl.edu>
        Error handling in Perl nikitak@my-deja.com
        Error handling in Perl nikitakin@yahoo.com
    Re: Error handling in Perl <ren.maddox@tivoli.com>
    Re: Error handling in Perl <elaine@chaos.wustl.edu>
        feeding password to host secure copy (scp) fsiegel@my-deja.com
    Re: feeding password to host secure copy (scp) <elaine@chaos.wustl.edu>
    Re: feeding password to host secure copy (scp) <dsimonis@fiderus.com>
    Re: feeding password to host secure copy (scp) fsiegel@my-deja.com
    Re: feeding password to host secure copy (scp) <peter.sundstrom@eds.com>
    Re: force arithmetic interpretation <anmcguire@ce.mediaone.net>
        fork and exec related question: cchristophe@my-deja.com
    Re: fork and exec related question: <uri@sysarch.com>
    Re: fork and exec related question: <anders@wall.alweb.dk>
    Re: Hash of Arrays oddness? <uri@sysarch.com>
    Re: Hash of Arrays oddness? <ren.maddox@tivoli.com>
    Re: Having trouble with substitution of a variable that <tim@ipac.caltech.edu>
    Re: Help : using Perl DBI on Linux (Chris Fedde)
    Re: How do I change the position on screen where to pri <anders@wall.alweb.dk>
    Re: How do I change the position on screen where to pri (Chris Fedde)
    Re: How do I change the position on screen where to pri <anmcguire@ce.mediaone.net>
    Re: How to get length of scalar? <ren.maddox@tivoli.com>
    Re: how to split text by number of words? <anmcguire@ce.mediaone.net>
    Re: Limiting Form Field Input? <jeffp@crusoe.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 03 Oct 2000 19:09:32 +0100
From: nobull@mail.com
Subject: Re: Add on
Message-Id: <u9snqdokyr.fsf@wcl-l.bham.ac.uk>

kily@my-deja.com writes:
> 
> Now the line: perl -pe "s/.*\s+..(.*)/\L$1/" <infile.txt > outfile.txt
> works at prompt line, but when I try to put: 's/.*\s+..(.*)/\L$1/' in
> file like somthing.pl and then at DOS prompt type:
> perl somthing.pl <infile.txt > outfile.txt, I find the file outfile.txt
> is empty. Can you explain what wrong?

Did you perhaps ignore the bit where I showed you to put a -p in the
shebang line?

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Tue, 3 Oct 2000 22:31:08 +0100
From: "Nige P" <nige@npay.freeserve.co.uk>
Subject: Re: Blank line appending data to file
Message-Id: <8rdj8e$1c$1@newsg2.svr.pol.co.uk>

Thanks Gwyn,
Apologies for the format - this should be better?

Essentially $login is a variable used to enter the 'type xxxx' command
on the command line.... does that help?
Failing that, I can post the script up tomorrow....
Thanks again.


Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote 
> I was shocked! How could Nige P <nige@npay.freeserve.co.uk>
> say such a terrible thing:
> >This is a multi-part message in MIME format.
> 
> Please don't do this. Long standing usenet tradition dictates that you
> should post in plain-text only, thanks.
> 
> >Can anyone enlighten me please....?
> >I am returning the contents of a file xxxx until a $ is detected.
> >This data is then appended into another file yyyy.
> >
> >However each time this occurs I get a blank line between
> >the data, but I cannot see why.....
> >
> >Many thanks for any input.
> >
> >$login->print("type xxxx");
> >                    ($alertfile) = $login->waitfor('/\$ *$/');
> >
> >                        open (LIVEFILE,">>yyyy") ||
> >die "Could not open file\n";
> >                        print LIVEFILE "$alertfile";
> 
> Well it's really impossible to tell without knowing what $login is (I'm
> guessing it's an object of some sort). Can you post a short snippet that
> runs and exhibits the behaviour?
> 
> -- 
> Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
> Decorate your home. It gives the illusion that your life is more
> interesting than it really is.
> -C. Schulz



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

Date: Tue, 3 Oct 2000 13:15:13 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: converting \codes
Message-Id: <MPG.1443de294b069d1998adfb@nntp.hpl.hp.com>

In article <MPG.14432ff39f89110098adfa@nntp.hpl.hp.com> on Tue, 3 Oct 
2000 00:51:56 -0700, Larry Rosler <lr@hpl.hp.com> says...

 ...

> #!/usr/bin/perl -wl
> use strict;
> 
> $_ = '\t \n \r \033 \x1B \c[';
>  
> my %escapes = map { $_ => eval qq("\\$_") } qw( a e f n r t );
> 
> s{\\( 0[0-7]{0,3} | x([\da-fA-F]{1,2}) | c(.) | [aefnrt] ) }
>  {  my $x = substr $1, 0, 1;
>     $x eq '0' ? chr oct $1 :
>     $x eq 'x' ? chr hex $2 :
>     $x eq 'c' ? chr ord $3 & "\x1F" :
>                 $escapes{$1} }egx;
> 
> print unpack 'H*' => $_;

Correcting and improving my code, based on the other responses in this 
thread:

  my %escapes = map { $_ => eval qq("\\$_") } qw( a b e f n r t );

  s{\\( ([0-7]{1,3}) | x([\da-fA-F]{1,2}) | c(.) | [abefnrt] ) }
   { defined $2 ? chr oct $2          :
     defined $3 ? chr hex $3          :
     defined $4 ? chr ord $4 & "\x1F" :
                  $escapes{$1} }egx;
  
This still doesn't handle the newer exotic escape sequences described in 
perlop, 'wide hex char' and 'named char'. Adding them is left as an 
exercise for the reader.  :-)

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


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

Date: Tue, 03 Oct 2000 21:29:25 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: converting \codes
Message-Id: <VcsC5.5615$O5.120571@news.itd.umich.edu>

In article <MPG.1443de294b069d1998adfb@nntp.hpl.hp.com>,
Larry Rosler  <lr@hpl.hp.com> wrote:
>In article <MPG.14432ff39f89110098adfa@nntp.hpl.hp.com> on Tue, 3 Oct 
>2000 00:51:56 -0700, Larry Rosler <lr@hpl.hp.com> says...
>  my %escapes = map { $_ => eval qq("\\$_") } qw( a b e f n r t );
>
>  s{\\( ([0-7]{1,3}) | x([\da-fA-F]{1,2}) | c(.) | [abefnrt] ) }
>   { defined $2 ? chr oct $2          :
>     defined $3 ? chr hex $3          :
>     defined $4 ? chr ord $4 & "\x1F" :
>                  $escapes{$1} }egx;

This can actually be tightened up a bit more, since oct() can handle
hexadecimal notation as well:

  s{\\( ([0-7]{1,3} | x[\da-fA-F]{1,2}) | c(.) | [abefnrt] ) }
   { defined $2 ? chr oct $2          :
     defined $3 ? chr ord $3 & "\x1F" :
                  $escapes{$1} }egx;

Although perlfunc claims oct only treats its argument as hexadecimal if it
begins with "0x", it seems that a single "x" works as well.

-- 
Sean McAfee                                                mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!


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

Date: Tue, 3 Oct 2000 21:12:28 +0100
From: <zoo.tv@btinternet.com>
Subject: Easy installation of modules
Message-Id: <8rdeor$43n$1@uranium.btinternet.com>

HI,

Can you put any module as the script you are calling from, or do they have
to be installed properly?

The module in question is DBI.pm. The hosting company of a site I'm working
on doesn't have it but I need it to connect to a mySQL database on another
server. I guess I'd have to put the mysql.pm (DBD) module in there too.

Any ideas?

Pete Smith

______________________________________________________________________

'But you haven't come out all this way to watch TV now have ya?'
zoo.tv@btinternet.com




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

Date: Tue, 03 Oct 2000 21:20:29 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: Easy installation of modules
Message-Id: <B5FFC5E2.7514%elaine@chaos.wustl.edu>

in article 8rdeor$43n$1@uranium.btinternet.com, zoo.tv@btinternet.com at
zoo.tv@btinternet.com quoth:
> Can you put any module as the script you are calling from, or do they have
> to be installed properly?
> 
> The module in question is DBI.pm. The hosting company of a site I'm working
> on doesn't have it but I need it to connect to a mySQL database on another
> server. I guess I'd have to put the mysql.pm (DBD) module in there too.

http://www.symbolstone.org/technology/perl/DBI/doc/faq.html
http://theoryx5.uwinnipeg.ca/CPAN/perl/pod/perlfaq8.html

Perlfaq8 will answer question #1 of 'how do I install my own modules without
having root' ...at least that's what I'm guessing your question
is...otherwise, no a module is not a script.

The DBI FAQ should answer some of the questions you may have on getting
remote db connections to work for you.

enjoy.

e.



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

Date: Tue, 03 Oct 2000 19:55:48 GMT
From: nikitak@my-deja.com
Subject: Error handling in Perl
Message-Id: <8rddk0$b74$1@nnrp1.deja.com>

Hi,
I have been trying to do error handling in Perl other than using
eval/die.
For this have been looking at Error.pm by Graham Barr.

There is a line of code here in which a sub routine is declared as:
sub sub_routine1($$$\@){}
sub sub_routine2(&;$){}

If I remove these special variables, then the code soes not compile.
What is the significance of these parameters?

Regards,
Nikita K


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


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

Date: Tue, 03 Oct 2000 20:24:27 GMT
From: nikitakin@yahoo.com
Subject: Error handling in Perl
Message-Id: <8rdf9h$cnc$1@nnrp1.deja.com>

Hi,
I have been trying to do error handling by using Error.pm package in
CPAN.

The module has 2 subroutines defined as follows:
sub sub_routine1($$$\@){}
sub sub_routine2(&;$){}

If I remove these characters, the program does not compile.
What is the purpose and use of these characters?

Regards,
Nikita K


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


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

Date: 03 Oct 2000 15:17:15 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Error handling in Perl
Message-Id: <m3pulhof1w.fsf@dhcp11-177.support.tivoli.com>

nikitak@my-deja.com writes:

> Hi,
> I have been trying to do error handling in Perl other than using
> eval/die.
> For this have been looking at Error.pm by Graham Barr.
> 
> There is a line of code here in which a sub routine is declared as:
> sub sub_routine1($$$\@){}
> sub sub_routine2(&;$){}
> 
> If I remove these special variables, then the code soes not compile.
> What is the significance of these parameters?

If I understand you correctly, then the information you want can be
found in:

perldoc perlsub

Search for "Prototypes".

-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 03 Oct 2000 21:28:36 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: Error handling in Perl
Message-Id: <B5FFC7CA.7516%elaine@chaos.wustl.edu>

in article 8rdf9h$cnc$1@nnrp1.deja.com, nikitakin@yahoo.com at
nikitakin@yahoo.com quoth:
> I have been trying to do error handling by using Error.pm package in
> CPAN.
> 
> The module has 2 subroutines defined as follows:
> sub sub_routine1($$$\@){}
> sub sub_routine2(&;$){}
> 
> If I remove these characters, the program does not compile.
> What is the purpose and use of these characters?

See your Camel book on prototyping or use 'perldoc perlfunc' to see what the
prototype function is. Basically, it tells the compiler what types and how
many arguments to expect so that your subroutines have the look and feel of
built-in functions. e.g. $$$@ means that it can expect 3 scalars and an
array...a semi-colon means anything after it is optional.

If you don't know what it is or does, generally deleting shit randomly isn't
a splendid idea. :)

e.




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

Date: Tue, 03 Oct 2000 18:47:46 GMT
From: fsiegel@my-deja.com
Subject: feeding password to host secure copy (scp)
Message-Id: <8rd9kg$7g0$1@nnrp1.deja.com>

Hello,

With a PERL script, I am trying to feed a password to a UNIX scp (secure
copy) command: From an o/s perspective echo'ing a password and piping to
scp does not work.  So within PERL I tried using processes as
filehandles:

$password = 'OsUserPassword';
open(SCP, "|scp  file1.txt  server1:/oracle/admin/scripts/file1.txt");
print SCP $pass;
close(SCP);

Nothing I do prevents scp from prompting me for a password!! scp works
properly when you type the password (even in the PERL script).  Does
anyone know how to invoke a secure copy within PERL feeding the
password?

I really need this and unsecure copying is not an option.
Thank you very much,
Frank


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


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

Date: Tue, 03 Oct 2000 19:37:14 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: feeding password to host secure copy (scp)
Message-Id: <B5FFADAC.74F9%elaine@chaos.wustl.edu>

in article 8rd9kg$7g0$1@nnrp1.deja.com, fsiegel@my-deja.com at
fsiegel@my-deja.com quoth:
 
> I really need this and unsecure copying is not an option.
> Thank you very much,

If it wasn't an option, you wouldn't be putting plain text passwords in
scripts. However, don't despair as you can use RSA keys which will allow you
to do a non-interactive login provided that you take the time to set it up
and configure sshd on both sides to allow for RSA logins if they don't
already. 

If you are attached to keeping the password in the script, you might have a
look at Expect.pm which should sort the present problem for you.

e. 




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

Date: Tue, 03 Oct 2000 16:06:01 -0400
From: Drew Simonis <dsimonis@fiderus.com>
Subject: Re: feeding password to host secure copy (scp)
Message-Id: <39DA3C29.CF96297@fiderus.com>

Elaine Ashton wrote:
> 
> in article 8rd9kg$7g0$1@nnrp1.deja.com, fsiegel@my-deja.com at
> fsiegel@my-deja.com quoth:
> 
> > I really need this and unsecure copying is not an option.
> > Thank you very much,
> 
> If it wasn't an option, you wouldn't be putting plain text passwords in
> scripts. However, don't despair as you can use RSA keys which will allow you
> to do a non-interactive login provided that you take the time to set it up
> and configure sshd on both sides to allow for RSA logins if they don't
> already.


Don't key based logins still require a passphrase to login?
This sounds more like a job for the key and ssh-agent.


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

Date: Tue, 03 Oct 2000 20:08:33 GMT
From: fsiegel@my-deja.com
Subject: Re: feeding password to host secure copy (scp)
Message-Id: <8rdebr$bpp$1@nnrp1.deja.com>

Thanks! At least I have something more to dig into now.

However, I will not hard code the passwords into the script.  Instead I
will prompt the user interactively for the password and then use to copy
to 20 or more servers.  The password will be nowhere in the script.

Thanks again.
frank



In article <B5FFADAC.74F9%elaine@chaos.wustl.edu>,
  Elaine Ashton <elaine@chaos.wustl.edu> wrote:
> in article 8rd9kg$7g0$1@nnrp1.deja.com, fsiegel@my-deja.com at
> fsiegel@my-deja.com quoth:
>
> > I really need this and unsecure copying is not an option.
> > Thank you very much,
>
> If it wasn't an option, you wouldn't be putting plain text passwords
in scripts. However, don't despair as you can use RSA keys which will
allow you to do a non-interactive login provided that you take the time
to set it up and configure sshd on both sides to allow for RSA logins if
they don't already.
>
> If you are attached to keeping the password in the script, you might
have a look at Expect.pm which should sort the present problem for you.
>
> e.
>
>


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


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

Date: Wed, 4 Oct 2000 10:14:17 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: feeding password to host secure copy (scp)
Message-Id: <8rdier$413$1@hermes.nz.eds.com>


Drew Simonis wrote in message <39DA3C29.CF96297@fiderus.com>...
>Elaine Ashton wrote:
>>
>> in article 8rd9kg$7g0$1@nnrp1.deja.com, fsiegel@my-deja.com at
>> fsiegel@my-deja.com quoth:
>>
>> > I really need this and unsecure copying is not an option.
>> > Thank you very much,
>>
>> If it wasn't an option, you wouldn't be putting plain text passwords in
>> scripts. However, don't despair as you can use RSA keys which will allow
you
>> to do a non-interactive login provided that you take the time to set it
up
>> and configure sshd on both sides to allow for RSA logins if they don't
>> already.
>
>
>Don't key based logins still require a passphrase to login?

Some people set null passphrases.

>This sounds more like a job for the key and ssh-agent.

This is the much better option.




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

Date: Tue, 3 Oct 2000 13:22:01 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: force arithmetic interpretation
Message-Id: <Pine.LNX.4.21.0010031320090.7067-100000@hawk.ce.mediaone.net>

On Tue, 3 Oct 2000, Bap quoth:

B> ruzbehgonda@my-deja.com wrote:
B> 
B> > after dynamically building an arithmetic
B> > expression
B> > such as
B> > $arith = ( (1 * 0) + 1) + 1
B> > how can i force perl to evaulate the results??
B> > assigning it to another variable :
B> > $results = $arith + 1;
B> > does not work

[ snip ]

B> ???
B> print eval( $arith ) . "\n";

TESTED:

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

my $expr    = '( (1 * 0) + 1) + 1';
my $results =  eval "$expr + 1";

print "$results\n";

__END__
3

perldoc -f eval

anm
-- 
perl -wMstrict -MText::ParseWords -e "
system echo => grep defined() ? /./ : q++ => quotewords '\s+', 0, <<JAPH;
"""""""""""""""""""""""""""""""" Just    """"""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" another """"""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" Perl    """"""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" Hacker  """"""""""""""""""""""""""""""""
JAPH
"



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

Date: Tue, 03 Oct 2000 17:57:48 GMT
From: cchristophe@my-deja.com
Subject: fork and exec related question:
Message-Id: <8rd6mn$4n6$1@nnrp1.deja.com>

Hi guys

just started playing with perl: in the following code, the file toto is
created but nothing is written, why? (note that when I use the standard
output the number 0 is printed on the screen):

#!/us/bin/perl

if (!defined($kidpid = fork())) {
    die "cannot fork: $!";

} elsif ($kidpid == 0) {
    open(OUT, ">./toto");
    print OUT "$kidpid\n";
    exec("date")||die "can't exec date: $!";

} else {
    waitpid($kidpid, 0);
    print "$kidpid\n";
}


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


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

Date: Tue, 03 Oct 2000 18:26:49 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: fork and exec related question:
Message-Id: <x71yxx6as6.fsf@home.sysarch.com>

>>>>> "c" == cchristophe  <cchristophe@my-deja.com> writes:

  c> just started playing with perl: in the following code, the file
  c> toto is created but nothing is written, why? (note that when I use
  c> the standard output the number 0 is printed on the screen):

  c> } elsif ($kidpid == 0) {
  c>     open(OUT, ">./toto");
  c>     print OUT "$kidpid\n";

you haven't flushed that file before you overwrite the process with the
following exec call. either close the file (which will flush it) or set
$| for it to 1 with select OUT ; $|++ ;

  c>     exec("date")||die "can't exec date: $!";

printing to STDOUT works since it is line buffered by default whereas a
file is block buffered.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Tue, 3 Oct 2000 20:33:26 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: fork and exec related question:
Message-Id: <WEpC5.153$UW.10893@news010.worldonline.dk>

cchristophe@my-deja.com wrote:

> Hi guys
> 
> just started playing with perl: in the following code, the file toto is
> created but nothing is written, why? (note that when I use the standard
> output the number 0 is printed on the screen):
> 
> #!/us/bin/perl
> 
> if (!defined($kidpid = fork())) {
>     die "cannot fork: $!";
> 
> } elsif ($kidpid == 0) {
>     open(OUT, ">./toto");
>     print OUT "$kidpid\n";
>     exec("date")||die "can't exec date: $!";
> 
> } else {
>     waitpid($kidpid, 0);
>     print "$kidpid\n";
> }
> 
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.

You may wish to close FILEHANDLE...

-anders

-- 
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]


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

Date: Tue, 03 Oct 2000 18:05:53 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Hash of Arrays oddness?
Message-Id: <x78zs56br3.fsf@home.sysarch.com>

>>>>> "AP" == Andrew Pearce <pearce@aw.sgi.com> writes:

  AP> Martien Verbruggen wrote:
  >> > I have a hash and one element is to be an array. As I construct it,
  >> > I'm using the push() call as recommended;
  >> 
  >> Recommended by whom?

  AP> By "Perl 5 Complete", by O'Reilly's "Perl Cookbook", by O'Reilly's
  AP> "Learning Perl", by Osborne's "Perl Programmer's Reference" ...

complete and programmer's reference suck. ANY book with perl5 in the
title sucks.

where (quote pages) do the others say to use push to create an array
ref? it can be done but it is overkill in your case.

  AP> Change this slightly and it will not work on your Perl too:

  AP> @a = qw (foo bar baz banana);
  AP> dbmopen( %hash, "test", 0666);
  AP> foreach $ae (@a)
  AP> {
  AP>     push @{$hash{bleb}}, $ae;
  AP> }
  AP> print "@{$hash{bleb}}\n";
  AP> __END__
  AP> bar baz banana

works fine the second time around. it is probably something with dbm and
not with perl itself.


  AP> I thank you for your help and I'm glad I gave you the oportunity
  AP> to be a jerk.

same to you.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 03 Oct 2000 15:08:45 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Hash of Arrays oddness?
Message-Id: <m3snqdofg2.fsf@dhcp11-177.support.tivoli.com>

Andrew Pearce <pearce@aw.sgi.com> writes:

> @a = qw (foo bar baz banana);
> dbmopen( %hash, "test", 0666);
> foreach $ae (@a)
> {
>     push @{$hash{bleb}}, $ae;
> }
> print "@{$hash{bleb}}\n";
> __END__
> bar baz banana

Looks like a bug in the dbm code, though it does seem a little severe
to consider it a bug when dbm is documented to not store references
(and I do realize that you already knew that and I'm not lecturing).
I would presume that the auto-vivification is not occurring in the
context of the tie in time for the push.

As Uri pointed out, it works fine the second time.  So perhaps the bug
only occurs when the key is being added to the dbm file in the first
place.

Are you seeing this problem occurring in a different use of tie, where
the references *should* work?

-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 03 Oct 2000 11:40:09 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Having trouble with substitution of a variable that contains a "/"
Message-Id: <39DA2809.918A11C3@ipac.caltech.edu>

"James M. Luongo" wrote:
> 
> I am reading in from an input file and grabbing a date.  The input file
> is a .csv (comma separated).  Anyway, the date is in the format
> "09/22/00"
> so i grab the date correctly (i printed it after the split (/,/, $_) )

As you may now, splitting CSV files is more complicated than that. E.g. what if
a string like "1,2,3" occupies one field? Theres a module for handling CSV files
on CPAN. But anyway, that's probably not your problem ... yet.

> the next step is to take out the quotations
> so i do this:
> $date =~ s/\"//g;  # i tried s/"//g; before that

Both forms are fine. Quote is not special in REs unless you've made the
delimiter a quote, which you haven't.

> and then when i print out the date, i get nothing...the value seems to
> be nil
> i will continue working on this, but if anyone can offer any help,
> please do

I can't see your problem without seeing some code. How 'bout sending a short
code snippet with some data that displays your problem. I'll bet you find the
problem while constructing the test case.

--

-- Tim Conrow         tim@ipac.caltech.edu                           |


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

Date: Tue, 03 Oct 2000 18:45:38 GMT
From: cfedde@u.i.sl3d.com (Chris Fedde)
Subject: Re: Help : using Perl DBI on Linux
Message-Id: <mPpC5.102$D4.170306560@news.frii.net>

In article <zMmC5.313117$1h3.7479757@news20.bellglobal.com>,
Etienne Laverdiere <info@digitaltango.com> wrote:
>
>Question 3 : Should I forget ActivePerl and use the default Perl
>distribution? (Perl 5.6.0)
>

There is activeperl for linux available.  Still it's bonehead easy
to build perl from the sources.  Just fetch them from www.cpan.org
and follow the directions in the README and INSTALLATION file.
Also read about and learn to use the CPAN module.  It makes installing
and maintaining modules from CPAN sources simple as falling off a log.

My opinion?  Activestate releases of perl represent a divergent
branch from the default trunk.  Over time the vendors desire to
differentiate themselves from the opensource will lead to arbitrary
differences that will make the two versions less and less compatible.

chris
-- 
    This space intentionally left blank


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

Date: Tue, 3 Oct 2000 20:05:51 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: How do I change the position on screen where to print?
Message-Id: <3fpC5.163$u23.12398@news000.worldonline.dk>

Peter Levi wrote:

> Help guys!I want to show on the screen the process of downloading a file -
> so I have to print for example "12%, 12520 bytes read".And I want this to
> appear on one and the same place on the screen. (to replace the previous
> "10%, 10380 bytes read" for
> example).How do I do this!Because currently  I print the new data on a new
> line - very embarassing and ugly!How can I change the position of the
> marker where I want to print?Peter
> 

You'd like to take a look at Term::Screen

-anders

-- 
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]


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

Date: Tue, 03 Oct 2000 18:27:31 GMT
From: cfedde@u.i.sl3d.com (Chris Fedde)
Subject: Re: How do I change the position on screen where to print?
Message-Id: <nypC5.101$D4.170306560@news.frii.net>

Please excuse the Jeopardy style quoting here.  It was done for
effect.  Also see an old thread about spinning batons or some
such.

#!/usr/bin/perl -w
$|=1;
print "\n";

while(<DATA>)
{
    chomp;
    print "\r$_". ' ' x (79 - length($_));
    sleep 1;
}
print "\n";

__END__
In article <1105_970595913@default>,
Peter Levi  <peterlevi@bulgaria.com> wrote:
>Help guys!I want to show on the screen the process of downloading a file -
>so I have to print for example "12%, 12520 bytes
>read".And I want this to appear on one and the same place on the screen.
>(to replace the previous "10%, 10380 bytes read" for
>example).How do I do this!Because currently  I print the new data on a new
>line - very embarassing and ugly!How can I change the
>position of the marker where I want to print?Peter
-- 
    This space intentionally left blank


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

Date: Tue, 3 Oct 2000 13:58:28 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: How do I change the position on screen where to print?
Message-Id: <Pine.LNX.4.21.0010031351370.7067-100000@hawk.ce.mediaone.net>

On Tue, 3 Oct 2000, Peter Levi quoth:

PL> Help guys!I want to show on the screen the process of downloading a file - so I have to print for example "12%, 12520 bytes 
PL> read".And I want this to appear on one and the same place on the screen. (to replace the previous "10%, 10380 bytes read" for 
PL> example).How do I do this!Because currently  I print the new data on a new line - very embarassing and ugly!How can I change the 
PL> position of the marker where I want to print?Peter

Here is one way:

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

local $| = 1;

foreach my $c (90 .. 100) {
    print "$c% $c";
    sleep 1;
    my $len = length "$c% $c";
    print "\b" x $len;
}

__END__

I really didn't need a local in there, but just in case you are doing this
in an inner block, you probably will want to localize the scope of '$| = 1'.

anm
-- 
perl -wMstrict -MText::ParseWords -e "
system echo => grep defined() ? /./ : q++ => quotewords '\s+', 0, <<JAPH;
"""""""""""""""""""""""""""""""" Just    """"""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" another """"""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" Perl    """"""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" Hacker  """"""""""""""""""""""""""""""""
JAPH
"



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

Date: 03 Oct 2000 15:18:25 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: How to get length of scalar?
Message-Id: <m3n1gloezy.fsf@dhcp11-177.support.tivoli.com>

David Steuber <nospam@david-steuber.com> writes:

>  perl -e '$ref = \{name => value}; print $ref;'
> 
> yielded SCALAR(0x80f1948)
> 
> It looks like I screwed up doing a reference to an anonymous hash
> though.  Clearly I haven't found my head yet.

Assuming you haven't figured this out yet, you are taking a reference
of a reference to a hash.

%hash = (name => "value");
$hash_ref = {name => "value};

HTH...

-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 3 Oct 2000 14:55:11 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: how to split text by number of words?
Message-Id: <Pine.LNX.4.21.0010031447130.7067-100000@hawk.ce.mediaone.net>

On Tue, 3 Oct 2000, Firestar quoth:

F> Hi, i need to break a long chunk of text into a few paragraphs, each
F> paragraph not more than 300 characters, for example. can i use regexp
F> for this? TIA.

Jeff already posted one way to do this, but I have to ask, what is the
point?  The traditional sense of a paragraph is to use whitescape
(or some other separator) to seperate and organize ideas.  You may
end up with some wierd looking output if you merely split your text
on some approximation of an arbitrary number of characters.

Then again, it may not matter, or you may not be using the term paragraph
in the traditional usage of the word either.  Just a thought....

anm
-- 
perl -wMstrict -MText::ParseWords -e "
system echo => grep defined() ? /./ : q++ => quotewords '\s+', 0, <<JAPH;
"""""""""""""""""""""""""""""""" Just    """"""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" another """"""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" Perl    """"""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" Hacker  """"""""""""""""""""""""""""""""
JAPH
"




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

Date: Tue, 3 Oct 2000 14:22:25 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Limiting Form Field Input?
Message-Id: <Pine.GSO.4.21.0010031421430.14163-100000@crusoe.crusoe.net>

[posted & mailed]

On Oct 3, xlr6drone@my-deja.com said:

>I have a resume form and I want to prevent the user from inputting more
>than 250 characters in any of the fields.  For example I need to prevent
>people from pasting in text that will exceed 250 characters.

Um, <input type="text" maxlength=250 ...>

>Would it be possible to create a regular expression to handle this?

This doesn't need to be done on the Perl side of things.  If you wanted
to, though, why not use the length() function?

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





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

Date: 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 4508
**************************************


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