[15773] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3186 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 27 18:05:24 2000

Date: Sat, 27 May 2000 15:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <959465110-v9-i3186@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 27 May 2000     Volume: 9 Number: 3186

Today's topics:
    Re: Advantages of Perl over Cold Fusion? (Steven Smolinski)
        Chop <debbieY2Kremovethis@mindspring.com>
    Re: Chop <godzilla@stomp.stomp.tokyo>
    Re: Couple of Newbie RegExp questions <jkipp5@home.com>
    Re: Couple of Newbie RegExp questions <jkipp5@home.com>
    Re: Couple of Newbie RegExp questions <UlleAckermann@t-online.de>
    Re: determining existence of object method <pepin@worldnet.att.net>
        Dynamic file names <wellhaven@worldnet.att.net>
        How do you write a loop invoked from a ketboard? <dkarr1@san.rr.com>
    Re: How Sambar 4.2 run CGI ? (Bart Lateur)
        mod_perl make test mr_lowell@my-deja.com
    Re: newbie: random access to large lists <jeff@vpservices.com>
    Re: oops Re: seeking method to encode email addresses i (Bart Lateur)
    Re: oops Re: seeking method to encode email addresses i <godzilla@stomp.stomp.tokyo>
    Re: oops Re: seeking method to encode email addresses i (Randal L. Schwartz)
    Re: Perl problems under Solaris (Mark McWiggins)
    Re: Perl sockets and binary data <UlleAckermann@t-online.de>
    Re: printing to browser and file with single FILEHANDLE (Eric Smith)
    Re: ref-to-glob error (*in) (Bart Lateur)
    Re: regexp question (Andrew Johnson)
    Re: regexp question <andkaha@my-deja.com>
        Replace a string with another <joeb@jagas.demon.co.uk>
    Re: Replace a string with another <jsdNOjsSPAM@gamespot.com.invalid>
    Re: Replace a string with another <godzilla@stomp.stomp.tokyo>
    Re: using CGI.pm to retrieve data, slice into an array  <csorensen@uptimeresources.net>
        using CGI.pm to retrieve data, slice into an array and  <csorensen@uptimeresources.net>
    Re: using CGI.pm to retrieve data, slice into an array  <jsdNOjsSPAM@gamespot.com.invalid>
    Re: using param() and CGI.pm to store a persistent valu <anmcguire@ce.mediaone.net>
    Re: using param() and CGI.pm to store a persistent valu <godzilla@stomp.stomp.tokyo>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 27 May 2000 18:05:59 GMT
From: sjs@yorku.ca (Steven Smolinski)
Subject: Re: Advantages of Perl over Cold Fusion?
Message-Id: <slrn8j03ft.6u2.sjs@john.sympatico.ca>

Steve Leibel <stevel@coastside.net> wrote:
>"Mark Aisenberg" <mark@sharewire.com> wrote:

>> 1)  Perl is open, and not controlled by a single company.
>> What happens is you use a proprietary product, and the
>> supplier raises its prices, changes its licensing terms,
>> discontinues support for it, or lards it with unneeded features
>> and fat?  What happens if you need to move to a different
>> development platform, one not supported by the supplier?
 
>Open source software can also become larded with unneeded features and
>fat.  I'd mention Perl 5.6 but I don't want to get flamed.  I've been
>using Perl since 4.31 or so and I can't help feeling that I'd rather have
>a cleaner parser than more language features.   

You're standing right on the point.  With a proprietary product,
you'd have little choice but to upgrade or have a shitty product.  If
you want perl circa 4.31, then you can have it.  You can fork it
at 4.31, fix all the security and optimization bugs, and boom! you've
got mini-perl.  (I wouldn't suggest this, but it's within your rights.)

With the proprietary product, you're SOL.  With an open-source product,
you have options to choose from, though they're not always economically
feasible.

Steve


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

Date: Sat, 27 May 2000 14:16:41 -0400
From: "BassGirl" <debbieY2Kremovethis@mindspring.com>
Subject: Chop
Message-Id: <8gp3fq$f2s$1@nntp9.atl.mindspring.net>

I've got a script for ad banners that is working almost 100%, BUT here's the
thing, I'm trying to use it from within database driven pages (the banners
are targeted to certain categories).  This is all fine and good, but when
the referring page is logged it is like this:
http://www.atlantanetpages.com/Results.asp?ListingRS_Action=Filter%28%22++CA
TEGORY+LIKE+%27%2AADVERTISING%2A%27%22%29&ListingRS_Position=PAR:

The problem with this is when my script tries to read & display this log
file it is geting screwed up on the special characters.  I want to be able
to chop off everything after the "?", or ignore everything after the "?"

Another problem is that not all of the logs are going to have all that stuff
after the "?" some will be logged like this:
http://www.atlantanetpages.com/Search.asp

