[9292] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2887 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 16 22:17:20 1998

Date: Tue, 16 Jun 98 19:00:58 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 16 Jun 1998     Volume: 8 Number: 2887

Today's topics:
        Calling perl from NT <webmaster@briefcasegolf.com>
    Re: grep question <aqumsieh@matrox.com>
        Help with exiting a loop Juli@my-dejanews.com
    Re: How can I write to specific line ? (Larry Rosler)
    Re: How to delete a character from a string? (Kevin Reid)
        htpasswd in perl? <doug@zmark.com>
    Re: Large files (>2GB) on Solaris 2.6 <tkil@scrye.com>
    Re: Loop / Parsing Newbie Question <jdporter@min.net>
    Re: Loop / Parsing Newbie Question (Mike Stok)
    Re: MakeMaker: How to run preprocessors? ken_fox@my-dejanews.com
        More efficient search - binary search?? (T. Ames)
    Re: More efficient search - binary search?? (Matt Knecht)
    Re: perl cgi generated html with java app "class not fo (David Innes)
    Re: Perl5 and the X11 libraries. (Craig Berry)
    Re: Perl5 and the X11 libraries. (Stuart McDow)
    Re: print <<END (with variables) (Alex Barilo)
    Re: print <<END (with variables) (Larry Rosler)
    Re: print <<END (with variables) (Kevin Reid)
    Re: Problem with pattern matching (Win32) (Larry Rosler)
    Re: Problem with pattern matching (Win32) (Patrick Timmins)
    Re: Problems Building Perl on Win95 <rpsavage@ozemail.com.au>
        Reading in multiple lines from file--elegant solution? sylvia@lsbio.com
    Re: Reading in multiple lines from file--elegant soluti (Matt Knecht)
    Re: Reading in multiple lines from file--elegant soluti (Bob Trieger)
    Re: Reading in multiple lines from file--elegant soluti (Mike Stok)
    Re: Reading in multiple lines from file--elegant soluti (Larry Rosler)
    Re: REVIEW: Perl CGI Programming - No Experience Requir <franzen@pmel.noaa.gov>
    Re: Sending mail, can I set the $from ? (Paul Rolfe)
    Re: simple expression matching problem (Larry Rosler)
        Tutorial for perldoc <achoy@us.oracle.com>
    Re: Tutorial for perldoc (Bob Trieger)
    Re: Undefined subroutine CGI::pram <jdporter@min.net>
    Re: Use of DBD::Oracle from cron (Todd Hivnor)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 16 Jun 1998 23:08:13 GMT
From: "Caleb Newville" <webmaster@briefcasegolf.com>
Subject: Calling perl from NT
Message-Id: <01bd997b$a17ea2a0$4685d4d1@newville>

Does anyone know how to call a perl or CGI from a HTML file on an NT
server. The following command works on Unix, but not on NT. Have a
solution?

<#!-- exec cgi="/cgi-bin/perl_script.pl">


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

Date: Tue, 16 Jun 1998 18:47:01 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: grep question
Message-Id: <3586F5E5.B07325E6@matrox.com>

Bryan Camp wrote:

> Hello,
>
> I have a simple question about executing
> a grep statement within a perl script.
> What I'm trying to do is prompt the user
> for input, and then search the current directory
> for all occurrences of this input.

> So far I have:
>
> $input = <STDIN>;
> $output = `grep $input *.par > outfile`;
>
> The second line works fine from the command line,
> and from my understanding, one can execute command
> line statements by placing backquotes around it.
> However, when I view the outfile, it is blank,
> even though there are occurences of the user input
> within many files in the directory.

That is due to the newline character "\n" that is appended to you $input
variable when the user types in his input and presses the return key.
(I wish I had a dollar for each time I said that!)

Chomp() it of:
chomp($input = <STDIN>);

> Can someone perhaps tell me what I'm doing wrong,
> or give advice on a different approach to take?
>

Buy yourself a copy of the Llama book .. by Randal Schwartz and Tom
Chtistiansen.

> Thank you.
>
> Bryan



--
Ala Qumsieh             |  No .. not just another
ASIC Design Engineer    |  Perl Hacker!!!!!
Matrox Graphics Inc.    |
Montreal, Quebec        |  (Not yet!)





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

Date: Wed, 17 Jun 1998 01:32:01 GMT
From: Juli@my-dejanews.com
Subject: Help with exiting a loop
Message-Id: <6m76ah$db3$1@nnrp1.dejanews.com>

unless (open(LIST, "list.pl")) {  die ("Can't open list\n"); } $rep_name =
"SamV";      while ($line =<LIST>)   {			     if ($line =~
"$rep_name")			   {					     
	      substr($rep_name,3) =~ tr/a-z/A-Z/;		     exit;   
	       }		       else		       {	     
	  substr($rep_name,0) =~ tr/a-z/A-Z/;			
substr($rep_name,1) =~ tr/A-Z/a-z/;			exit;		     
  }	  } Basically what I'm trying to do is read a list, and compare it to
