[16127] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3539 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 2 18:10:30 2000

Date: Sun, 2 Jul 2000 15:10:20 -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: <962575819-v9-i3539@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 2 Jul 2000     Volume: 9 Number: 3539

Today's topics:
    Re: Pattern Matching (Clinton A. Pierce)
    Re: Pattern Matching (Tad McClellan)
    Re: Pattern Matching (Keith Calvert Ivey)
    Re: Perl Newbie Question <gellyfish@gellyfish.com>
    Re: Perl Tk dynamic widget allocation <gellyfish@gellyfish.com>
        Perl <jumigas@ctv.es>
    Re: Perl <tony_curtis32@yahoo.com>
        PPM problems <greg2@surfaid.org>
    Re: PPM problems <rob9428@swbell.net>
        Problem with part of a string <ab.abson@e-contact.nl>
    Re: Problem with part of a string <jfisher@epotec.com>
    Re: Problem with part of a string (Keith Calvert Ivey)
    Re: Problem with part of a string <tina@streetmail.com>
    Re: Problems installing perl on PC (Bart Lateur)
    Re: Read multiple lines as one <gellyfish@gellyfish.com>
        Redirecting output to file <tambaa@netscape.net>
    Re: upload <gellyfish@gellyfish.com>
    Re: Uploading files via form without CGI.pm (David Efflandt)
    Re: Uploading files via form without CGI.pm <gellyfish@gellyfish.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 02 Jul 2000 18:39:00 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Pattern Matching
Message-Id: <8%L75.18737$fR2.197173@news1.rdc1.mi.home.com>

[Posted and mailed]

In article <395F6A59.19E01350@teleport.com>,
	Dan Burch <dburch@teleport.com> writes:
> 
> if ( $list[2] =~ /\b$search_name\b/ ) 
> 
> that works perfectly on that machine, but when I loaded it to my Unix
> server(solaris running apache and perl5.00404) it it didn't make the
> match. After trying many different combination(hours of banging my head
> on my desk) and testing to see if $list[2] and $seacrh_name were actualy
> there I took a stab in the dark and added a ?.
> 
> if ( $list[2] =~ /\b$search_name?\b/)
> 
> and it worked, but I don't understand why, and that disturbs me because

Fear what you cannot explain.

I guess it all depends on what's in the variable $search_name.  If 
$search_name contains the word "fleas" then

	/\b$search_name\b/  

Would only match "fleas" surrounded by word boundaries of some kind.
If you then match:

	/\b$search_name?\b/

This matches "fleas" or "flea" 'cause that interpolates to:

	/\bfleas?\b/

The "s" becomes optional.  Your problem has something to do with
what's actually in $search_name.  Good luck!


-- 
    Clinton A. Pierce              Teach Yourself Perl in 24 Hours! 
  clintp@geeksalad.org         for details see http://www.geeksalad.org
"If you rush a Miracle Man, 
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Sun, 2 Jul 2000 14:04:31 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Pattern Matching
Message-Id: <slrn8lv11f.amr.tadmc@magna.metronet.com>

On Sun, 02 Jul 2000 09:14:17 -0700, Dan Burch <dburch@teleport.com> wrote:

>I've been working on a script on my developement box (win98 running
>apache and perl5.00502).

>I use a pattern match 
>
>if ( $list[2] =~ /\b$search_name\b/ ) 


Have you ensured that there are no regex metacharacters in $search_name?

Or do you _intend_ for there to be some?


>that works perfectly on that machine, but when I loaded it to my Unix
                                                  ^^^^^^    ^^    ^^^^

Using ASCII (or TEXT) mode FTP?


>server(solaris running apache and perl5.00404) it it didn't make the
>match. After trying many different combination(hours of banging my head
>on my desk) and testing to see if $list[2] and $seacrh_name were actualy
>there I took a stab in the dark and added a ?.
>
>if ( $list[2] =~ /\b$search_name?\b/)
>
>and it worked, but I don't understand why, 


Neither do we.

To evaluate a pattern match, we need two pieces of information:

1) the pattern

2) the string to try and match against


>and that disturbs me because
>I'm not sure whats going on. 


Neither are we.

What is the pattern?  (i.e. what is in $search_name)

What is the string to be matched against (i.e. what is in $list[2])



We need 2 things. 

You gave us neither! 

We can't help much without more information.


Can you make a short and complete program that we can run
to see the behavior you describe?

If you can do that, we can surely get it fixed for you.


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


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