Here is the snippet of script that write to the log file:

sub log
{
 open (LOG,">>$log_dir$idnum.txt") || &redirect;
 flock(LOG,2);

 print LOG "$ENV{'HTTP_REFERER'} $ENV{'REMOTE_ADDR'} $ENV{'REMOTE_HOST'}\n";

 flock(LOG,8);
 close(LOG);
}

I need to be able to chop the HTTP_REFFERER to log only the basic URL.

Any ideas?

Thanks so much,

Debbie
Please reply to debbieREMOVETHIS@web-tec.com




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

Date: Sat, 27 May 2000 13:35:19 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Chop
Message-Id: <39303187.4B416247@stomp.stomp.tokyo>

BassGirl wrote:
 
> I've got a script for ad banners that is working 
> almost 100%, BUT here's the thing,

(snipped)

> the referring page is logged it is like this:
 http://www.atlantanetpages.com/ (big messy query string)
 
> The problem with this is when my script tries to read & 
> display this log file it is geting screwed up on the 
> special characters. I want to be able to chop off 
> everything after the "?", or ignore everything 
> after the "?"


I have two methods for you, both quite basic.
These will 'remove' your query string mess,
sorta, actually ignore it really. If you 
really want a question mark ? on the end
of your referrer variable, tag it back on.

In my test script you will see $env_ref is
set to your referrer. I do this simply to
protect the original referrer variable so
I can use it twice.

First method is a basic method with lots
of pretty \/ in there. Little victory signs!

Second method uses a " m " modifier so I can
use exclamation marks  !  for my matching
operator to avoid this \/ kinda thing. No
real difference between the two except the
first needs some backslashing to escape /
in your matching operator. Second does not.

Hmm.. you might have to add a few oddball
characters for the match. Offhand, I cannot
think of any host names with weird characters
but I am sure there are a few, somewhere.
Letters, numbers and periods should work ok
for your enclosed variable character set.
Keep an eye on this for weird exceptions.

Personal choice on which to use. Look this
over, see what you think. Might help. 

Here is an expanded character example if
you need to catch more than the basic host
name as I think you are indicating:

/(http:\/\/[a-zA-Z0-9\.]+\/[a-zA-Z0-9\.]+\/)/

You can just keeping stretching it out if
needed. What I have here will catch the
basic host name referrer, if it exists.
Seems you might be interested in only
the basic host name.

For an average homepage type referrer,
toss a tilde ~ right in front of your
second enclosed character set, dump
the last \/ style slashing.

/(etc... etc...\/~[a-zA-Z0-9\.]+)/

Use of (.*) will shorten things a bit for you
if you do a good match operator. Play around,
set up a simple test and discover what all
you can do. Try this with Plain English first
so you can get a feel for how this works. Then
move into shorter methods.

A simple test html page and a simple test cgi
script will be of great benefit for playing.

An alternative method would be to substitute
out any string within your string starting 
with a ? outward -->. Others will post this 
code for you. With my code and substitution
codes others will post, you will have options.


First printed line is the input data from a regular
html page with a hyperlink.

Second printed line is the first basic method.

Third printed line is the m modifier method.

Fourth line, looks like it didn't print.


Godzilla!


PRINTED RESULTS
_______________

Input Data: 

http://la.znet.com/~callgirl/test.html 207.167.96.82 lats2-82.znet.net


Basic Method: 

http://la.znet.com/ 207.167.96.82 lats2-82.znet.net


Modified Method: 

http://la.znet.com/ 207.167.96.82 lats2-82.znet.net



TEST SCRIPT
___________


#!/usr/local/bin/perl

print "Content-Type: text/plain\n\n";

print "Input Data: \n\n";

print "$ENV{HTTP_REFERER} $ENV{REMOTE_ADDR} $ENV{REMOTE_HOST}\n\n\n";

$env_ref = $ENV{HTTP_REFERER};

print "Basic Method: \n\n";


## using basic method:

if ($env_ref =~ /(http:\/\/[a-zA-Z0-9\.]+\/)/)
 { $env_ref = $1; }

print "$env_ref $ENV{REMOTE_ADDR} $ENV{REMOTE_HOST}\n\n\n";

print "Modified Method: \n\n";


## using " m " modifier method:

$env_ref = $ENV{HTTP_REFERER};