another value. If it is the same, capitalize  the whole value. If is
different, then capitalize the first value. My problem is I can only exit the
program in one of the if sections, not both.  What I want to do is as soon as
it finds what it is looking for to exit, instead it keeps going through the
loop.  Please help, I'm a little new at this. My email address is
julih@earthlink.net

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Tue, 16 Jun 1998 18:50:10 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How can I write to specific line ?
Message-Id: <MPG.ff0c0ace69ef43898968d@nntp.hpl.hp.com>

In article <6m6fta$fh$1@usenet50.supernews.com>, danbeck@eudoramail.com 
says...
> The man pages talk about in-place editing. Check out the IO section.  I think 
> that's where it is.
> 
> In article <6l5q1v$h5m$1@news.huji.ac.il>, evgenya@amos-01.cs.huji.ac.il 
> (Evgenya Borisenko) wrote:
> >Hi,
> >
> >I'd like to know is there a possibility to write (change) to a specific
> >line in a file ?
> >
> >Thanx for any help,
> >Eugenia.

perlfaq5: How do I change one line in a file/delete a line in a 
file/insert a line in the middle of a file/append to the beginning of a 
file? 

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Tue, 16 Jun 1998 21:27:32 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: How to delete a character from a string?
Message-Id: <1daqih2.1vf6kpw9fobf0N@slip166-72-108-131.ny.us.ibm.net>

Alex T <at@pixelfilm.com> wrote:

> Hi!
> 
> I have a variable, for example "$xy". If the first character is "0", the
> character should be
> deleted.
> How can I compare and delete a character from a string???

#!perl -w

use Benchmark;

timethese(500000, {
  'substr1' => sub {
    $xy = '0101';
    $xy = substr($xy, 1) if substr($xy, 1) eq '0';
  },
  'substr0' => sub {
    $xy = '1010';
    $xy = substr($xy, 1) if substr($xy, 1) eq '0';
  },
  'regexp1' => sub {
    $xy = '0101';
    $xy =~ s/^0//;
  },
  'regexp0' => sub {
    $xy = '1010';
    $xy =~ s/^0//;
  },
});

__END__

(run twice due to variability)

Benchmark: timing 500000 iterations of regexp0, regexp1, substr0,
substr1...
   regexp0:  5 secs ( 5.47 usr  0.00 sys =  5.47 cpu)
   regexp1:  8 secs ( 8.12 usr  0.00 sys =  8.12 cpu)
   substr0:  8 secs ( 8.35 usr  0.00 sys =  8.35 cpu)
   substr1:  6 secs ( 7.30 usr  0.00 sys =  7.30 cpu)
Benchmark: timing 500000 iterations of regexp0, regexp1, substr0,
substr1...
   regexp0:  6 secs ( 5.92 usr  0.00 sys =  5.92 cpu)
   regexp1:  9 secs ( 9.00 usr  0.00 sys =  9.00 cpu)
   substr0:  9 secs ( 9.23 usr  0.00 sys =  9.23 cpu)
   substr1:  8 secs ( 7.43 usr  0.00 sys =  7.43 cpu)

Depends on which case is more common.

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: Tue, 16 Jun 1998 20:41:48 -0400
From: Douglas Potts <doug@zmark.com>
Subject: htpasswd in perl?
Message-Id: <358710CC.833494BD@zmark.com>

Need help with a script I am working on that will create passwords the
same as htpasswd executable.

My confusion come in with how to fire-off the crypt function to include
the proper salt.

And is that all I need to figure out???

Thanks,

Doug
doug@zmark.com



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

Date: 16 Jun 1998 17:17:47 -0600
From: Tkil <tkil@scrye.com>
Subject: Re: Large files (>2GB) on Solaris 2.6
Message-Id: <g3ed5j5r8.fsf@scrye.com>

>>>>> "MJTG" == M J T Guy <mjtg@cus.cam.ac.uk> writes:

MJTG> There is discussion going on on making Perl properly 64 bit, but
MJTG> don't hold your breath.

there is also a mailing list.  take a look at the bottom of:

   http://www.perl.org/maillist.html

t.
-- 
Tkil * <URL: http://www.scrye.com/~tkil> * hopelessly hopeless romantic.
  "So amplify this little one 	|   She hears as much as she can see
   She's a volume freak       	|   And what she sees, she can't believe."
        -- Catherine Wheel, _Happy Days_, "Judy Staring At The Sun"


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

Date: Tue, 16 Jun 1998 23:31:18 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Loop / Parsing Newbie Question
Message-Id: <3587020B.23DD@min.net>