Date: Sun, 02 Jul 2000 19:14:35 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Pattern Matching
Message-Id: <395f9259.1716460@nntp.idsonline.com>

Dan Burch <dburch@teleport.com> wrote:

>After trying many different combination(hours of banging my head
>on my desk) and testing to see if $list[2] and $seacrh_name were actualy
>there I took a stab in the dark and added a ?.
>
>if ( $list[2] =~ /\b$search_name?\b/)
>
>and it worked, but I don't understand why, and that disturbs me because
>I'm not sure whats going on. I'm hoping someone can shed some light on
>this for me.

I don't understand why either.  It would help a lot if you gave
us some idea what the values of $list[2] and especially
$search_name are.  Without that, we're reduced to stabs in the
dark.  For example, the problem could be that $search_name
somehow has a newline on the end that doesn't exist in $list[2].

Do you intend $search_name to be a regular expression or just a
string?  If it's just supposed to be a string, then you ought to
be escaping metacharacters (like .?*+()[]^$) to make it behave
the way you expect (and avoid getting syntax errors):

    if ( $list[2] =~ /\b\Q$search_name\E\b/ )

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


-----= 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! =-----


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

Date: 2 Jul 2000 21:38:24 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl Newbie Question
Message-Id: <8jo980$akq$1@orpheus.gellyfish.com>

On Sun, 02 Jul 2000 17:10:05 GMT Costas Menico wrote:
> I know this is a CGI question but I am trying to accomplish this in
> Perl. 
> 
> ASP/VB has an  object for tracking users' variables.  
> 
> The  object is called the Session object. This is used for tracking
> variables from one form/link to another for a particular user.  So you
> can say:
> 
> cust="John Smith"
> Session("CustName")=cust
> 
> and then on the next form retrive this info by saying:
> 
> cust=Session("CustName")
> 
> There is an expiration time when the Session object becomes invalid.
> 
> Does Perl have an equivalent?  
> 

Perl doesnt care about these things.  The ASP 'session variables' are
achieved by cookies under then bonnet its just the ASP engine hides that
from you.  You probably want to use cookies and you certainly want to
ask in the group comp.infosystems.www.authoring.cgi ...

/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

Date: 2 Jul 2000 22:51:47 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl Tk dynamic widget allocation
Message-Id: <8jodhj$one$1@orpheus.gellyfish.com>

On Thu, 29 Jun 2000 15:06:24 -0400 "Francois Eric (LMC)" wrote:
> Both solutions did not work.  Here is the problem again
> 
> Thank you anyway,
> 

Maybe you should have posted into comp.lang.perl.tk in the first place.
Just a thought ...

/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

Date: Sun, 02 Jul 2000 19:53:31 GMT
From: "Juan Miguel" <jumigas@ctv.es>
Subject: Perl
Message-Id: <%4N75.441$S96.6482@m2newsread.uni2.es>

Hello,
Does anybody know how to change a decimal number into a hexadecimal?
Thanks.

--
________________________________________
web personal: http://www.ctv.es/USERS/jumigas





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

Date: 02 Jul 2000 15:31:40 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Perl
Message-Id: <873dls2s0j.fsf@limey.hpcc.uh.edu>

>> On Sun, 02 Jul 2000 19:53:31 GMT,
>> "Juan Miguel" <jumigas@ctv.es> said:

>> Subject: Re: Perl

your subject should reflect the content of your post:
something like "decimal to hexadecimal conversion?" would
have been better.

> Hello, Does anybody know how to change a decimal number
> into a hexadecimal?

You can *represent* a number as a hex *numeral* (string)
through the 'x' conversion in

    perldoc -f sprintf

hth
t
-- 
"With $10,000, we'd be millionaires!"
                                           Homer Simpson


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

Date: Sun, 02 Jul 2000 20:16:58 +0100
From: Greg Griffiths <greg2@surfaid.org>
To: support@activestate.com
Subject: PPM problems
Message-Id: <395F952A.929BCB33@surfaid.org>

Having rebuit my machine and re-installed the latest PERL from
Activestate as well as the PPM fix, I am still getting the following
error :



Microsoft(R) Windows 98
   (C)Copyright Microsoft Corp 1981-1998.

C:\WINDOWS\Desktop>ppm
PPM interactive shell (1.1.4) - type 'help' for available commands.
PPM> install DBD::ODBC
Install package 'DBD-ODBC?' (y/N): y
Retrieving package 'DBD-ODBC'...

unclosed token at line 11, column 43, byte 936 at
C:/Perl/site/lib/SOAP/Parser.p
m line 73
C:\WINDOWS\Desktop>

