[17540] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4960 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 24 09:05:37 2000

Date: Fri, 24 Nov 2000 06:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <975074712-v9-i4960@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 24 Nov 2000     Volume: 9 Number: 4960

Today's topics:
        "meow" = New troll on the block? (was: subroutine stuff nobull@mail.com
    Re: Accessing Microsoft SQL nobull@mail.com
    Re: Accessing Microsoft SQL <geoff-at-farmline-dot-com@127.0.0.1>
        CGI & user 'nobody' problems <pmalone@tssg.wit.ie>
        Check for integer <shallow@mail.com>
    Re: Check for integer <MiGuenther@lucent.com>
    Re: Counter HELP <atong@operamail.com>
    Re: Counter HELP nobull@mail.com
        Counting bits. <mcousins@bfsec.bt.co.uk>
    Re: Counting bits. <MiGuenther@lucent.com>
    Re: Counting bits. <vestlandet@usa.net>
    Re: how do I merge blocks of text from different lines? (Roger Denholm)
    Re: how do I merge blocks of text from different lines? (Anno Siegel)
        How many free space on my Hd ? <NonDisponible@Not.Available.com>
        How to find what is between n'th and the next tab? <kumpu@mit.tut.fi>
    Re: How to find what is between n'th and the next tab? <MiGuenther@lucent.com>
    Re: IO::Socket: bind or listen errors <unformat@my-deja.com>
    Re: IO::Socket: bind or listen errors <unformat@my-deja.com>
    Re: IO::Socket: bind or listen errors <unformat@my-deja.com>
    Re: Need help with file splitting <johan.sunnerstig@netgiro.com>
    Re: Passing java parameters from Perl <henrik.aberg@edt.ericsson.se>
        Perl "save file" formatting text ... please assist <ducott@intergate.ca>
    Re: Perl "save file" formatting text ... please assist (Bernard El-Hagin)
        Perl and JPG <MiGuenther@lucent.com>
    Re: Perl and JPG (Honza Pazdziora)
        Perl and Mysql <vivekvp@spliced.com>
        perl parser embedding obscuremu@riftsmux.dhs.org
    Re: perl parser embedding (Bernard El-Hagin)
    Re: Perl XS <matt@sergeant.org>
    Re: perl2exe, does anybody know this software? <carvdawg@patriot.net>
        Regex question re: \x$1 theredviper@my-deja.com
    Re: Remote File Access James@Antikythera_Machines.com.au
    Re: splitting a string into an array and preserving the <bernie@fantasyfarm.com>
    Re: subroutine stuff <atong@operamail.com>
    Re: subroutine stuff <b_nospam_ill.kemp@wire2.com>
    Re: Subroutines in Perl??? <bart.lateur@skynet.be>
    Re: Subroutines in Perl??? nobull@mail.com
    Re: test post - dont read (Anno Siegel)
        Test to see if a file exists? <rev260@home.com>
    Re: Test to see if a file exists? (Bernard El-Hagin)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 24 Nov 2000 08:41:00 +0000
From: nobull@mail.com
Subject: "meow" = New troll on the block? (was: subroutine stuff)
Message-Id: <u9y9y9ra6s.fsf_-_@wcl-l.bham.ac.uk>

"meow" <atong@operamail.com> writes upside down (I've fixed that):

> >When I'm printing the values of the Hash after Foo1 subroutine I'm getting
> >output as all zero's.

> >foreach $val (sort keys %Message)
> >{ print "\n $val , $Message{$val}"; }

> of course the print value will be zero since you use return 0 for your
> subs...

Bogus.

The OP clearly states in that he is printing the values of the hash
not the return value of the sub.

> if you want to return a hash, replace the 0 with your hash
> variable...

Bogus.  Returning a hash by flattening it is as a general rule not the
best way.

> meow.

Am I right in beliving that "meow" in Usenet is used to denote a
self-proclaimed troll article that is being posted to disrupt
discussion of a matter the troll thinks should not be discussed?

As a general rule if someone posts upside-down in this group you
should expect their advice to be bogus.

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


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

Date: 24 Nov 2000 08:32:44 +0000
From: nobull@mail.com
Subject: Re: Accessing Microsoft SQL
Message-Id: <u93dghspxn.fsf@wcl-l.bham.ac.uk>

felrodian@my-deja.com writes:

> What perl mod will work with Microsoft SQL? Due to its popularity, I
> know there must be tons. Does DBI work with it? We don't have the server
> set up yet to test, they(employers) want me to gather everything I need
> first ie perl modules.

If you are running Perl on Win32 then you can use DBD::ODBC to talk to
any database with a ODBC interface.

I don't know if there's a DBD to talk directly to MS-SQL.

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


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

Date: Fri, 24 Nov 2000 09:53:32 -0000
From: "Geoff Winkless" <geoff-at-farmline-dot-com@127.0.0.1>
Subject: Re: Accessing Microsoft SQL
Message-Id: <8vldqg$esd$1@soap.pipex.net>

<nobull@mail.com> wrote in message news:u93dghspxn.fsf@wcl-l.bham.ac.uk...
: felrodian@my-deja.com writes:
:
: > What perl mod will work with Microsoft SQL? Due to its popularity, I
: > know there must be tons. Does DBI work with it? We don't have the server
: > set up yet to test, they(employers) want me to gather everything I need
: > first ie perl modules.
:
: If you are running Perl on Win32 then you can use DBD::ODBC to talk to
: any database with a ODBC interface.
:
: I don't know if there's a DBD to talk directly to MS-SQL.

If you're -not- running Win32 perl, check out http://www.freetds.org/

Geoff




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

Date: Fri, 24 Nov 2000 11:49:11 +0000
From: Paul Malone <pmalone@tssg.wit.ie>
Subject: CGI & user 'nobody' problems
Message-Id: <3A1E55B7.9EBDA5F4@tssg.wit.ie>

I have not posted to this group before and am a relative newcomer to
many security issues. I am hoping that some of you regular subscribers
can give me a answer to my problem, which is outlined below...

I am trying to authenticate users on a web site. I want to allow only
genuine unix users of the system to execute certain database
administrative tasks through CGI. I have the cgi running under ssl. I
need the username and password to authenticate the user via PAM. I have
written a small library which does the PAM authentification. I have
written a small cli script which allows users (including user 'nobody')
to authenticate 'real' users of the system. However  when I try to do
this from the cgi (which is running as user 'nobody') I get the
following error in the /var/log/messages

Nov 23 10:43:43 hostname pwdb_chkpwd[7910]: password not found

I never get this message when I su to 'nobody' and run my test script
from bash which succesfully authenticates the user. What are the
differences
between the user 'nobody' running through the httpd and running through
the
Bourne shell. Do I need to set an environment variable or something like
that?

I am considering suEXEC and/or CGIwrap to get around this problem, but I

have a feeling that this may not be necessary.

system...
Red Hat Linux 6.2
Kernel 2.2.14
Apache 1.3.12
Authen::PAM perl module

Can anyone help ?
Thanks in advance...
PaulM





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

Date: Fri, 24 Nov 2000 12:30:03 -0000
From: Shallowen <shallow@mail.com>
Subject: Check for integer
Message-Id: <t1snqbraibd523@corp.supernews.com>

If I have a number, say 18.88, stored as an element of an array, what is
the most elegant way to check that that number is:
exactly divisible by 0.64 after 0.32 has been subtracted from the original
number. I tried using a modular divide, but I reached (and went past) the
limit of my understanding of maths at that point.

So something like this (this is pseudo-code, I know it means not much to
PERL as it is):

if (((($sample_array[$element])-0.32)/0.64)==an integer) {
  print "It's divisible!\n";
} else {
  print "D'oh! It's not exactly divisible!\n";
}


or something like that.

Any help much appreciated! If there's a function which tests for this,
sorry for wasting your time, but I looked, and couldn't find it. (Although
doubtless that means very little =)

--
Posted via CNET Help.com
http://www.help.com/


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

Date: Fri, 24 Nov 2000 13:57:42 +0100
From: "Michael Guenther" <MiGuenther@lucent.com>
Subject: Re: Check for integer
Message-Id: <8vloiv$1r7@nntpa.cb.lucent.com>

my $str = "3";


if ( ($str/2)=~/[\.,]/) {
 print "not Ok\n"
}
else{
 print "OK\n";
}
print $str."\n";


looking for divided by 2

treat the result as an string and look fo "." or "," depending on your local
settings

Michael





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

Date: Fri, 24 Nov 2000 16:45:01 +0800
From: "meow" <atong@operamail.com>
Subject: Re: Counter HELP
Message-Id: <8vl9qi$kjk@news.or.intel.com>

why not you use RCS control... this will make sure only once person can
update the same at a particular time...

Plug-in tools wrote in message <8vl54r$daf$1@mango.singnet.com.sg>...
> open(countx,"<counter.txt") || print "ERROR NO SAVE";
> $v_count=<countx>;
> close(countx);
> $v_count++;
>
> &lock(countx);
> open(countx,">counter.txt") || print "ERROR NO SAVE";
> print countx $v_count;
> close(countx);
> &unlock(countx);
>
>###################
>sub lock {
>my($name)=@_;
>        flock($name,LOCK_EX);
>         #and, in case someone appended
>         #while we were waiting...
>
>        seek($name, 0, 2);
>
>  }
>
>sub unlock{
>my($name)=@_;
>        flock($name,LOCK_UN);
>    }
>
>
>##############
>that is a problem when 2 user access at the same time,
>my counter.txt will be reset to a different number.
>
>anyone can help how to avoid the problem?
>
>




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

Date: 24 Nov 2000 08:51:31 +0000
From: nobull@mail.com
Subject: Re: Counter HELP
Message-Id: <u9zoiprams.fsf@wcl-l.bham.ac.uk>

"meow" <atong@operamail.com> writes upside down:

[ in answer to the FAQ: "I still don't get locking.  I just want to
increment the number in the file..." ]

> why not you use RCS control... this will make sure only once person can
> update the same at a particular time...

Bogus.

RCS for simple file locking is gross overkill.  Also since RCS doesn't
block you need to implement a polling retry algorithm with random
back-off. This gets real messy.

As a general rule if someone posts upside-down in this group you
should expect their advice to be bogus.

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


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

Date: Fri, 24 Nov 2000 14:00:27 -0000
From: "Michael Cousins" <mcousins@bfsec.bt.co.uk>
Subject: Counting bits.
Message-Id: <8vlodd$g15$1@pheidippides.axion.bt.co.uk>

Hi all.
Is there an easy way in Perl to count the number of bits set in an integer?

eg;
4     = 00000100 has 1 bit set
132 = 10000100 has 2 bits set
etc..

Thanks.
Michael.




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

Date: Fri, 24 Nov 2000 14:06:31 +0100
From: "Michael Guenther" <MiGuenther@lucent.com>
Subject: Re: Counting bits.
Message-Id: <8vlp38$1th@nntpa.cb.lucent.com>

Hi Michael this is Michael try

my $str = "100110101";
my $count = 0;

while ($str=~/1/g){
   $count ++;
}
print $count;


Michael




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

Date: Fri, 24 Nov 2000 14:39:45 +0100
From: "Warlord" <vestlandet@usa.net>
Subject: Re: Counting bits.
Message-Id: <XauT5.2366$5H3.51818@news1.oke.nextra.no>

#!/usr/bin/perl -w

print numbits(127);

sub numbits {
  my $b = unpack("B32", pack("N", @_));
  $b =~ s/0//g;
  return length $b;
}

"Michael Cousins" <mcousins@bfsec.bt.co.uk> skrev i melding
news:8vlodd$g15$1@pheidippides.axion.bt.co.uk...
> Hi all.
> Is there an easy way in Perl to count the number of bits set in an
integer?
>
> eg;
> 4     = 00000100 has 1 bit set
> 132 = 10000100 has 2 bits set
> etc..
>
> Thanks.
> Michael.
>
>




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

Date: Fri, 24 Nov 2000 10:10:42 GMT
From: denr0g@canb.auug.org.au (Roger Denholm)
Subject: Re: how do I merge blocks of text from different lines?
Message-Id: <3a1e3e13.5032119@newshost.canb.auug.org.au>

On Wed, 22 Nov 2000 17:01:42 -0800, "Mauro" <-@-.com> wrote:

>________input is____
>[1]|some text
>[2]|I've an apple
>[3]|I eat the apple
>
>separatortag
>
>1. HALLO
>2. HI
>3. FOOBAR
>
>_______output must be_____
>HALLO|some text
>HI|I've an apple
>FOOBAR|I eat the apple
man cut
man paste
and for the smart, man sed
awk is useful for field swapping exercises.
Me, I would pass the lot thru ksh read statements and use its string
cutting and shell vars.  
Enuf hints for homework.
#include <std_disclaimer.h>


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

Date: 24 Nov 2000 11:31:00 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: how do I merge blocks of text from different lines?
Message-Id: <8vljhk$80u$1@lublin.zrz.tu-berlin.de>

Roger Denholm <denr0g@canb.auug.org.au> wrote in comp.lang.perl.misc:
>On Wed, 22 Nov 2000 17:01:42 -0800, "Mauro" <-@-.com> wrote:
>
>>________input is____
>>[1]|some text
>>[2]|I've an apple
>>[3]|I eat the apple
>>
>>separatortag
>>
>>1. HALLO
>>2. HI
>>3. FOOBAR
>>
>>_______output must be_____
>>HALLO|some text
>>HI|I've an apple
>>FOOBAR|I eat the apple

>man cut
>man paste
>and for the smart, man sed
>awk is useful for field swapping exercises.
>Me, I would pass the lot thru ksh read statements and use its string
>cutting and shell vars.  
>Enuf hints for homework.
>#include <std_disclaimer.h>

This would be good advice -- if Perl hadn't been invented.

Anno


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

Date: Sat, 25 Nov 2000 12:17:32 +0100
From: "Frederic" <NonDisponible@Not.Available.com>
Subject: How many free space on my Hd ?
Message-Id: <8vliq9$r2q@aix4.segi.ulg.ac.be>

I'd like to know how many free space available on my HD ??

which function ??

Thks
Fred.





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

Date: Fri, 24 Nov 2000 15:16:41 +0200
From: Pekka Kumpulainen <kumpu@mit.tut.fi>
Subject: How to find what is between n'th and the next tab?
Message-Id: <3A1E6A39.5228B414@mit.tut.fi>

Hi,
I am a newbie with perl but I have read the faq, searched from books and
web tutorials.
I want to get a column from tab-separated ascii-file.
Is it possible to find where in my line is the n'th tab and then get the
characters from that to next tab?

Now I do it with split:
        (@stuff) = split /\s/, $_;
        print OUT "$stuff[$colnum-1]\n";

It works but this it takes ages to run. If I get the first one or second
limiting the split:
      (@stuff[0..1],$rest) = split /\s/, $_, 3;
       print OUT "$stuff[1]\n";

This runs fast. So splitting entire string seems to be inefficient when
I only want one value.

Can I find positions of tabs n and n+1? Then I could use substr.
Or is there a feature in split (which I could not find yet) that allows
to pick n:th value directly, something like: ($crap,$mystuff,$morecrap)
= split /\s/, $_, n;

Thanks in advance

Meanwhile I 'll try running index n times increasing startpoint etc. to
see how it performes.
My current datafile has 1376216 rows and 82 columns and there is more
coming...



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

Date: Fri, 24 Nov 2000 14:28:24 +0100
From: "Michael Guenther" <MiGuenther@lucent.com>
Subject: Re: How to find what is between n'th and the next tab?
Message-Id: <8vlqc9$204@nntpa.cb.lucent.com>

Try
my $str = "1001\t101\t010001\t00000\tFR0ED\trolf";
my $count = 0;
my $result;

print "FRED".$str."#\n";

while ($str=~/\t(\w*)/g){
   $count ++;
   if ($count == 4){
      $result=$1;
   }
}
print $result."


Michael




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

Date: Fri, 24 Nov 2000 08:00:40 GMT
From: unformat <unformat@my-deja.com>
Subject: Re: IO::Socket: bind or listen errors
Message-Id: <8vl778$j9r$1@nnrp1.deja.com>

In article <x7hf4yc71i.fsf@home.sysarch.com>,
  Uri Guttman <uri@sysarch.com> wrote:

> are you checking the returned value? it will be true if a listen
socket
> is created, false (probably undef), otherwise. and what error method
are
> you referring to? IO::Socket doesn't mention that at all. what docs
are
> you using for this?

Yes, I check the returned value, and No, it doesn't return undef if it
can't bind (or listen) it (correctly) returns the socket created by the
new() method. I am using the pod and the error method if refered to in
(perldoc) IO::Handle.

--
unformat@my-deja.com
http://www.bmeworld.com/unformat/  -- tattooed all over!
"Enough love to knock a rhino sideways" - SNUFF


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


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

Date: Fri, 24 Nov 2000 08:11:42 GMT
From: unformat <unformat@my-deja.com>
Subject: Re: IO::Socket: bind or listen errors
Message-Id: <8vl7ru$jkf$1@nnrp1.deja.com>

In article <nSdT5.1431$xb1.91724@eagle.america.net>,
  garry@zvolve.com wrote:
> On Thu, 23 Nov 2000 17:42:01 GMT, unformat <unformat@my-deja.com>
wrote:
> >When using IO::Socket and creating a socket object with ->new, I can
> >give args to make it listen on a port. I cannot, however, establish
an
> >error condition following failure to bind to port using the ->error
> >method. How can I find out if the bind or listen failed within ->new
() ?

> Why not check $!?

I did and it doesn't get set (or it gets set and gets clobbered)...

#! perl -w
use strict; use IO::Socket; use IO::Select;
select((select(STDOUT),$|=1)[0]); #<-- make STDOUT a hot handle.

my $l1 = IO::Socket::INET->new(
   Proto     => 'tcp',
   LocalPort => 2070,
   Listen    => SOMAXCONN,
   Reuse     => 1);

print STDOUT "After \$l1, \$l1->error() = ", $l1->error(), " and \$! =
$!.\n";

# attempt to listen on same port...

my $l2 = IO::Socket::INET->new(
   Proto     => 'tcp',
   LocalPort => 2070,
   Listen    => SOMAXCONN,
   Reuse     => 1);

print STDOUT "After \$l2, \$l2->error() = ", $l2->error(), " and \$! =
$!.\n";

__END__

 ...which gives...

After $l1, $l1->error() = '0' and $! = ''.
After $l2, $l2->error() = '0' and $! = ''.

 ...Now, $l1 and $l2 cannot be undef here or there would be a runtime
error. I tried to split up the new and bind and listen separately but
had trouble with the syntax - but if that is what's necessary then I'll
persevere. Perhaps there is an other way of checking whether the
IO::Socket object is actually listening on the port - erm ->localport???

(surely this isn't something to do with the Reuse param reusing the
port because perl sees that I do nothing with the first filehandle -
nah!)

--
unformat@my-deja.com
http://www.bmeworld.com/unformat/  -- tattooed all over!
"Enough love to knock a rhino sideways" - SNUFF


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


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

Date: Fri, 24 Nov 2000 13:08:19 GMT
From: unformat <unformat@my-deja.com>
Subject: Re: IO::Socket: bind or listen errors
Message-Id: <8vlp82$usl$1@nnrp1.deja.com>

After some discussion with Bill Leubkert on Perl-Win32-Users mailing
list
and running sample scripts on both ActiveState 522 and a 5.005 build on
Linux (kernel 2.2.13-7) we find that IO::Socket is allowing multiple
sockets
to bind to a single local port - the question is "HOW?" - is this a
side-affect of anonymous filehandle globs?

testing in progress...
--
unformat@my-deja.com
http://www.bmeworld.com/unformat/  -- tattooed all over!
"Enough love to knock a rhino sideways" - SNUFF


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


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

Date: Fri, 24 Nov 2000 09:06:21 GMT
From: Sunner <johan.sunnerstig@netgiro.com>
Subject: Re: Need help with file splitting
Message-Id: <8vlb2d$mk6$1@nnrp1.deja.com>

Thanks alot :)

Regards
//Johan


In article <slrn91nsda.laf.rgarciasuarez@rafael.kazibao.net>,
  rgarciasuarez@free.fr (Rafael Garcia-Suarez) wrote:
> Sunner wrote in comp.lang.perl.misc:
> > Hi.
> > I have a script that's supposed to write a report out of a logfile.
> > At first the logfile is crammed with all sorts of stuff, but now the
> > script reduces it to the two parts I need, an ID number, and a
status
> > code that tells how an operation went.
> > A processed file might look like this:
> > 10002000 0
> > 10002000 0
> > 10001000 0
> > 10002000 3
> > 10002000 2
> > 10001000 5
> > With the 8 digit number being the ID and the 1 digit number being
the
> > code.
> > Now as long as there arent too many operations performed, counting
them
> > by hand is feasible, but with 1000 ops its a bit harder.
> >
> > So what I wanna do is make a short report that would look something
> > like:
> > 10002000 had 2 code 0's
> > 10002000 had 1 code 3's
> > 10002000 had 1 code 2's
> > 10001000 had 1 code 0's
> > 10001000 had 1 code 5's
> > Or something similar.
> > It doesnt need to contain anything else than the ID, status code,
and
> > number of times really.
>
> Use a hash. Attempt at an implementation :
>
>   my %hash = ();
>   while (<>) { # This reads your modified logfile
>     chomp;
>     my ($id,$code) = split;
>     ++$hash{"$id-$code"};
>   }
>   for (keys %hash) {
>     my ($id,$code) = split '-';
>     print "$id had $hash{$_} code $code's\n";
>   }
>
> --
> # Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
>


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


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

Date: Fri, 24 Nov 2000 09:31:35 +0100
From: Henrik =?iso-8859-1?Q?=C5berg?= <henrik.aberg@edt.ericsson.se>
To: Terrence Brannon <brannon@lnc.usc.edu>
Subject: Re: Passing java parameters from Perl
Message-Id: <3A1E2767.139AC912@edt.ericsson.se>

Hi Terrence.

Where can i find the JPL list? Is it a newsgroup or a mailinglist? 

/Henrik. 


Terrence Brannon wrote:
> 
> "Gary L. Berger" <gary.berger@odnss.com> writes:
> 
> > I am having a problem passing parameters to java from Perl in a CGI script.
> > The quotes are giving me a problem.  Any suggestions?
> 
> Why dont you join the JPL (java-perl lingo) list? They can help you.
> 
> >
> >
> >
> >
> > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> > http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> > -----==  Over 80,000 Newsgroups - 16 Different Servers! =-----
> 
> --
> Terrence Brannon


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

Date: Fri, 24 Nov 2000 05:23:31 -0800
From: "Robert Valcourt" <ducott@intergate.ca>
Subject: Perl "save file" formatting text ... please assist
Message-Id: <3a1e6bbf$1@newsserver1.intergate.ca>

Hello,

I have a big problem, i'm seeking assitance so the boss wont kill me. One of
our client sites uses perl to take contents of a form and save them to a
text file. This all works fine. I then use an SSI command to call upon the
contents of that text file, and print them inside a table on the page. Here
is the problem. SSI won't read the line breaks as illustrated below :

If I type this in the form :

   The dog ran fast

   The cat ran slow

Perl saves that info to the text file exactly as I wrote it, line breaks and
all.
But when I use the SSI command to call the file, the contents get printed
like this :

The dog ran fastThe cat ran slow

As you can see, SSI ignored the line breaks, and I guess thats to be
expected. Here is where I need your help. I'm guessing I need to modify the
perl scripts to ad <br> to all recorded line breaks from the form ... so the
following would occur :

typed in the form :

 11111111

  22222222

But saved like this :

  11111111
  <br><br>
  22222222

This way SSI would read the contents and print it correctly. I am begging
your assistance! And thank you in advance!

--

Sincerely,
Robert




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

Date: Fri, 24 Nov 2000 13:39:45 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Perl "save file" formatting text ... please assist
Message-Id: <slrn91srmn.cag.bernard.el-hagin@gdndev25.lido-tech>

On Fri, 24 Nov 2000 05:23:31 -0800, Robert Valcourt <ducott@intergate.ca> wrote:
>Hello,

Hiyah.

[snip]

>As you can see, SSI ignored the line breaks, and I guess thats to be
>expected. Here is where I need your help. I'm guessing I need to modify the
>perl scripts to ad <br> to all recorded line breaks from the form ... so the
>following would occur :

perl -i.bak -pe 's/\n/<br>\n/' <input_file>

Cheers,
Bernard
--
perl -le '$#="Just Another Perl Hacker"; print \Bernard'


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

Date: Fri, 24 Nov 2000 13:12:52 +0100
From: "Michael Guenther" <MiGuenther@lucent.com>
Subject: Perl and JPG
Message-Id: <8vlluk$1n5@nntpa.cb.lucent.com>

Does any body out there ever used perl to manipulate JPG files?

What I need is an idea where to start and which module is usable for this.


I have a pic of several layers an I want to combine them with perl


Thanks

Michael






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

Date: Fri, 24 Nov 2000 12:49:01 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Perl and JPG
Message-Id: <G4J4xp.D8z@news.muni.cz>

On Fri, 24 Nov 2000 13:12:52 +0100, Michael Guenther <MiGuenther@lucent.com> wrote:
> Does any body out there ever used perl to manipulate JPG files?
> 
> What I need is an idea where to start and which module is usable for this.
> 
> I have a pic of several layers an I want to combine them with perl

Have a look at Gimp (program) and Gimp.pm (the Perl module).

Yours,

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
   .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------


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

Date: Fri, 24 Nov 2000 11:15:31 GMT
From: vivekvp <vivekvp@spliced.com>
Subject: Perl and Mysql
Message-Id: <8vlikj$r38$1@nnrp1.deja.com>



Can you use perl to create tables with Mysql.

Almost like an interface - so you can create custom tables then access
them?

Any examples of how to do this?  Or scripts that already do this?

Thanks,

V


--
He who fights and runs away, lives to run another day!


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


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

Date: Fri, 24 Nov 2000 09:12:00 GMT
From: obscuremu@riftsmux.dhs.org
Subject: perl parser embedding
Message-Id: <3a1e2a88.98173450@news.inreach.com>

This may or may not be appropriate to this group. But here is the deal.

I program/code on what is nown as a MUSH. It stands for
multi-user-shared-hallucination. What it is is an internet based multiuser
play/chat area, text only. Within the code has pretty extensive ways of
'programming' it to do what you want, unfortunatly many of these 'programs' are
far from being anything neat, especially for prototyping or upkeeping the code.

What I want to do is add a perl interpeter to the program that would handle perl
scripts in the same way a webserver would. I would like it to be able to pull
perl scripts for use on the outside in the directory scripts that could be
called by commands within the program. For an example of what code looks like in
MUSH3.0 from within the server.

What it does is When someone enters, for example:
+info fizban<enter>

it will check the attributes/varibles on Fizban and use them to return the
following. (best seen in fixed pitch font)

---------------------------- +INFO for Fizban<fiz> --------------------------- 
This is a test of the info system. If this were not a test, something usefull
would have been placed here.
================================== End +Info =================================

And the code for this is as follows:

&CMD_+INFO Global Command Object GCO=$+info *: @pemit %# =
switch(pmatch(%0),#-1,%[GAME%] No player by that name., #-2,%[GAME%] Matches
([match(%0*,iter(lwho(%0),name(##)))])\, please be more specific.,
u(gfo/fn_+info,%#,#$))

&FN_+INFO Global Function Object
GFO=iter(sort(lattr(me/fn_+info_*)),u(##,%0,%1))

&FN_+INFO_01 Global Function Object GFO=%r[center(%b+INFO for
[ansi(h,name(%0))]<[ansi(h,get(%0/alias))]>%b,78,-)]

&FN_+INFO_02 Global Function Object GFO=%r[u(%0/info)]

&FN_+INFO_10 Global Function Object GFO=%r[center(%bEnd +Info%b,78,=)]

What I would like to do is be able to call scripts within the parser via
functions utilised within the server that could reach out and use the
information from within the MUSH's database and return the result without
blocking the MUSH. Just like what a CGI does when you send a request to a web
server.

If anyone could lead me in the right direction, I would be grateful. 

Hard information-

MUSH3.0 is written in C
I know almost no C
I have the source code as well as the meens to compile a new binary.


Thank you.


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

Date: Fri, 24 Nov 2000 11:33:48 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: perl parser embedding
Message-Id: <slrn91skb1.cag.bernard.el-hagin@gdndev25.lido-tech>

On Fri, 24 Nov 2000 09:12:00 GMT, obscuremu@riftsmux.dhs.org
<obscuremu@riftsmux.dhs.org> wrote:
>This may or may not be appropriate to this group.

It may not.

comp.infosystems.www.authoring.cgi may or may not find it to be more
appropriate.

Cheers,
Bernard
--
perl -le '$#="Just Another Perl Hacker"; print \Bernard'


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

Date: Fri, 24 Nov 2000 13:19:07 +0000
From: Matt Sergeant <matt@sergeant.org>
Subject: Re: Perl XS
Message-Id: <3A1E6ACB.5060605@sergeant.org>

Soumen Das wrote:

> My questions are as follows :
> 1. Is it required to build the entire project again with the .c file
> generated ?
> 2. How should I tweak my build options ? (Command line build does not work
> as well)
> 3. Where can I get more information on Using XS with C++ ?

Get yourself a copy of the XS Cookbook. Its indispensible. Its on CPAN, 
in authors/id/D/DM/DMR

Matt.



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

Date: Fri, 24 Nov 2000 06:15:51 -0500
From: H C <carvdawg@patriot.net>
Subject: Re: perl2exe, does anybody know this software?
Message-Id: <3A1E4DE7.9E4CA10F@patriot.net>



> yes. Very useful. The only excuse that perl2exe had to exist was that
> you only had to ship one binary, and could avoid installing perl on all
> machines. Then they start splitting it up in multiple binaries.
>
> Now where is the use in that?

In the case where someone wants the functionality of the program, but
doesn't
want to install Perl, using Perl2Exe can be quite a benefit.

If, for instance, I write several scripts that all use the same module (ie,
Win32::Lanman),
I can ship the .dlls once, and then send the much smaller executables.  No
need to use
MSInstaller, download Perl, use PPM, etc.



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

Date: Fri, 24 Nov 2000 12:34:51 GMT
From: theredviper@my-deja.com
Subject: Regex question re: \x$1
Message-Id: <8vln9b$tj5$1@nnrp1.deja.com>

I have what is probably a simple question.  Why will the following
regex not work properly in perl?

s/%(..)/\x$1/g

It kinda seems like this would take %1A and convert the hex 1A to its
ascii equivilant. Changing the substitution value to \x027 takes the
literal hex value 27 and replaces the matches accordingly, but I want
to use the value in $1.  I searched dejanews for an example and looked
in the Mastering Regular Expressions book, but haven't had any luck
finding an answer.  Thanks for any help.

-theredviper


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


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

Date: 24 Nov 2000 08:17:11 GMT
From: James@Antikythera_Machines.com.au
Subject: Re: Remote File Access
Message-Id: <8vl867$5ll$1@news.netmar.com>


>I need for users to be able to upload a data file from the client machine
and
>have the CGI program able to process this data before inserting the data
into
>the database.
>
>Can someone point me in the right direction of some information on remote
>file access, or let me know if what i want to achieve is infesiable.


I found what i needed by searching for related questions.
If anyone is interested the relevant info is at

http://stein.cshl.org/WWW/software/CGI/cgi_docs.html#upload

(magnificent resource)

James


 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

Date: Fri, 24 Nov 2000 08:39:34 -0500
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: splitting a string into an array and preserving the "\n"
Message-Id: <eprs1toa0stgecgimors0c5hl0klg32tif@news.supernews.net>

rgarciasuarez@free.fr (Rafael Garcia-Suarez) wrote:

} Eric Smith wrote in comp.lang.perl.misc:
} > I want to split a multi-line scalar into an array.  I want each element of
} > the array to have a line terminated by a "\n".
} > Problem is that when I split on "\n", then this newline character is lost.
} > 
} > Of course I can loop through the array and stick it back on again but I
} > want to do it right when I create the array.
} 
} 
} my @array = split /(?<=\n)/, $multi_line_string;
} 
} see the perlre manpage for details.