Tim Olson wrote:
> 
> I am relatively new to Perl and the newsgroup.

Here's a friendly tip: use of MIME is severely frowned upon
in this newsgroup.  Plain text is where it's at, man.



while (<INP>) {
  chomp;
  if ( /%VEND / ) { check_rec();    $vend = $'; }
  if ( /%TOPCELL / )          {  $topcell = $'; }
  if ( /%CPROP\s+Cellname=/ ) { $cellname = $'; }
}
check_rec();

sub check_rec {
  return unless defined($topcell) && defined($cellname);
  print "VEND $vend: TOPCELL=$topcell, Cellname=$cellname\n";
  if ( $topcell eq $cellname ) {
    print "SAME!\n";
  } else {
    print "DIFFERENT!\n";
  }

  $topcell = undef;
  $cellname = undef;
}
 

hth,
John Porter


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

Date: 16 Jun 1998 23:51:34 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Loop / Parsing Newbie Question
Message-Id: <6m70e6$su@news-central.tiac.net>

In article <3586DAB6.91334AE3@ball.com>, Tim Olson  <tolson@ball.com> wrote:
>-=-=-=-=-=-
>
>I am relatively new to Perl and the newsgroup.  My question involves
>searching through an ASCII text file for certain matches.  A section of
>the file to be searched is shown below:
>
>%NAME KJ888
>
>   %SYMB REF_6PIN default
>        gate1 GND V_OUT TEMP TRIM VIN O/P_SEL
>%VEND AD494OP/SSS default
> %INTERNAL 5962-9463601MPA default
>        %COMP   nc_gate 1
>                nc_gate 7
>                gate1 4 6 3 5 2 8
> %TOPCELL DIP8                <---------------------
> %DESC "IC, AD780"
>        %CPROP  ALTSHAPE=DIP8S
>        %CPROP  matspec=DESC 5962-94636
>        %CPROP  cage=14933
>        %CPROP  notes=F7
>        %CPROP  Cellname=DIP8 <------------------
>        %CPROP  Part no=AD780
>        %CPROP  voltage =
>        %CPROP  Component tol=0.2%
>
>I need to see if the properties following "%TOPCELL and %CPROP
>Cellname" match (pointed to above).  I have figured this out, but it
>gets more complicated it there are multiple %VEND declarations in one
>file.  There is a different "%TOPCELL and %CPROP  Cellname" under each
>declaration that need to be compared and logged to a file.  How do I
>loop through each %VEND declaration, one at a time?  I have tried the
>following code, but it never enters the second while loop:
>
>while($inline = <INP>){
>
>while($inline =~ /%VEND\s+(\S+)/){

The second while loop never assigns another line of input to $inline, so
once the loop condition is true it stays that way.  One way to do it might
be something like this (untested code):

  while (<INPUT>) {
    if (($topCell) = /^%TOPCELL\s+(\w+)/) {
      # remember most recent TOPCELL and where we saw it

      $topCellLine = $.;
      next;
    }

    if (($cellName) = /^\s+%CPROP\s+Cellname=(\w+)/) {
      unless (defined $topcell) {
        warn "$0: found Cellname with no preceding TOPCELL (line $.)\n";
      }
      elsif ($cellName ne $topCell) {
        warn "$0: Cellname ($cellName, line $.) ne " .
             "TOPCELL ($topCell, line $topCellLine)\n";
      }
      else {
        print "OK $cellName\n";
      }
      undef $topCell;
    }
  }

\w+ is a quick and dirty guess at what's legal in an identifier, it might
be more complex e.g. ([A-Z][A-Z0-9.]*)

Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Wed, 17 Jun 1998 00:23:50 GMT
From: ken_fox@my-dejanews.com
Subject: Re: MakeMaker: How to run preprocessors?
Message-Id: <6m72ao$53h$1@nnrp1.dejanews.com>

ehood@geneva.acs.uci.edu (Earl Hood) wrote:
> Zenin  <zenin@bawdycaste.org> wrote:
> > I'm trying to find a way to get MakeMaker to run my modules through a
> > preprocessor such as cpp ...
>
> You may want to look at the Makefile.PL that comes with GetoptLong.
> Johan Vromans generates the module to be installed from separate source
> files by using the MY::postamble ...

I took a look at GetoptLong and it seems like it doesn't use
this technique anymore.  I was hoping to see somebody else
using this technique because I independently arrived at the
same place and it kinda seems like a hack.

Here's my Makefile.PL code:

sub MY::postamble {'
XRT.pm: XRT.in
        '.join(' ', $Config{'cppstdin'}, $xrt_flags, $incs,
$Config{'cppminus'}).' < XRT.in > XRT.pm
'}

WriteMakefile('OPTIMIZE' => '-g',
              'TYPEMAPS' => [ '../typemap' ],
              'NAME' => 'X11::XRT',
              'PM' => { 'XRT.pm' => '$(INST_LIBDIR)/XRT.pm',
                        'XRTCons.pm' => '$(INST_LIBDIR)/XRTCons.pm' },
              'realclean' => { FILES => 'XRT.pm' },
              'DEFINE' => $xrt_flags,
              'INC' => $incs,
              'LIBS' => [ $libs ],
              'OBJECT' => "XRT.o ../Lib/packages.o ../Toolkit/Toolkit.o
 ../Motif/Motif.o",
              'VERSION_FROM' => 'XRT.in',
              @extra_MakeMaker_flags);

Now that I can run a preprocessor, I'm finding that cpp really
sucks for Perl code.  Anybody else think it would be a good
idea to throw a *simple* preprocessor into MakeMaker?

- Ken

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Wed, 17 Jun 1998 00:52:12 GMT
From: ames0009@tc.umn.edu (T. Ames)
Subject: More efficient search - binary search??
Message-Id: <35870f0e.29381792@news.tc.umn.edu>


Suppose you want to test whether or not a variable is a member of an
array.  My first thought is to set up a "for" loop which checks each
element of the array against the variable using pattern match
operation. Like this:

#!/usr/bin/perl5 -w

$keyword = 3;
@numbers = ("1","2","3","4","5");
for ($count = 1; $count <= @numbers; $count++) {
        if ($numbers[$count -1] =~ /$keyword/) {
                print "number 3 reached";
	   last;
                }
}

But suppose I want to call "die" if the the variable $keyword is not
matched in @numbers?

	   else{
                die ("DIED");
	   }
}

Now the trouble is that using an "else" statement will terminate the
loop after the first iterartion (before it reaches "3" and matches and
prints "number 3 reached").  So, in essence, I want the loop to go
through the entire array before if finally dies (assuming no matches
were found).  

One solution is to use a flag, like this:

$flag = 0;
$keyword = 3;
@numbers = ("1","2","3","4","5");
for ($count = 1; $count <= @numbers; $count++) {
        if ($numbers[$count -1] =~ /$keyword/) {
                print "number 3 reached";
	   $flag = 1; 
	    last;
                }
}

##Now use a seperate if statement

if ($flag == 0) {
	die ("DIED");
}

But that seems really lame.  Is there another way to approach this?
Searching through a list using a "for" loop seems really inefficient -
I don't know much C, but I've read about binary seaches on ordered
arrays -- is that possible in Perl?

thanks,

T. Ames










>>>>>>>>>>>>>>>>>>>
Todd C. Ames
ames0009@tc.umn.edu
University of Minnesota


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

Date: Wed, 17 Jun 1998 01:57:06 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: More efficient search - binary search??
Message-Id: <SnFh1.5$qF2.37423@news3.voicenet.com>

T. Ames <ames0009@tc.umn.edu> wrote:
>$keyword = 3;
>@numbers = ("1","2","3","4","5");
>for ($count = 1; $count <= @numbers; $count++) {
>        if ($numbers[$count -1] =~ /$keyword/) {
>                print "number 3 reached";

And 3, being the third number be reached, shal be counted.  Thou shall
not count to 4.  5 is right out.  Thou shalt not count to 2, except in
passing to 3...

>But that seems really lame.

Agreed. :)

You just need to check out 'perldoc grep'.  Instead of all that messy
code, you could have something like this:

@numbers = (1 .. 5);

for $keyword (4 .. 6) {
    print "Got $keyword\n" if grep { $keyword == $_ } @numbers
	or die "Fooey!\n";
}



Not to drift onto another topic, but...

When I first wrote this, I had no idea if grep would be interpreted in a
scalar or list context (Having made this mistake before, I'm quite wary
of it).  I tried to find out through perlsyn; I couldn't find it.  But
this code snippet explained it quite nicely to me:

print "list context\n" if is_list();
print "scalar context\n" if !is_list();

sub is_list { wantarray ? 1 : 0 }

When run, I get "scalar context", so there was no need to say 'scalar
grep ...'.  Nifty, huh? :)

-- 
Matt Knecht - <hex@voicenet.com>
"496620796F752063616E207265616420746869732C20796F7520686176652066
617220746F6F206D7563682074696D65206F6E20796F75722068616E6473210F"


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

Date: Tue, 16 Jun 1998 21:20:41 -0400
From: news@ravenstar.com (David Innes)
Subject: Re: perl cgi generated html with java app "class not found"
Message-Id: <MPG.ff0e3f63b962584989682@news.telerama.com>

In article <MPG.fef85c83b27a1c8989680@news.telerama.com>, 
news@ravenstar.com says...
> Could use some help on this one, relatively new to perl. 
> 
> I have a perl script which reads an existing html document and creates 
> another one from it, with minor changes. The newly created html document 
> can not find the Lake.class (which the java needs) while running in the 
> perl script. The new html doc runs fine on it's own with the Lake.class 
> in the same directory.
> 
> Any suggestions would be appreciated.
> Thanks
> 
Special thanks to all who responded and especially Roger who's single 
line of code solved my problem 100%, thanks Roger.

Change or add "codebase = PATH_OF_CLASS_FILE" in <applet> tag.


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

Date: 16 Jun 1998 23:07:07 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Perl5 and the X11 libraries.
Message-Id: <6m6tqr$fn3$1@marina.cinenet.net>

stephen farrell (sfarrell@farrell.org) wrote:
: kfox@pt0204.pto.ford.com (Ken Fox) writes:
: 
: > Thomas Resing <tresing@globalscape.net> writes:
: > > I have a question regarding security and Perl.  For security reasons,
: > > the X11 libraries are restricted from normal users of our linux server.
: > 
: > I'm a little confused how the X *libraries* can cause a security risk.
: 
: There are suid root executables like xterm that link against them.

Well, yes, but they probably link libc, too -- does that make libc a
security risk?  I really don't see the logic here; it seems backwards.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 16 Jun 1998 23:40:16 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: Perl5 and the X11 libraries.
Message-Id: <6m6vp0$8bt$1@ns1.arlut.utexas.edu>

stephen farrell <sfarrell@farrell.org> writes:
> 
> There are suid root executables like xterm that link against them.

Uh-oh. You're right. We're in big trouble. Looks like we're going to
have to restrict libc as well. There are some executables that link
against it.

--
Stuart McDow                                     Applied Research Laboratories
smcdow@arlut.utexas.edu                      The University of Texas at Austin
            "Look for beauty in roughness, unpolishedness"


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

Date: Tue, 16 Jun 1998 23:08:36 GMT
From: hash@email.infotrade.co.uk (Alex Barilo)
Subject: Re: print <<END (with variables)
Message-Id: <3586efc1.2218315@news.force9.net>

On Tue, 16 Jun 1998 00:49:23 -0400, David Wasserstrum <zeos@gti.com>
wrote:

> So heres the problem... I am using a print <<"END" command so that I can
> print out a table... within the table are a bunch of graphics... some
> times they should be button_left.gif and other times they should be
> buttonon_left.gif.  This depends on what the $a variable is.

 Follow up question: is there a way to do like this:
print <<"EOT"
  &my_func
EOT

and, of cource, to get the RESULT of the my_func.

Cheers,
Alex
---------
All you need is Perl


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

Date: Tue, 16 Jun 1998 18:15:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: print <<END (with variables)
Message-Id: <MPG.ff0b88baa75464398968a@nntp.hpl.hp.com>

In article <3586efc1.2218315@news.force9.net>, hash@email.infotrade.co.uk 
says...
> On Tue, 16 Jun 1998 00:49:23 -0400, David Wasserstrum <zeos@gti.com>
> wrote:
 ...
>  Follow up question: is there a way to do like this:
> print <<"EOT"
>   &my_func
> EOT
> 
> and, of cource, to get the RESULT of the my_func.

In scalar context:  ${\(&my_func)}

In list context:    @{[&my_func]}

Ugly but true.

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Tue, 16 Jun 1998 21:27:35 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: print <<END (with variables)
Message-Id: <1daqiqt.11vmwt1lbur7fN@slip166-72-108-131.ny.us.ibm.net>

Alex Barilo <hash@email.infotrade.co.uk> wrote:

> On Tue, 16 Jun 1998 00:49:23 -0400, David Wasserstrum <zeos@gti.com>
> wrote:
> 
> > So heres the problem... I am using a print <<"END" command so that I can
> > print out a table... within the table are a bunch of graphics... some
> > times they should be button_left.gif and other times they should be
> > buttonon_left.gif.  This depends on what the $a variable is.
> 
>  Follow up question: is there a way to do like this:
> print <<"EOT"
>   &my_func
> EOT
> 
> and, of cource, to get the RESULT of the my_func.

Put this in the string;

print <<"EOT"
  @{[&my_func]}
EOT

Or, if you need scalar context:

print <<"EOT"
  ${\(&my_func)}
EOT

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: Tue, 16 Jun 1998 18:38:19 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Problem with pattern matching (Win32)
Message-Id: <MPG.ff0bde8fda189098968c@nntp.hpl.hp.com>

In article <6m6mol$r9@transfer.stratus.com>, michael_mongeau@stratus.com 
says...
> Perl for Win32 (Build 316) appears to have a problem matching an escaped
> bracket.  I'm just scanning a text file looking for strings enclosed in
> square brackets:
> 
>  open (FH,"file.txt") || die;
>  while (<FH>) {
>    if (/\[/) { do something }
>  }
> 
> This generates a "Missing right bracket at line xx" error.  Am I doing
> something wrong ?  Thanks.
> 
>  Mike Mongeau

Your code works fine with the MKS Win32 perl.

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Wed, 17 Jun 1998 01:43:39 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Problem with pattern matching (Win32)
Message-Id: <6m770c$e2f$1@nnrp1.dejanews.com>

In article <6m6mol$r9@transfer.stratus.com>,
  "Michael Mongeau" <michael_mongeau@stratus.com> wrote:
>
> Perl for Win32 (Build 316) appears to have a problem matching an escaped
> bracket.  I'm just scanning a text file looking for strings enclosed in
> square brackets:
>
>  open (FH,"file.txt") || die;
>  while (<FH>) {
>    if (/\[/) { do something }
>  }
>
> This generates a "Missing right bracket at line xx" error.  Am I doing
> something wrong ?  Thanks.
>
>  Mike Mongeau
>
>

Mike, you've got it set up properly. If I remember right (I haven't used
ActiveState Perl for a year or so now) you might want to try excaping your
escape, eg:

if (/\\[/) { do something }

There are all sorts of goofy and improper things with ActiveState Perl (or
there was when I used to use it). You might want to get the real Perl port
for win32 (Gurusamy Sarathy). I've got Perl 5.004_02 on Win95, and your
original code worked fine.

Hope that helps.

Patrick Timmins
U. Nebraska Medical Center

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 16 Jun 1998 23:22:03 GMT
From: "Ron Savage" <rpsavage@ozemail.com.au>
Subject: Re: Problems Building Perl on Win95
Message-Id: <01bd997d$f02a2ee0$43ea1286@steelres-pcm657.resmel.bhp.com.au>

Cassbrothers <cassbrothers@erols.com> wrote in article
<3586EDC1.6531E0A4@erols.com>...
> I'm new to this newsgroup and new to Perl.  (Please bear with me.)
> 
[snip]
> Before I forge ahead, I'm hoping to get some advice.  If it's not worth
> my time, please let me know - I'll get some space on a server.

It isn't. Get the binary of 500402 from CPAN. The make requires support for
things like '&&' on the command line, I believe, which is simply
unavailable under DOS (aka Win95).

[snip]



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

Date: Tue, 16 Jun 1998 22:49:23 GMT
From: sylvia@lsbio.com
Subject: Reading in multiple lines from file--elegant solution?
Message-Id: <6m6spj$r2k$1@nnrp1.dejanews.com>

Hello,

Is there a more elegant way to do this?

I need to parse out a file which looks something like this:

//
value1: abcdef
value2: arwererbcdef
value3: aweroiupoiwuer
        rweqarsfaserawer
        rweruiwoufoaeu
//
value1: abcdwerweef
value2: abcderweef
value3: aweroiupoiwuer
        rweqarsfaserawer
        rweruiwoufoaeu
//

I've done quite a bit of parsing through a file on a line by line basis, and
that works great most of the time.  But, is there any way I could tell perl

"read into x until you hit a // "

Then I could do whatever I need to with x.

Thanks for any help!
Sylvia

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Tue, 16 Jun 1998 23:18:51 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Reading in multiple lines from file--elegant solution?
Message-Id: <v3Dh1.1$Cb1.3509@news2.voicenet.com>

sylvia@lsbio.com <sylvia@lsbio.com> wrote:
>I need to parse out a file which looks something like this:
>
>//
>value1: abcdef
>value2: arwererbcdef
>value3: aweroiupoiwuer
>        rweqarsfaserawer
>        rweruiwoufoaeu
>//
>"read into x until you hit a // "

How about:

sub get_next_record
{
    local $x;

    while (($line = <FH>) ne "//\n") {
	$x .= $line;
	last and print "File didn't terminate with '//'!\n" if eof(FH);
    }

    $x;
}

-- 
Matt Knecht - <hex@voicenet.com>
"496620796F752063616E207265616420746869732C20796F7520686176652066
617220746F6F206D7563682074696D65206F6E20796F75722068616E6473210F"


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

Date: Tue, 16 Jun 1998 23:19:26 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Reading in multiple lines from file--elegant solution?
Message-Id: <6m6ul9$hun$1@strato.ultra.net>

[ posted and mailed ]

sylvia@lsbio.com wrote:
-> Hello,
-> 
-> Is there a more elegant way to do this?
-> 
-> I need to parse out a file which looks something like this:
-> 
-> //
-> value1: abcdef
-> value2: arwererbcdef
-> value3: aweroiupoiwuer
->         rweqarsfaserawer
->         rweruiwoufoaeu
-> //
-> value1: abcdwerweef
-> value2: abcderweef
-> value3: aweroiupoiwuer
->         rweqarsfaserawer
->         rweruiwoufoaeu
-> //
-> 
-> I've done quite a bit of parsing through a file on a line by line basis, and
-> that works great most of the time.  But, is there any way I could tell perl
-> 
-> "read into x until you hit a // "
-> 
-> Then I could do whatever I need to with x.

open(FH,"your_file") or die "why me: $!";
while (<FH>) {
        last if m!//!;
        push @foo,$_;  # or if you want string  $foo .= $_; 
}
close FH;

but if your file is as shown, then it will end right away because it starts 
with "//".

I am a little confused by your question.

Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-239-0341
    and hang up when the recording starts. "


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

Date: 17 Jun 1998 00:30:10 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Reading in multiple lines from file--elegant solution?
Message-Id: <6m72mi$su@news-central.tiac.net>

In article <6m6spj$r2k$1@nnrp1.dejanews.com>,  <sylvia@lsbio.com> wrote:
>Hello,
>
>Is there a more elegant way to do this?

 [...]

>I've done quite a bit of parsing through a file on a line by line basis, and
>that works great most of the time.  But, is there any way I could tell perl
>
>"read into x until you hit a // "
>
>Then I could do whatever I need to with x.
>
>Thanks for any help!
>Sylvia

Have you considered setting perl's input record separator, stored in $/ ?
It seems you're reading records separated by "//\n"  

The perlvar documentation describes $/ and you can use the perdoc command
to view the documentation which comes with recent versions of perl.

Consider this:

[mike@mike tmp]$ cat try.pl
#!/usr/local/bin/perl -w

$/ = "//\n";

while (<DATA>) {
  chomp;
  print "got >>>$_<<<\n";
}

__END__
//
value1: abcdef
value2: arwererbcdef
value3: aweroiupoiwuer
        rweqarsfaserawer
        rweruiwoufoaeu
//
value1: abcdwerweef
value2: abcderweef
value3: aweroiupoiwuer
        rweqarsfaserawer
        rweruiwoufoaeu
//
[mike@mike tmp]$ ./try.pl
got >>><<<
got >>>value1: abcdef
value2: arwererbcdef
value3: aweroiupoiwuer
        rweqarsfaserawer
        rweruiwoufoaeu
<<<
got >>>value1: abcdwerweef
value2: abcderweef
value3: aweroiupoiwuer
        rweqarsfaserawer
        rweruiwoufoaeu
<<<
[mike@mike tmp]$ 

Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Tue, 16 Jun 1998 18:12:35 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Reading in multiple lines from file--elegant solution?
Message-Id: <MPG.ff0b7daabb8dfd1989689@nntp.hpl.hp.com>

In article <v3Dh1.1$Cb1.3509@news2.voicenet.com>, hex@voicenet.com 
says...
 ...
>     while (($line = <FH>) ne "//\n") {
> 	$x .= $line;
> 	last and print "File didn't terminate with '//'!\n" if eof(FH);
>     }

This 'print' will never be executed.  Preferable would be:
 	print "File didn't terminate with '//'!\n" and last if eof(FH);
or (better):
  	print("File didn't terminate with '//'!\n"), last if eof(FH);

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Tue, 16 Jun 1998 16:26:38 -0700
From: Nathan Franzen <franzen@pmel.noaa.gov>
Subject: Re: REVIEW: Perl CGI Programming - No Experience Required
Message-Id: <Pine.SOL.3.96.980616152042.11046A-100000@corona.pmel.noaa.gov>


On Tue, 16 Jun 1998, Chris Nandor wrote:

> # Beginners should get documentation that says that the array, the AV, is a
> # real thing, and the the list is but a fiction.
> 
> But it is not.  That would be an untruth.

I hope I did not give offense in my previous post.  Unintended.  What I
aimed for was a constructive suggestion of how future documentation might
reduce beginner confusion (and FAQ's to this newsgroup).  To that end I
suggested that the "list" be regarded as a fictional construct, helpful
only in limited ways.  In contrast, "list context" is an obviously vital
concept.  As is the idea of an AV. 

[ I'm avoiding loaded words like 'truth' and the problems therewith: "I
think everyone familiar with this true documentation is well aware that
lists are precisely identical to arrays in the FSF sense" :) :) :) :) ]

Since an array is indeed a Perl variable, it is relatively easy to pin it
down and look at its behavior.  I have been attempting to do the same with
lists, to see some specific list characteristics which cannot be
attributed simply to characteristics of the operators and to the
invocation of "list context". It isn't easy.

I wonder if it is appropriate to think of a list as a sequence of values
without a home ... a list is to an array as a value is to a scalar. 

I'll shut up now.

-Nathan




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

Date: Wed, 17 Jun 1998 00:44:28 GMT
From: prolfe@southwest.com.au (Paul Rolfe)
Subject: Re: Sending mail, can I set the $from ?
Message-Id: <35891116.216167707@news.southwest.com.au>

On Mon, 15 Jun 1998 13:50:54 -0400, dolph6@jersey.net (Christopher
Soeffing) wrote:

>I am using the following call . . .
>
>open (MAIL, "|/bin/mail -s '$subject' $towho 2> /dev/null > /dev/null");
>
>which I don't really understand all that much, and the email I get says it
>is from a name that is associated with where I sent the email from.  I was
>wondering if I can set the actual "from field" of the message that gets
>sent.  
>
>Also if anyone could explain the options that are available when I open a
>file for mail, I would really appreciate it.  I assume -s is for setting
>the subject, but what else is there ?

You can reference sendmail directly:

open (mail,"|/usr/sbin/sendmail -f$from $to");

Which will allow you to set the from address.  It will place a warning
in the "hidden" headers about this being a possible fake message,
however.  I use it here for our Web based mail client at the moment.

Hope this helps.



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

Date: Tue, 16 Jun 1998 18:25:37 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: simple expression matching problem
Message-Id: <MPG.ff0baeca7d356b198968b@nntp.hpl.hp.com>

In article <3586E11C.EA3E3FCF@matrox.com>, aqumsieh@matrox.com says...
> gulam.faruque@csfp.co.uk wrote:
 ...
> > I am using win32-perl v5.004 on NT4
> 
> Poor you!
> 
> > Thanks
> >
> 
> You can easily do that from the command prompt:
> 
> perl -p -i.bak -e 's/\Qstring1\E/string2/g' filename

You made a snide remark about NT but didn't realize the implications.
The correct command (which would also work on Unix) is:

perl -p -i.bak -e "s/\Qstring1\E/string2/g" filename

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Tue, 16 Jun 1998 17:12:58 -0700
From: Allen Choy <achoy@us.oracle.com>
Subject: Tutorial for perldoc
Message-Id: <35870A0A.A738363@us.oracle.com>

I'm looking for some documentation on adding perldoc-style documentation
in perl modules.
Anyone know where I can find this?

thanks--allen



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

Date: Wed, 17 Jun 1998 00:52:50 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Tutorial for perldoc
Message-Id: <6m744d$cm$1@strato.ultra.net>

[ posted and mailed ]

Allen Choy <achoy@us.oracle.com> wrote:
-> I'm looking for some documentation on adding perldoc-style documentation
-> in perl modules.
-> Anyone know where I can find this?


You mean pod?

perldoc perlpod

HTH

Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-239-0341
    and hang up when the recording starts. "


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

Date: Tue, 16 Jun 1998 23:37:12 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Undefined subroutine CGI::pram
Message-Id: <3587036E.6423@min.net>

Dave wrote:
> 
> $variable = $form->pram('variable');
>   Undefined subroutine CGI::pram

Hmm. What do you suppose that error message means?
Could it mean that no subroutine named "pram" was defined in
the CGI module?
If that is the case, what would lead you to want to try to
call a sub named "pram" in the CGI module?  That is, why
do you think (mistakenly) that there should be a sub named "pram"
in the CGI module?  Now, if your thinking was in error, what
would be the most likely way to correct it?  Perhaps, finding
the name of subroutine in CGI which is the one you really wanted.
Say, perhaps, "param".  How would you find that, if it existed?
Would you look in the file CGI.pm, maybe?  Or type "perldoc CGI"
at your command prompt?

John Porter


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

Date: 17 Jun 1998 00:57:31 GMT
From: hivnor@shore.net (Todd Hivnor)
Subject: Re: Use of DBD::Oracle from cron
Message-Id: <6m749r$860@fridge.shore.net>

In article <6m5ufh$r0q$1@tholian.cse.psu.edu>,
John D Groenveld <groenvel@cse.psu.edu> wrote:
>You will be able to duplicate the error by removing your .cshrc or .profile
>file and executing another shell. I suspect you're missing ORACLE_HOME, but
>if you need to set LD_LIBRARY_PATH your installation may be really foobared.

Yes, I was able to duplicate the error from the command line
side by disabling my .cshrc. That was an excellent troubleshooting
tip. Thanks!

As it turns out, LD_LIBRARY_PATH wasn't set. Which is *really*
strange, since I *was* saying $ENV{LD_LIBRARY_PATH} = '/bin/oracle/lib';
And, I was saying it in an early BEGIN block, so it would take affect
*before* I tried to use DBD::Oracle. 

So I don't understanding why setting $ENV{} didn't work, 
but I do know that I can write a simple csh script to set LD_LIBRARY_PATH
and then run my perl script. Weird, but it works. 

Todd Hivnor
hivnor at shore dot net



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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 2887
**************************************

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