any ideas ?




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

Date: Sun, 2 Jul 2000 14:40:08 -0500
From: "Rob" <rob9428@swbell.net>
Subject: Re: PPM problems
Message-Id: <MXM75.27$Nn3.51172@nnrp3.sbc.net>

You may want to check but I believe there is an additional patch from
ActiveState for Win 95 and 98. As well as the ppm patch.


"Greg Griffiths" <greg2@surfaid.org> wrote in message
news:395F952A.929BCB33@surfaid.org...
> Having rebuit my machine and re-installed the latest PERL from
> Activestate as well as the PPM fix, I am still getting the following
> error :
>
>
>
> Microsoft(R) Windows 98
>    (C)Copyright Microsoft Corp 1981-1998.
>
> C:\WINDOWS\Desktop>ppm
> PPM interactive shell (1.1.4) - type 'help' for available commands.
> PPM> install DBD::ODBC
> Install package 'DBD-ODBC?' (y/N): y
> Retrieving package 'DBD-ODBC'...
>
> unclosed token at line 11, column 43, byte 936 at
> C:/Perl/site/lib/SOAP/Parser.p
> m line 73
> C:\WINDOWS\Desktop>
>
> any ideas ?
>
>
>



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

Date: Sun, 2 Jul 2000 20:32:08 +0200
From: "Ab Abson" <ab.abson@e-contact.nl>
Subject: Problem with part of a string
Message-Id: <395f8dc5$0$19999@reader3>

Hello,

I have a script in which a field contains information on specific positions.
Now I want to move the value of positions 5 till 8 from this field in an
other field.
I have tried this with split but nothing really works.

Thanx, Ab.




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

Date: Sun, 02 Jul 2000 19:11:29 GMT
From: James Fisher <jfisher@epotec.com>
Subject: Re: Problem with part of a string
Message-Id: <395F93A1.1070307@epotec.com>

Ab Abson wrote:
> 
> Hello,
> 
> I have a script in which a field contains information on specific positions.
> Now I want to move the value of positions 5 till 8 from this field in an
> other field.
> I have tried this with split but nothing really works.
> 
> Thanx, Ab.
> 
> 
Could you elaborate a bit on exactly what you want to do...

JF



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

Date: Sun, 02 Jul 2000 19:20:04 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Problem with part of a string
Message-Id: <3960950f.2410561@nntp.idsonline.com>

"Ab Abson" <ab.abson@e-contact.nl> wrote:

>I have a script in which a field contains information on specific positions.
>Now I want to move the value of positions 5 till 8 from this field in an
>other field.
>I have tried this with split but nothing really works.

If you're looking for data at specific positions (rather than
data separated by a specific character or character sequence),
then you probably want to use substr, not split.  Something like

    my $field = substr($line, 5, 4);

(or substr($line, 4, 4), depending on what "position 5" means to
you).

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


-----= 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! =-----


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

Date: 2 Jul 2000 19:35:04 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Problem with part of a string
Message-Id: <8jo5h7$10h0n$2@ID-24002.news.cis.dfn.de>

hi,
Ab Abson <ab.abson@e-contact.nl> wrote:

> I have a script in which a field contains information on specific positions.
> Now I want to move the value of positions 5 till 8 from this field in an
> other field.
> I have tried this with split but nothing really works.

i can only guess. with field you mean a
string? 
$string = "123456789";
and you want the 5678?
$part = substr($string, 4, 4);

read perldoc perlfunc
and perldoc -f substr

tina



-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \ _,_\ __/\ __/_| /__/ perception
"The Software required Win98 or better, so I installed Linux."


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

Date: Sun, 02 Jul 2000 20:52:50 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Problems installing perl on PC
Message-Id: <3961ab8b.1632755@news.skynet.be>

Neil Jones wrote:

>The problem was in the registry. I was advised to run regclean.
>This worked.

Long live the Registry. Pile of crap. 

-- 
	Bart.


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

Date: 2 Jul 2000 22:00:06 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Read multiple lines as one
Message-Id: <8joagm$eqd$1@orpheus.gellyfish.com>

On Fri, 30 Jun 2000 17:43:28 -0400 Gary Pitman wrote:
> In a file that contains
>     <VirtualHost xxx.xxx.xxx.xxx:80>
>         ServerName www.foo.com
>         DocumentRoot /home/a/abc/www
>     </VirtualHost>
> i need to extract only the domain name and the username from the path
> ("abc" in above example)
> I can get it to work when all the info is on one line but I am having
> trouble remembering or finding how to treat multiple lines as one.
> I am sure the tags will make this simple if i could just remember how to
> do it.
> 