if ($env_ref =~ m!(http://[a-zA-Z0-9\.]+/)!)
 { $env_ref = $1; }

print "$env_ref $ENV{REMOTE_ADDR} $ENV{REMOTE_HOST}\n\n";


exit;


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

Date: Sat, 27 May 2000 21:04:43 GMT
From: Jim Kipp <jkipp5@home.com>
Subject: Re: Couple of Newbie RegExp questions
Message-Id: <393038BC.A235096@home.com>

Thanks I will read the faq

Ilja wrote:
> 
> In article <392FB8F6.5A5398E8@home.com>,
>   Jim Kipp <jkipp5@home.com> wrote:
> > Hello
> > I am trying to write something to find repeated words in an
> > input file, print the repeated word and the line # it is on.
> > I came up with the mess below but did not work.  The second
> > script I need is one that uses the translation operator to
> > remove repeated instances of the tab character and then
> > replaces the tab character with a space character.
> >
> 
> ...skipped...
> 
> If you simply need to replace repeated tabs with just one space:
> 
> $string =~ s/\t+/ /g;
> 
> For more complex tab expansion pls read the FAQ:
> "How do I expand tabs in a string?"
> 
> You'll find it in your local perldoc perlfaq4
> or http://www.cpan.org/doc/manual/html/pod/perlfaq4.html.
> 
> Hope this helps.
> Ilja.
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.


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

Date: Sat, 27 May 2000 21:08:11 GMT
From: Jim Kipp <jkipp5@home.com>
Subject: Re: Couple of Newbie RegExp questions
Message-Id: <3930398D.DE6B4C1B@home.com>

Thanks. I just started learning about regex. Having a tought
time with them. Do you know any good links explaining them .

Jim

Dave Cross wrote:
> 
> On Sat, 27 May 2000 11:59:33 GMT, Jim Kipp <jkipp5@home.com> wrote:
> 
> >Hello
> >I am trying to write something to find repeated words in an
> >input file, print the repeated word and the line # it is on.
> >I came up with the mess below but did not work.
> 
> Your match is being executed once - before any of the file has been
> read and therefore always returns false. Also your regex could use
> some adjustments. The 's*' need to be '\s*' and actually would be
> better replaced by \b (a word boundary). Also you don't allow for any
> spaces between the two words.
> 
> >$target = m/(s*\w+)\1/;
> >
> >open (IN, "<word.txt");
> >
> >while (<IN>) {
> >        if (/$target/) {
> >                print "found dups on line $." . "$1\n";
> >        }
> >}
> >close (IN);
> 
> Better written something like:
> 
> #!/usr/bin/perl -w
> use strict;
> 
> open(IN, 'word.txt') or die "Can't open word.txt: $!\n";
> 
> while (<IN>) {
>   print "dups found on line $.\n" if /\b(\w+)\s+\1\b/;
> }
> 
> But that still doesn't cope with the possibility that the last word on
> one line and the first word on the next are the same.
> 
> hth,
> 
> Dave...
> 
> --
> <http://www.dave.org.uk>  SMS: sms@dave.org.uk
> yapc::Europe - London, 22 - 24 Sep <http://www.yapc.org/Europe/>
> 
> "There ain't half been some clever bastards" - Ian Dury [RIP]


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

Date: Sat, 27 May 2000 22:19:35 +0200
From: Ulrich Ackermann <UlleAckermann@t-online.de>
Subject: Re: Couple of Newbie RegExp questions
Message-Id: <39302DD7.E1D3B6D8@t-online.de>

Jim Kipp wrote:
> 
> Thanks. I just started learning about regex. Having a tought
> time with them. Do you know any good links explaining them .

Get 'Regular Expressions' from Jeffrey Friedl (wonderful O'Reilly-book). 
Most examples written for Perl and the Code is on the web, I think.
Contains the duplicated word example too, as far as I remember.

Ulrich


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

Date: Sat, 27 May 2000 20:44:33 GMT
From: "Joseph Pepin" <pepin@worldnet.att.net>
Subject: Re: determining existence of object method
Message-Id: <RsWX4.7217$hL1.485424@bgtnsc04-news.ops.worldnet.att.net>

Try $object->can('sub').  See UNIVERSAL::can.

Julian L. Cardarelli <jc@juliancardarelli.com> wrote in message
news:HcHU4.2738$Rf.27214@news1.rdc1.on.wave.home.com...
> my $refval        =    ref(\&{$object->sub}) Actually, I can't remember
how
> to suppress the actual running of the code but ref will return 'CODE'
which
> will tell you if the method exists.  If you can find out how to suppress
the
> running of the code, you're on your way.  Just let me know how you did it
to
> refresh my memory.
>
> = Julian
>
>
> Kenneth Lee <kenneth.lee@alfacomtech.com> wrote in message
> news:3922244D.B80A1EF8@alfacomtech.com...
> > i want to test whether an object can invoke an arbitrary method.
> > defined() (or exists() in 5.6.0) only works for class methods, but not
> > object ones.
> >
> > i tried eval(), which set $@ if the method doesn't exists, but it sets
$@
> > also if that method exists and raises exception when called.
> >
> > there's no way to identify the error except parsing the value in $@.
> > Any thought?
> >
> > kenneth
>
>




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

Date: Sat, 27 May 2000 21:41:29 GMT
From: "William Cardwell" <wellhaven@worldnet.att.net>
Subject: Dynamic file names
Message-Id: <diXX4.2066$Zm5.153258@bgtnsc06-news.ops.worldnet.att.net>

I would like to read a file, and for each line, write it to a file named in
the line.

The last thing I tried is below but it doesn't work correctly and may be
completely wrong approach. I have spent a while with FAQs and documentation
but perhaps not enough. All ideas are welcome.

Thank you in advance,

Will Cardwell

Test Program:

while(<>) {
  $fn=substr($_,3,5); # extract file name
  if ($fnhash{$fn}) {  # if file already open
    select $fnhash{$fn};
  } else

    $fh=$fnhash{$fn}="F$fn"; # create handle- filename prepended with "F"
    open $fh, ">$fn" or die "Can't open $fn for output: $!";    # open it
  }
  print $_;  # write this line as next line in the proper file
}


Test Data (File names: "bbbbb", "xxxxx", "ffffff", "lkdfg" etc...)

aaabbbbbxxxxxxxxxxxxxxxxxxx11xxxxxxxxxxxxx
aaabbbbbxxxxxxxxxxxxxxxxxxx22xxxxxxxxxxxxx
aaaxxxxxxxxxxxxxxxxxxxxxxxx33xxxxxxxxxxxx
aaafffffbbbbbxxxxxxxxxxxxxx44xxxxxxxxxxxxxxxxxx
aaabbbbbbbbbbxxxxxxxxxxxxxx55xxxxxxxxxxxxxxxxxx
aaalkdfgbbbbbxxxxxxxxxxxxxxx66xxxxxxxxxxxxxxxxx
aaadghjebbbbbxxxxxxxxxxxxxxxxxx77xxxxxxxxxxxxxx
aaabbbbbxxxxxxxxxxxxxxxxxxxxx88xxxxxxxxxxx
aaafffffbbbbbxxxxxxxxxxxx99xxxxxxxxxxxxxxxxxxxx
aaabbbbbxxxxxxxxxxxxxxxxxxxxx1010xxxxxxxxxxx




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

Date: Sat, 27 May 2000 21:40:05 GMT
From: "debra karr" <dkarr1@san.rr.com>
Subject: How do you write a loop invoked from a ketboard?
Message-Id: <VgXX4.19357$Y4.92088@typhoon2.san.rr.com>

I have the code so far to read in a directory path from the keyboard, read
the contents, then print it to the screen. It counts the number of files in
the directory, then prints that. But how do you code in how many times you
want to run this code, inputed into the original command line?
CODE:

###################################################
#  Database Engine to Process SQL scripts
#
#
###################################################
my $dir;($dir = $ARGV[0]);
my $lcount= 0;
#($lcount = $ARGV[1]);


opendir(DIR,"$dir") or die "could not open $dir: $!";
print "\n $dir contains:  \n";


while ($_ = readdir(DIR)) {
$lcount = $lcount + 1;
   {
print "\t$_  \n";
   }
}

closedir DIR;

print "\n Number of Loops: $lcount \n";

exit;

INPUT/OUTPUT
C:\Perl>perl dbeng.pl c:\perl\scrip

 c:\perl\script contains:
        .
        ..
        empdata1.pl
        counter2.pl
        counter1.pl
        hexchart.pl
        popcheck.pl
        rep.pl
        select.pl
        test.pl
        test.txt
        htLoad.txt

 Number of Loops: 12

C:\Perl>





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

Date: Sat, 27 May 2000 20:40:15 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: How Sambar 4.2 run CGI ?
Message-Id: <3932ef54.1795278@news.skynet.be>

Adolf wrote:

>I have checked the URL/main.cgi
>but Sambar return it as a document
>and Sambar seem not to support permission setting

It must. Check the documentation on how to support scripting. Otherwise,
it would be pretty useless.

Even Microsoft's brainchild, IIS, has a notion of "executabitlity",
although in that case I think it relies on the permissions for a whole
directory, not of indivdual files.

-- 
	Bart.


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

Date: Sat, 27 May 2000 19:36:18 GMT
From: mr_lowell@my-deja.com
Subject: mod_perl make test
Message-Id: <8gp83h$cv9$1@nnrp1.deja.com>

While installing mod_perl
 AS recommended by some helpful news-reader, I installed libwww-perl and
the other
 recommended modules like URI, and html-parser and resumed the
installation of mod_perl. I
 followed the install-documentation to the letter.
 perl Makefile.PL ......
 make
 make test
 make install

 It compiles well, but make test fails with the following error.

 ../apache-1.3.12/src/httpd -f `pwd`/t/conf/httpd.conf -X -d `pwd`/t &
httpd listening on port 8529
 Syntax error on line 213 of /sources/mod_perl-1.24/t/conf/httpd.conf:
Invalid command
 'PerlHandler', perhaps mis-spelled or defined by a module not included
in the server configuration
 will write error_log to: t/logs/error_log#PerlOpmask default
 letting apache warm up...\c
 done
 /usr/bin/perl t/TEST 0
 still waiting for server to warm up...............not ok
 server failed to start! (please examine t/logs/error_log) at t/TEST
line 95.
 *** Error code 9
 make: Fatal error: Command failed for target `run_tests'


 The head of this file t/conf/httpd.conf looks like this,

 =pod
 =head1 NAME
 #mod_perl test configuration file
 =head1 DESCRIPTION
 #umm, we use this to test mod_perl
 =over to apache
 -Tw
 PerlTaintCheck On
 PerlWarn On
 PerlFreshRestart On
 =back to pod
 =over 4
 =item Test that mod_perl skips this
 =back
 =cut


 I commented out some of these but it looks like this conf file is not
in order. "make test" also
 complained about the following lines in the conf file ..everything that
has to do with PerlHandler,
 PerlSendHeader, PerlSetupEnv and the following

 PerlPassEnv TERM EDITOR NOCHANCE USER PERL5LIB
 PerlSetEnv KeyForPerlSetEnv OK
 PerlSetVar KeyForPerlSetVar OK
 PerlRequire docs/startup.pl
 PerlRequire docs/stacked.pl
   PerlHandler          Apache::Registry
   PerlSendHeader      On
 Apache::ePerl

 HTML::Embperl


 Help please  ..what module do I need to include


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


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

Date: Sat, 27 May 2000 12:39:24 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: newbie: random access to large lists
Message-Id: <3930246C.C04CCAFB@vpservices.com>

Thomas Stewart wrote:
> 
> All-
> 
> I'm working on a script that needs to randomly grab a line from a large
> list (tens of thousands of lines).  I want the whole line, and the lines
> are not fixed length.  What is the best way of going about this?  

If you want to do this with simple file operations, there was an entire
thread on exactly this topic about two weeks ago.  There were a number
of answers posted.  Check the archives at www.deja-news.com searching
for "random".

> I want the lists to be manually editable, so DBM doesn't seem
> appropriate.  

If you have need for this as a database, you can use one of the DBI
drivers that can work with text files like DBD::CSV or DBD::RAM and
access the same files either manually or through DBI calls.

-- 
Jeff


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

Date: Sat, 27 May 2000 20:40:12 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: oops Re: seeking method to encode email addresses in web page forms
Message-Id: <3931ee11.1472374@news.skynet.be>

Godzilla! wrote:

>Mr. Dragon and myself have known each
>other for years. I taught him a lot of 
>tricks and hard lessons over time.

Eh? I thought Mr. WebDragion recently wrote that he's new in Perl,
having used it for no longer than a couple of weeks.

>As it
>is, I've been around the net and Perl
>programming two to three times as long
>as * almost * all of you. 

Can't be. I've been using Perl on a daily basis since 1995. Perl is
about 11 years old now. 3 times as long? Definitely not.

And I know for sure that a lot of the regulars have been using Perl for
longer than I have. Some were even around when Perl was still in it's
cradle.

-- 
	Bart.


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

Date: Sat, 27 May 2000 13:59:06 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: oops Re: seeking method to encode email addresses in web page forms
Message-Id: <3930371A.4D151388@stomp.stomp.tokyo>

Bart Lateur wrote:
> Godzilla! wrote:

> >As it is, I've been around the net and Perl
> >programming two to three times as long
> >as * almost * all of you.
 
> Can't be. I've been using Perl on a daily basis since 1995. Perl is
> about 11 years old now. 3 times as long? Definitely not.



I've been using our net since 1985 if you
can call it 'the net' back then. More like
a bunch of academic geeks sending plain
text love letters to each other.

Perl is eleven years old you say?

Hmmm... Perl first came out in 1989
then, correct?


Godzilla!


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

Date: 27 May 2000 14:14:03 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: oops Re: seeking method to encode email addresses in web page forms
Message-Id: <m1r9and7c4.fsf@halfdome.holdit.com>

>>>>> "Godzilla!" == Godzilla!  <godzilla@stomp.stomp.tokyo> writes:

Godzilla!> Perl is eleven years old you say?

Godzilla!> Hmmm... Perl first came out in 1989
Godzilla!> then, correct?

"perldoc perlhist" tells the story, if you have a reasonably modern
version of Perl installed, either for Windows *or* Unix.

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


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

Date: Sat, 27 May 2000 19:18:44 GMT
From: mark@IcanFixYourEmail.com (Mark McWiggins)
Subject: Re: Perl problems under Solaris
Message-Id: <39321f5d.1222499130@news.supernews.com>

It was indeed a problem with the Solaris libraries; patching the
system solved the problem.

Thanks much.

mark@IcanFixYourEmail.com
425-957-0848


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

Date: Sat, 27 May 2000 22:12:17 +0200
From: Ulrich Ackermann <UlleAckermann@t-online.de>
Subject: Re: Perl sockets and binary data
Message-Id: <39302C21.8B9E3475@t-online.de>

R1CH wrote:
> =

> Hi,
> I have a bunch of packet data (ie, just binary mess such as
> =11
>  =1A       ^^ 0=1A =05
>         =C8,    F =1C^
> that I need to send down a TCP stream to another computer. However, whe=
n
> I use
> =

> open (PACKET,"mypacket");
> $packettosend =3D <PACKET>;

@packettosend =3D <PACKET>;  looks better to me for reading the whole fil=
e
"mypacket".
Then just put the content of the array into your string-variable if
needed.
But maybe I do not understand you quite right, because I do not know,
what this has to do with the sockets you where mentioning in your header
=2E.. =

 =

> $packettosend is always just the first couple of bytes. This makes me

Because $packettosend is a string and just gets the first line (until \n
normally).


Anyway, HTH

Ulrich



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

Date: 27 May 2000 19:42:16 GMT
From: eric@fruitcom.com (Eric Smith)
Subject: Re: printing to browser and file with single FILEHANDLE
Message-Id: <slrn8j098f.ja5.eric@plum.fruitcom.com>

Ilja posted
 > In article <slrn8it5qn.rid.eric@plum.fruitcom.com>,
 >   eric@fruitcom.com wrote:
 > >
 > > I would like to send a copy of browser output to a file.
 > 
 >    ...skipped...
 > 
 > > How could I achieve this?
 > >
 > > (apologies for posting here but I tried the cgi group).
 > >
 > 
 > Sounds like a FAQ: "How do I print to more than one file at once? "
 > 
 > Colsult your local 'perldoc perlfaq5' or
 > http://www.cpan.org/doc/manual/html/pod/perlfaq5.html.

 Thank you.  Howver this is where I found the examples but could not get
 them to work in a cgi :(


-- 
Eric Smith
eric@fruitcom.com


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

Date: Sat, 27 May 2000 20:40:18 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: ref-to-glob error (*in)
Message-Id: <3934f649.3575947@news.skynet.be>

Seansan wrote:

>I dont understand this next line.
>I mean the star next to in (*in)
>I use it in a library file, but saw it somewhere and
>wondered why they use it.
>what does it mean ??
>
>my (*in) = shift if @_;   # CGI input

As Alex wrote: it can't work. Use "local" instead of "my".

And what is it good for? *foo is a typeglob; a "record" od all values
associated with the global variable name "foo", including %foo, @foo and
$foo, plus some more (filehandle, sub, format, to name a few. I don't
know if this list is complete).

So what does 

	*x = *y;

do? It allows you to access the variables contents of *y through *x,
i.e. modify $y through $x, %y through %x, @y through @x. In fact, you
have created "aliases" to the original variables.

	$x = "this is set through x\n";
	*y = *x;
	print $y;
	$y = "this is modified through y\n";
	print $x;

-- 
	Bart.


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

Date: Sat, 27 May 2000 19:37:50 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: regexp question
Message-Id: <iuVX4.343$55.7825@news1.rdc1.mb.home.com>

In article <39300FF9.341B0B9B@styx.math.uni-bonn.de>,
 Oliver Sick <sick@styx.math.uni-bonn.de> wrote:
> Hi
> 
> I've a problem finding the correct regular expression  for matching  a
> string of FIXED length (lets =L) which contains a specific letter
> EXACTLY ONE time !
> 
> Example:  If the length of the string is L=6 and the specific letter is
> the "s",
> then  the strings  "supper"  and  "nights"   should match but  the
> string "assert"  shouldn't.

It strikes me that you would be better off using length() and tr///
to test the string length and letter count respectively:

#!/usr/bin/perl -w
use strict;
my @strings = qw/assert supper nights sailed bailed based/;
for (@strings) {
    if(length == 6 && tr/s// == 1){
        print "$_\n";
    }
}
__END__

regards,
andrew

-- 
Andrew L. Johnson   http://members.home.net/andrew-johnson/epwp.html
    Some people, when confronted with a problem, think 'I know,
    I'll use regular expressions.'  Now they have two problems.
        -- Jamie Zawinski, on comp.lang.emacs


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

Date: Sat, 27 May 2000 19:33:17 GMT
From: Andreas Kahari <andkaha@my-deja.com>
Subject: Re: regexp question
Message-Id: <8gp7tt$cm2$1@nnrp1.deja.com>

In article <39300FF9.341B0B9B@styx.math.uni-bonn.de>,
  Oliver Sick <sick@styx.math.uni-bonn.de> wrote:
> Hi
>
> I've a problem finding the correct regular expression  for matching  a
> string of FIXED length (lets =L) which contains a specific letter
> EXACTLY ONE time !
>
> Example:  If the length of the string is L=6 and the specific letter
is
> the "s",
> then  the strings  "supper"  and  "nights"   should match but  the
> string "assert"  shouldn't.
>
> I'm grateful for any helpfull hint.
>
> Thanks in advance,
> Oliver
>
>

Match a string that contains exactly one 's':

/^[^s]*s[^s]*$/

I didn't quite understand that about the length of the string...


/A

--
# Andreas Kähäri, <URL:http://hello.to/andkaha/>.
# All junk e-mail is reported to the
# appropriate authorities, no exceptions.


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


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

Date: Sat, 27 May 2000 21:09:59 +0100
From: JoeB <joeb@jagas.demon.co.uk>
Subject: Replace a string with another
Message-Id: <39302B97.9737F37@jagas.demon.co.uk>

Hello All,

I need a function that will take a word and replace it with another as
in:
"Mango and Fruit" I want this string to be "Mango +Fruit"
I have tried:
    my $vale = "Mango and Fruit";
     $vale =~ tr/ and /+;
It doesn't work.

On the other hand, if the value of $vale is:
my $vale = "Mango  and     Fruit";

I still want it to be clever and convert it to:
"Mango +Fruit"

Any help will be appreicated.

Many Thanks

Joe B.



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

Date: Sat, 27 May 2000 13:45:27 -0700
From: jsd <jsdNOjsSPAM@gamespot.com.invalid>
Subject: Re: Replace a string with another
Message-Id: <1282107c.2a5fb5bd@usw-ex0105-037.remarq.com>

tr is for substituting any character from the left side with the
corresponding character from the right side, eg: $x =~
tr/abc/xyz/ will change all a's to x's, b's to y's, and so on.

you want the s operator, which uses regular expressions (see
perlre for details).

basically, you want something like:  $string =~ s/and/+/g;

-jsd-


* 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: Sat, 27 May 2000 14:18:42 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Replace a string with another
Message-Id: <39303BB1.829114B@stomp.stomp.tokyo>

JoeB wrote:
 
> I need a function that will take a word and replace 
> it with another as in:

> "Mango and Fruit" 

> I want this string to be "Mango +Fruit"

> I have tried:
> my $vale = "Mango and Fruit";
> $vale =~ tr/ and /+;

> On the other hand, if the value of $vale is:
> my $vale = "Mango  and     Fruit";



* strikes up a familiar Jimi Hendrix tune *

Hey Joe, where ya going with that gun in your hand...

Transliteration might not be your best choice
for what you want to do Joe. Good start though!
You have the right idea but need a little help.

Down below, you will see printed results and
a test script. Fairly self-explanatory. Look
over the results, look over the code, then
compare this to your code. Pretty sure you
will understand why you might want to use
a different method. Keep at it! You will
get there in time just like we all did.

Oh, airhead me, I tossed in a way to make
a query string if this might be of help
to you, maybe later you might want to 
do something different.

My \n in there are simply to make a 
pretty print. This is as critically
important as pretty acrylic nails.

Godzilla!



PRINTED RESULTS
_______________

Substitution Method Single Space:

Before: Mango and Fruit 

After: Mango +Fruit 


Substitution Method Multiple Space:

Before: Mango and        Fruit 

After: Mango +Fruit 


Transliteration Method: 

Before: Mango and Fruit 

After: M++go +++ Fruit 


Create A Query String:

Before: Mango and Fruit 

After: Mango+Fruit 




TEST SCRIPT
___________


#!/usr/local/bin/perl

print "Content-Type: text/plain\n\n";


## Substitution Method Single Space

print "Substitution Method Single Space:\n\n";

$value = "Mango and Fruit";

print "Before: $value \n\n";

$value =~ s/ and / +/gi;

print "After: $value \n\n\n";


## Substitution Method Multiple Space

print "Substitution Method Multiple Space:\n\n";

$value = "Mango and        Fruit";

print "Before: $value \n\n";

$value =~ s/ and\s+/ +/gi;

print "After: $value \n\n\n";


## Transliteration Method

print "Transliteration Method: \n\n";

$value = "Mango and Fruit";

print "Before: $value \n\n";

$value =~ tr/ and / +/;

print "After: $value \n\n\n";


## Create A Query String

print "Create A Query String:\n\n";

$value = "Mango and Fruit";

print "Before: $value \n\n";

$value =~ s/ and /+/gi;

print "After: $value \n\n\n";

exit;


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

Date: 27 May 2000 17:22:26 EDT
From: Chris <csorensen@uptimeresources.net>
Subject: Re: using CGI.pm to retrieve data, slice into an array and print to a  flatfile
Message-Id: <39303C86.3A67BFAC@uptimeresources.net>

well .. that works perfectly ..

unfortuantely my script that set's cookies is no longer working .. no error
codes .. the redirect works  .. but using the retrieval script as a test.. I
haven't found any change in the cookies value .. despite the fact that I keep
changing it



jsd wrote:

> In article <39302A11.F5A883A1@uptimeresources.net>, Chris
> <csorensen@uptimeresources.net> wrote:
> >#!/usr/bin/perl
> ># grab and print
> >
> >use CGI qw(:standard);
> >
> >open (IDNT, ">lstrans.txt") || die "cannot open";
> >@idlist = cookie('ident');
> >print IDNT $idlist(1), "\n";
>
> try
>
> #!/usr/bin/perl -w
> use strict;
> use CGI ':cgi';
>
> open IDNT, ">lstrans.txt" or die "can't write file: $!";
> print IDNT cookie('ident'). "\n";
> close IDNT;
>
> * 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: 27 May 2000 16:03:42 EDT
From: Chris <csorensen@uptimeresources.net>
Subject: using CGI.pm to retrieve data, slice into an array and print to a flat  file
Message-Id: <39302A11.F5A883A1@uptimeresources.net>

I set a cookie using CGI.pm and param() .. now that the cookie is set ..
I thought a quick . .tiny little script would be all I need to retrieve
the value I stored and print to a file . .

I checked the cookie setting script .. it worked .. I checked the
cookies set on my browser .. it's there with the correct value stored in
it..  (so I don't think that's the problem)..


any idea where I goofed ..


script to retrieve the data:

#!/usr/bin/perl
# grab and print

use CGI qw(:standard);

open (IDNT, ">lstrans.txt") || die "cannot open";

@idlist = cookie('ident');

print IDNT $idlist(1), "\n";


\/\/\/\\/\//\/\//\\\\/\////\\/\/\/\/


script that set the data:

#!/usr/bin/perl
# Script: stick and move

use CGI qw/:standard/;

$the_cookie = cookie(-name=>'ident',
                     -value=>param("siteID"),
                     -expires=>'+1d');

print header('text/html'),
print redirect('http://www.insuremybiz.com');





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

Date: Sat, 27 May 2000 13:47:52 -0700
From: jsd <jsdNOjsSPAM@gamespot.com.invalid>
Subject: Re: using CGI.pm to retrieve data, slice into an array and print to a flat file
Message-Id: <0510fe82.2b015e0d@usw-ex0105-037.remarq.com>

In article <39302A11.F5A883A1@uptimeresources.net>, Chris
<csorensen@uptimeresources.net> wrote:
>#!/usr/bin/perl
># grab and print
>
>use CGI qw(:standard);
>
>open (IDNT, ">lstrans.txt") || die "cannot open";
>@idlist = cookie('ident');
>print IDNT $idlist(1), "\n";

try

#!/usr/bin/perl -w
use strict;
use CGI ':cgi';

open IDNT, ">lstrans.txt" or die "can't write file: $!";
print IDNT cookie('ident'). "\n";
close IDNT;


* 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: Sat, 27 May 2000 13:10:50 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: using param() and CGI.pm to store a persistent value
Message-Id: <Pine.LNX.4.21.0005271309060.3758-100000@hawk.ce.mediaone.net>

On Sat, 27 May 2000, Godzilla! wrote:

+ Huh? * stupefied *

[ snip ]

+ I know of spelling errors well.
+ My choice is not to use them.

OK.

+ I know of poor bargins. My choice
+ is not to buy one.

That's bargains.

Regards,

anm
-- 
/*-------------------------------------------------------.
| Andrew N. McGuire                                      |
| anmcguire@ce.mediaone.net                              |
`-------------------------------------------------------*/



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

Date: Sat, 27 May 2000 12:31:44 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: using param() and CGI.pm to store a persistent value
Message-Id: <393022A0.7D7D4F35@stomp.stomp.tokyo>

"Andrew N. McGuire" wrote:
 
> On Sat, 27 May 2000, Godzilla! wrote:
 
> + Huh? * stupefied *
 
> [ snip ]
 
> + I know of spelling errors well.
> + My choice is not to use them.
 
> OK.
 
> + I know of poor bargins. My choice
> + is not to buy one.
 
> That's bargains.



Review USENET guidelines. You just
committed one of the lamest most
inane sins for a newsgroup. You
are disrupting the harmony of this
newsgroup. Trolls are not welcomed
much of anywhere. Take your malice
intent trolling elsewhere.


"Never give a sucker an even break."

- W.C. Fields


So petty...

Godzilla!


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

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


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