I just looked and I can't find any docs on '(?<=' in perlre.  We're on
5.004_004 [I'm hoping to upgrade fairly soon, but I don't have a say in
that kind of thing].. is this some 5.6 cleverness or did I miss something
in the 5.4 perlre?

  /Bernie\
-- 
Bernie Cosell                     Fantasy Farm Fibers
bernie@fantasyfarm.com            Pearisburg, VA
    -->  Too many people, too few sheep  <--          


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

Date: Fri, 24 Nov 2000 16:31:35 +0800
From: "meow" <atong@operamail.com>
Subject: Re: subroutine stuff
Message-Id: <8vl91f$k5c@news.or.intel.com>

of course the print value will be zero since you use return 0 for your
subs... if you want to return a hash, replace the 0 with your hash
variable...

meow.

jaya wrote in message ...
>Hi PerlExperts,
>
>I want a solution for the following problem :
>
>I want my subroutine as shown
>Foo ($Val1, %Elements, $Time);
>
>Inside the Foo function :
>sub Foo
>{
>   ($myv, %mye, $myt) = @_;
>   # Here I want to modify the values of the "mye" hash
>   and I want that the same values to the reflected back to the calling
>function.
>   #But I don't want
>   %Elements = Foo ($Val1, %Elements, $Time)
>   # How do I do that
>
>}
>
>I tried in the following way:
>In the following program:
>
>#!/usr/bin/perl5 -wl
>use Tie::IxHash;
>tie( %Message, 'Tie::IxHash',
> 'Message_Type' => 0,
> 'Message_discriminator' => 0,
> 'Message_Value' => 0,
> 'Message_Data' => 0
> );
>$Status = Foo1(%Message);
>
>foreach $val (sort keys %Message)
>{ print "\n $val , $Message{$val}";}
>print "\nStatus = ", $Status;
>
>$Status = Foo2(%Message);
>foreach $val (sort keys %Message)
>{ print "\n $val , $Message{$val}"; }
>print "\nStatus = ", $Status;
>
>sub Foo1
>{ $i = 1;
> foreach $val (sort keys %$_)
> { $$_{$val} = $i;
> $i++;
> }
> return 0;
>}
>
>sub Foo2
>{ $i = 1;
> foreach $val (sort keys %Message)
> { $Message{$val} = $i;
> $i++;
> }
> return 0;
>}
>
>When I'm printing the values of the Hash after Foo1 subroutine I'm getting
>output as all zero's.
>And After the Foo2 subroutine I'm getting output as per my requirement.
>I know in Foo2 subroutine I used the same name of the passed paramter,
>that's why I'm getting the values.
>
>Will any one help me solving the problem
>
>Thanks in advance,
>Regards,
>Jaya
>
>
>
>--
>Posted via CNET Help.com
>http://www.help.com/




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

Date: Fri, 24 Nov 2000 10:38:10 -0000
From: "W K" <b_nospam_ill.kemp@wire2.com>
Subject: Re: subroutine stuff
Message-Id: <975062293.19211.0.nnrp-09.c3ad6974@news.demon.co.uk>

>Hi PerlExperts,

 ... I'll answer even though its not addressed to me then.
>I want my subroutine as shown
>Foo ($Val1, %Elements, $Time);
>
>Inside the Foo function :
>sub Foo
>{
>   ($myv, %mye, $myt) = @_;
>   # Here I want to modify the values of the "mye" hash
>   and I want that the same values to the reflected back to the calling
>function.
>   #But I don't want
>   %Elements = Foo ($Val1, %Elements, $Time)
>   # How do I do that
>
>}


Bart Lateur's reply to your last post was perhaps too comprehensive.
In brief: find about how references work , and pass by reference.

Foo ($Val1, \%Elements, $Time);
lets you pass a reference to the subroutine.

Inside the sugroutine.
($myv, $ref_to_hash, $myt) = @_;
$ref_to_hash->{easy}=58;

Yes, that is an arrow.

By the way, if you are using subroutines why not use scoped variables?




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

Date: Fri, 24 Nov 2000 08:46:36 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Subroutines in Perl???
Message-Id: <f2as1tgdptkpapn8ikrijq67bi9r8d3dcb@4ax.com>

<vidulats@yahoo.co.uk> wrote:

>Hi PerlExperts,
>
>My question is:
>I want to write one subroutine like
>Receive ($Val1, %Elements, $Time);
>
>Inside the Receive function :
>sub Receive
>{
>   ($myv, %mye, $myt) = @_; 

   my($myv, %mye, $myt) = @_; 

>   # Here I want to modify the values of the "mye" hash
>   and I want that the same values to the reflected back to the calling    
>function.
>   #But I don't want
>   %Elements = Receive ($Val1, %Elements, $Time)
>   # How do I do that
>}
>
>Will anyone guide me.

You'll have to pass a reference to to the hash the sub. Anything you do
in the referenced hash, will happen to the original hash. What is
annoying, is that in the sub, you (pretty much) must access the hash
through a reference. Like:

	%Elements = ( a => 'Alpha', b => 'Beta' );
	my($Val1, $Time) = (1, time);
	Receive ($Val1, \%Elements, $Time);
	use Data::Dumper;
	print Data::Dumper->Dump([ \%Elements ] , [ "*Elements" ]);

	#Inside the Receive function :
	sub Receive
	{
	    my($myv, $mye, $myt) = @_;
	    foreach (keys %$mye) {
	        $mye->{$_} = uc $mye->{$_};
	    }
	}
-->
	%Elements = (
	              'a' => 'ALPHA',
	              'b' => 'BETA'
	            );

You could use a typeglob in the sub, to create an alias for the iginal
hash, but nowadays this is considered bad form, for 2 reasons:

 A) The inner variable *mye (for %mye) is a global
 B) There isn't a check that what you pass is indeed a hash reference.