Here is one I made earlier that might be of use to you :

#!/usr/bin/perl -w

use strict;


my %virthosts;
my $invirthost;
my $currhost;
my $skipit;

while(<>)
{
  chomp;
  if (/<VirtualHost\s+([^\s>]+)\s*>/)
    {
     $invirthost++;
     $currhost = $1;
    }
  elsif ( m#</VirtualHost>#)
    {
      $invirthost = 0;
    }
  elsif ( $invirthost )
    {
      $skipit++,next if ( /<Directory/ );
      $skipit = 0, next if (m#</Directory#);
      next if ($skipit);  
      s/^\s+//g;
      my ($attr,$value) = split / /,$_,2;
      $virthosts{$currhost}->{$attr} = $value;
    }
}

my $host;
foreach $host (keys %virthosts)
 {
   print $host,":\n";
   my $config;
   foreach $config (keys %{$virthosts{$host}})
     {
       print "\t$config :\t $virthosts{$host}->{$config}\n";
     }
}


/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

Date: Sun, 02 Jul 2000 16:49:01 -0500
From: TH <tambaa@netscape.net>
Subject: Redirecting output to file
Message-Id: <395FB8CD.688672B7@netscape.net>

Hello,

I have a cgi form whose action calls a remote cgi script with the post
method. The problem is I need to save the output in a file and not
display it on the browser. The output on the browser will just be a
successful or unsuccesful message. Any ideas or a short sample code
that can help me achieve this?

TIA
TH


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

Date: 2 Jul 2000 22:33:09 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: upload
Message-Id: <8jocel$l5a$1@orpheus.gellyfish.com>

On Thu, 29 Jun 2000 15:48:04 +0200 Nesiren Armin wrote:
> Hi !
> 
> Somebody know how to upload file from web site to server ... whit cgi-perl
> script... thanks!
> 

I dont know what a 'cgi-perl script' is but if you are using Perl to
write a CGI program and if you are using the module CGI.pm then there
is a section in the manpage for that module which discusses this.
Alternatively you might want to search on Deja News 
<http://www.deja.com/home_ps.shtml> for 'CGI upload' and you will be sure
to find an example.

Heres one I prepared earlier (the date on the file indicates that it is
older than the stuff you can get from Deja News at the moment ):

#!/usr/bin/perl -wT

use strict;

use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

if (defined param('uploaded_file' ))
{
   my $fh = upload('uploaded_file');

   print header('text/plain');

   while (<$fh>) 
   {
      print;
   }
}
else
{
  print header,
        start_html,
        start_multipart_form,
        filefield( -name => 'uploaded_file'),
        submit(-name => 'submit'),
        end_form,
        end_html;
}

Dont take my posting this as an excuse not to read the documentation or
search the other resources though.

You are probably better off asking in comp.infosystems.www.authoring.cgi
anyhow as most of the issues here are general to  CGI rather than specific
to Perl .

/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

Date: 2 Jul 2000 20:28:42 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Uploading files via form without CGI.pm
Message-Id: <slrn8lv9es.9ed.efflandt@efflandt.xnet.com>

On Sun, 02 Jul 2000, auto71426@hushmail.com <auto71426@hushmail.com>
wrote:
>For educational (masochism) purposes. How would I be able to uploading a
>file via a form without using CGI.pm? Any sample scripts/Help URLs/FAQs
>welcomed.

A very crude CGI I did years ago (before Perl5) is available as
ul-demo.tgz or ul-demo.zip at http://www.de-srv.com/pub/.  Since it holds
the uploaded file in memory, upload file size is limited.  Should be
modified to use a tmp file.

The regex that parses uploaded filename from path is too rigid:

/([-\w.]*)$/

Should be more flexible for any OS:

m|[/\\:]+([^/\\:]+)$|


-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: 2 Jul 2000 21:34:45 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Uploading files via form without CGI.pm
Message-Id: <8jo915$9st$1@orpheus.gellyfish.com>

On Sun, 02 Jul 2000 17:10:57 GMT auto71426@hushmail.com wrote:
> For educational (masochism) purposes. How would I be able to uploading a
> file via a form without using CGI.pm? Any sample scripts/Help URLs/FAQs
> welcomed.
> 
If its for educational purposes then you dont want to see any sample scripts
you want to start with the CGI specification :

    < http://www.w3.org/CGI/>

and take it from there.  In production code you will want to CGI.pm though.

/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

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


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