If you pass an array reference, it won't complain, but you will not
modify the original data structure. Instead, it will just have created a
temporary localized global variable.

Here's the code anyway:

	sub Receive
	{
	    (my $myv, local *mye, my $myt) = @_;
	    foreach (keys %mye) {
	        $mye{$_} = uc $mye{$_};
	    }
	}

-- 
	Bart.


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

Date: 24 Nov 2000 08:46:33 +0000
From: nobull@mail.com
Subject: Re: Subroutines in Perl???
Message-Id: <u91yw1spig.fsf@wcl-l.bham.ac.uk>

"meow" <atong@operamail.com> writes upside down:

> sub Receive {
>    my($myv, %mye, $myt) = @_;

Bogus.  %mye will be a _copy_ of the argument passed, not what the OP
wanted.  Also $myt will never be set, instead you'll get a warning
about initising %mye with an odd number of elements.

As a general rule if someone posts upside-down in this group you
should expect their advice to be bogus.

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


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

Date: 24 Nov 2000 11:24:38 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: test post - dont read
Message-Id: <8vlj5m$804$1@lublin.zrz.tu-berlin.de>

 <Joe@nowhere.com> wrote in comp.lang.perl.misc:
>test

There are newsgroups for testing.  They have "test" in their name.

Anno


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

Date: Fri, 24 Nov 2000 13:41:04 GMT
From: "Revelation" <rev260@home.com>
Subject: Test to see if a file exists?
Message-Id: <QduT5.137906$td5.20530432@news1.rdc2.pa.home.com>

If $date_1.jpg exists I want to print out a link to it...how can I check if
it does?

Revelation
rev260@home.com




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

Date: Fri, 24 Nov 2000 13:47:44 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Test to see if a file exists?
Message-Id: <slrn91ss65.cag.bernard.el-hagin@gdndev25.lido-tech>

On Fri, 24 Nov 2000 13:41:04 GMT, Revelation <rev260@home.com> wrote:
>If $date_1.jpg exists I want to print out a link to it...how can I check if
>it does?

perl -e 'print "Yep, I exist" if -e shift' /etc/passwd

Or a more legible version:

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

my $pedo_file = '/etc/passwd';

if (-e $pedo_file){
	print "Yep, I exist\n";
}
----------------------

The "-e" does the work here and you can read about it in:

perldoc perlfunc (look for the -X file tests)

Cheers,
Bernard
--
perl -le '$#="Just Another Perl Hacker"; print \Bernard'


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

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


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