[11636] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5236 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 26 16:07:32 1999

Date: Fri, 26 Mar 99 13:00:22 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 26 Mar 1999     Volume: 8 Number: 5236

Today's topics:
    Re: Anonymous Hashes (Steve Linberg)
    Re: Anonymous Hashes <jglascoe@giss.nasa.gov>
    Re: Anonymous Hashes (Bill Moseley)
        anything like xemacs for win32? <hattons@cpkwebser5.ncr.disa.mil>
    Re: anything like xemacs for win32? <jzucker@sprynet.com>
    Re: array question (Abigail)
    Re: Bitwise Operators (Abigail)
    Re: Calculating the current time in London or GMT+x (Abigail)
    Re: Can Somedy Stop This Script From Crashing the Log F (Abigail)
    Re: Can Somedy Stop This Script From Crashing the Log F (Aart Koelewijn)
    Re: cardinality of an associative array? (Abigail)
        CGI/Perl help needed <jdalldata@my-dejanews.com>
    Re: check to see if directory exists (Bill Moseley)
    Re: check to see if directory exists <jglascoe@giss.nasa.gov>
    Re: Counter Digits (Steve Linberg)
    Re: How do I use POST from an HTML form (Steve Linberg)
    Re: How do you use a variable in an array name? (Larry Rosler)
    Re: How do you use a variable in an array name? (Greg Bacon)
    Re: my random doesn't return number!! <arnej@fc.hp.com>
    Re: Need Help with Simple Program <aqumsieh@matrox.com>
        newbie questions hilaryk8088@my-dejanews.com
    Re: newbie questions <jglascoe@giss.nasa.gov>
    Re: newbie questions <jbc@shell2.la.best.com>
    Re: newbie questions <jglascoe@giss.nasa.gov>
    Re: Perl and Databases on NT. Which module to use pault12@postoffice.pacbell.net
    Re: Problem about REGULAR EXPRESSION <cassell@mail.cor.epa.gov>
        regexp on block of text stenew@my-dejanews.com
    Re: Sorry to be angry, but i do not know what is wrong. <jdf@pobox.com>
        Unprintable ASCII characters <zephria1@hotmail.com>
    Re: Unprintable ASCII characters (Larry Rosler)
    Re: Unprintable ASCII characters <juex@my-dejanews.com>
        WebPDB Publication Database Engine <mark@sunserv.kfki.hu>
    Re: WHY: open (HPIPE, "| notexistfile") or die "..."; D <aqumsieh@matrox.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 26 Mar 1999 14:10:21 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Anonymous Hashes
Message-Id: <linberg-2603991410210001@ltl1.literacy.upenn.edu>

In article <36FBD263.691DB2DE@eli.net>, Charles Arcudi <carcudi@eli.net> wrote:

> --------------9259B9F635645DB50D18940F
> Content-Type: text/html; charset=us-ascii
> Content-Transfer-Encoding: 7bit

Please, please, please don't post HTML.  It makes people mad.


> We all know about using foreach with a plain old hash:
> 
>                        foreach $k (keys %ENV) {
>                print STDOUT "$ENV{$k}\n";
>             }
> 
> Is there a similar construct for retrieving members of an anonymous has
> (or attributes of a class, as the case may be), where the members are
> referred to as $hash->{value}?

You mean you want to get the keys of hash you only have a reference to?

foreach $k (keys %$hr) {
   print "$hr->{$k}\n";
}

-- 
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>


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

Date: Fri, 26 Mar 1999 14:12:33 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Charles Arcudi <carcudi@eli.net>
Subject: Re: Anonymous Hashes
Message-Id: <36FBDC21.D7A8D42@giss.nasa.gov>

[courtesy copy sent to cited author]

my $hash_ref = { foo => 1, bar => 3 };
#  ^^^^^^^^^   ^^^^^^^^^^^^^^^^^^^^^^
#  reference     anonymous hash
#  to a hash

my $foo = sub { print @_, "\n" };
#  ^^^^   ^^^^^^^^^^^^^^^^^^^^
#   ref       anonymous

foreach $k (keys %$hash_ref) {
    &$foo($k, $hash_ref->{$k});
}

# or, similarly,

while (my ($k, $v) = each %$hash_ref) {
    $foo->($k, $v);
}

	Jay Glascoe
-- 
"Just say 'Narf!'."
  --Pinky


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

Date: Fri, 26 Mar 1999 11:23:05 -0800
From: moseley@best.com (Bill Moseley)
Subject: Re: Anonymous Hashes
Message-Id: <MPG.11657e779d50a0949896f8@206.184.139.132>

In article <36FBD263.691DB2DE@eli.net>, carcudi@eli.net says...
> Is there a similar construct for retrieving members of an anonymous has
> (or attributes of a class, as the case may be), where the members are
> referred to as $hash->{value}?

Do you mean something like:
my $hash_ref = {
    1 => 'bar',
    2 => 'foo',
};

foreach  ( keys %$hash_ref ) {
    print "Key: '$_' has a value of '$hash_ref->{$_}'\n";
}

-- 
Bill Moseley mailto:moseley@best.com


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

Date: Fri, 26 Mar 1999 13:35:45 -0500
From: "Steven T. Hatton" <hattons@cpkwebser5.ncr.disa.mil>
Subject: anything like xemacs for win32?
Message-Id: <36FBD381.362916AB@cpkwebser5.ncr.disa.mil>

I have found Xemacs is really good for editing perl code on a linux
box.  I especially like the color syntax highlighting.  Is there
anything that runs under win32 that will give me color syntax
highlighting?  I see that a port to win32 is underway for xemacs.  It
doesn't look like it's there yet.  There is a  port of emacs, but I
don't see a way to get the color syntax highlighting with that.

TIA,

Steve

--
http://www.winehq.com   | I think.
http://www.suse.com     | I think I am.
http://www.kde.org      | Therefore I am.
http://samba.anu.edu.au | I think? - Moody Blues






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

Date: Fri, 26 Mar 1999 15:41:29 -0500
From: Jeff Zucker <jzucker@sprynet.com>
Subject: Re: anything like xemacs for win32?
Message-Id: <36FBF0F9.7EF81D09@sprynet.com>

cperl mode for emacs does great color syntax highlighting on win32.

-- 
jeff


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

Date: 26 Mar 1999 19:06:11 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: array question
Message-Id: <7dglr3$imb$1@client2.news.psi.net>

Bart Lateur (bart.lateur@skynet.be) wrote on MMXXXIII September MCMXCIII
in <URL:news:36fc5da9.2607784@news.skynet.be>:
// 
// I can't follow. Why do something so complicated (and possibly slow?)
// 
// 	$file_extension =~ s/.*\.//;
// 
// ONE substitution. Kill everything up to and including the last period.
// 
// Note that this will fail (as will yours ;-) if there is NO extension,
// i.e. no period. The extension should be a null string in that case.


This will make the extension the filename, if there's no period:

        $file_extension = (split /\./ => $file_extension) [-1];

Alternatively, one could work with rindex and substr:

        $file_extension = substr $file_extension =>
                                 1 + rindex $file_extension => '.';


Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: 26 Mar 1999 19:07:06 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Bitwise Operators
Message-Id: <7dglsq$imb$2@client2.news.psi.net>

Benjamin (bench@surfshop.net.ph) wrote on MMXXXIII September MCMXCIII in
<URL:news:7df0la$25q$1@tempo.news.iphil.net>:
"" Are there equivalent of C bitwise operators such as AND (&) and OR (|) in
"" Perl?


Djees. How hard would that be to look up in the manual?




Abigail
-- 
perl -wlne '}for($.){print' file  # Count the number of lines.


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

Date: 26 Mar 1999 19:08:24 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Calculating the current time in London or GMT+x
Message-Id: <7dglv8$imb$3@client2.news.psi.net>

Steffen Beyer (sb@sdm.de) wrote on MMXXXIII September MCMXCIII in
<URL:news:7dfmfp$480$1@solti3.sdm.de>:
?? In article <36FA5AD1.3EEE2C9@soton.sc.philips.com>, Neil Johnson <neil.johnson@soton.sc.philips.com> wrote:
?? 
?? > Californian daylight saving , I believe is very similar to British and
?? > European daylight saving. The only difference is that in Britain and
?? > Europe the clocks go forward a week earlier than California (28th March).
?? > The clocks go back on the same date.
?? 
?? AFAIK, DST begins and ends also in the middle of a week in the U.S.


No it doesn't.



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


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

Date: 26 Mar 1999 19:09:38 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Can Somedy Stop This Script From Crashing the Log File?
Message-Id: <7dgm1i$imb$4@client2.news.psi.net>

tatabu@my-dejanews.com (tatabu@my-dejanews.com) wrote on MMXXXIII
September MCMXCIII in <URL:news:7df22t$rht$1@nnrp1.dejanews.com>:
## This CGI script keeps deleting the contents of the
## HTML LOG file it reads/recreates too often. Can somebody
## fix it? I would appreciate it.

Maybe if you make some logical layout to your program.

But your code is a total mess.




Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


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

Date: 26 Mar 1999 10:17:13 GMT
From: aart@mtack.xs4all.nl (Aart Koelewijn)
Subject: Re: Can Somedy Stop This Script From Crashing the Log File?
Message-Id: <7dfmr9$8ak$1@mtack.xs4all.nl>

In article <7df22t$rht$1@nnrp1.dejanews.com>,
	tatabu@my-dejanews.com writes:
> This CGI script keeps deleting the contents of the
> HTML LOG file it reads/recreates too often. Can somebody
> fix it? I would appreciate it.
> 
> @@-->>> tatabu
> tatabu@ministre.com
> 
> open (LOG, "$logpath") || die;
> @data = <LOG>;
> close(LOG);
> 
> $url = "<tr><td align=\"right\"><a
> href=\"$ENV{'DOCUMENT_URI'}\">$ENV{'DOCUMENT_URI'}</a>:</td>"; $count = 0;
> $pad = "%.$pad"."d"; open (LOG, ">$logpath") || die; flock (LOG,2); foreach
                                   >>
> $line(@data) {	if ($line =~ /$url/) {	$line =~ /<td>(.*)<\/td>/;  $count =
> $1;  $count++;	$count = sprintf($pad, $count);  print LOG
> "$url<td>$count</td></tr>\n";  }  elsif ($count == 0 && substr($line,0,8) eq
> "</table>") {  $count++;  $count = sprintf($pad, $count);  print LOG
> "$url<td>$count</td></tr>\n";  print LOG "$line";  }  else { print LOG
> "$line"; } } flock (LOG,8); close(LOG);
> 
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

-- 
Aart Koelewijn                |  Linux 2.0.36
E-mail: aart@mtack.xs4all.nl  |  my newsserver kills all
http://www.xs4all.nl/~mtack/  |  Content-Type: multipart/* messages


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

Date: 26 Mar 1999 19:21:49 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: cardinality of an associative array?
Message-Id: <7dgmod$j0a$1@client2.news.psi.net>

Sam Holden (sholden@pgrad.cs.usyd.edu.au) wrote on MMXXXIII September
MCMXCIII in <URL:news:slrn7flt4i.kih.sholden@pgrad.cs.usyd.edu.au>:
[] On 26 Mar 1999 02:22:21 GMT, Peter Bismuti <bismuti@cs.fsu.edu> wrote:
[] >
[] >In class the instructor got stuck on the issue of printing out
[] >an array:
[] >
[] >print "the array is ", @array;
[] >
[] >He could not get it to print out the array itself, just the
[] >cardinality.  When I tried it I could not reproduce it, I
[] >could only get the array itself and not the cardinality,
[] >what could explain this?  What is the rule for printing
[] >out the cardinalith of an arrah?
[] 
[] An array in a scalar context is the length of the array...
[] 'print "the array is ", scalar @array;' will print the length
[] of the array. There are many ways to get something into a scalar
[] context.

Yes. The instructor might have had:

   print "the array is ". @array;

which would put the @array in scalar context as well.

[] >He also tried it on associative arrays and got interesting
[] >someghing interesting, the output was what seemed to be the
[] >cardinality of the ass array, it looked something like:
[] >
[] >     3/8

And your instructor didn't tell you what it meant? Did you ask him/her?
If the instructor doesn't know the answer, and can't find it in the
manual (it's there plain and clear), consider asking your money back.
You're wasting time with such an instructor.

[] >I'd never even heard of this before. Again, can somebody explain 
[] >to me the rule when cardinality is printed out as opposed to the
[] >actual array itself?

scalar context. Look up the 'scalar' function in the manual for instance.
And arrays themselves of course.




Abigail
-- 
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


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

Date: Fri, 26 Mar 1999 20:02:50 GMT
From: Jamester76 <jdalldata@my-dejanews.com>
Subject: CGI/Perl help needed
Message-Id: <7dgp53$b64$1@nnrp1.dejanews.com>




Hello

I need to run a perl program that does a system function from my web server.
The program will do a remote shell to another system, reset some processes,
then quit.

I have a perl program that works, but when I try to run it on the webserver,
it gives me a Malformed header message in the errorlog.

Here is a sample of what I am doing:
#!/usr/bin/perl
print "Content-type: text/html\r\n\r\n";
print '<TITLE>Directory listing of root directory</TITLE>';
print '<h1>Here is root listing</h1>';
$jamie = system 'rsh','remotehost','run-this-program.sh';
print "$jamie";


And here is the error log: [Fri Mar 26 09:45:15 1999] access to
/home/httpd/cgi-bin/directory-list.pl faile d for 10.206.44.30, reason:
malformed header from script. Bad header=total 496 [Fri Mar 26 09:50:29 1999]
access to /home/httpd/cgi-bin/directory-list.pl faile d for 10.206.44.30,
reason: malformed header from script. Bad header=total 496

I know there is a problem with the line $jamie = system, etc., etc. because
when I comment it out, the remainder works fine.  And the script runs manually
fine.  So, how do I accomplish this?

TIA

Jamie


+---------------------------------------
|  James A. (Jamie) Dennis
|
| "A waist is a terrible thing to mind"

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 26 Mar 1999 11:36:08 -0800
From: moseley@best.com (Bill Moseley)
Subject: Re: check to see if directory exists
Message-Id: <MPG.11658184ef61ba529896f9@206.184.139.132>

In article <36FBCD28.723197C5@chiso.com>, stephen@chiso.com says...
> I am trying to see if a directory exists on an NT machine, and am having
> some troubles.
> 
> Here is my test statement:
> 
> if (!(-d "x:\\home\\$Name"))
>     print ("Need to create homedir for $Name");
> 
> this is not working though.....
> Any ideas?

Is that really your code.  What happens when you run it?
Do you get a syntax error?

BTW -- You don't need to use backslashes.


print "Need to create homedir for $Name"
    unless -d "x:/home/$Name";


-- 
Bill Moseley mailto:moseley@best.com


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

Date: Fri, 26 Mar 1999 15:32:23 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
Subject: Re: check to see if directory exists
Message-Id: <36FBEED7.D81E4767@giss.nasa.gov>

Bill Moseley wrote:
> 
> BTW -- You don't need to use backslashes.

<NOISE>

I think backslashes should be required on WinDOS
machines -- just so this facticule needn't be 
pointed out to every new Perler working on such
platforms.   ;^)

Or perhaps the WinDOS perl executable should be renamed
"perl_Oh_and_BTW_you_do_not_need_backslashes.exe"  ;^)

</NOISE>


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

Date: Fri, 26 Mar 1999 14:02:39 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Counter Digits
Message-Id: <linberg-2603991402390001@ltl1.literacy.upenn.edu>

In article <36fbd156.0@info.xpoint.at>, "Christian" <cb2001@hotmail.com> wrote:

> Hi
> 
> i programmed a counter in perl and now i want to show the hits on the page
> so the user know, i'm visitor (eg. 00102) i made 10 gif files each
> containing one digit.
> so can anyone please tell me how to yoin the digits from a counter together
> (on the fly).

You should bring your CGI question to the fine folks on
comp.infosystems.www.authoring.cgi, rather than cross-posting to five perl
groups, including the porters, who especially don't want to hear these
kinds of questions.

Followups set.

(I wish there were a way to set followups everywhere the poster posted
without actually contributing to the followup pollution.)

-- 
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>


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

Date: Fri, 26 Mar 1999 14:15:54 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: How do I use POST from an HTML form
Message-Id: <linberg-2603991415540001@ltl1.literacy.upenn.edu>

You want to use CGI.pm.

-- 
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>


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

Date: Fri, 26 Mar 1999 11:44:22 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How do you use a variable in an array name?
Message-Id: <MPG.1165836d77d32429897d7@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7dgdil$ke$1@nnrp1.dejanews.com> on Fri, 26 Mar 1999 16:45:12 
GMT, diane6683@my-dejanews.com <diane6683@my-dejanews.com> says...
> I've tried using the following bit of code in my parse_form subroutine, which
> doesn't work (due to the @p_o_$ponum):
> 
>         elsif ($name =~ /^p_o_/) {
>             if ($value ne '') {
>                 $ponum = (split(/_o_/,$name))[1];
>                 push ("@p_o_$ponum",$value);
>             }
>         }
> 
> I have 20 arrays, named @p_o_1 through @p_o_20, and I'm trying to avoid having
> to repeat the above code for each array.

Just to answer the symbolic-reference attempt:  The way to do it would be this:
  @{"p_o_$ponum"}

But, as Jerome O'Neil says in his response, one doesn't want to do it.

As the values are specified as 1 through 20, an array of array refs 
would be suitable:

  push @{$arrays[$ponum -1]}, $value;

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 26 Mar 1999 20:18:08 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: How do you use a variable in an array name?
Message-Id: <7dgq20$fb$1@info2.uah.edu>

Please read <URL:http://www.plover.com/~mjd/perl/varvarname.html>.

Greg
-- 
As I stood before the gates I realized that I never want to be as certain
about anything as were the people who built this place. 
    -- Rabbi Sheila Peltz, on her visit to Auschwitz


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

Date: Fri, 26 Mar 1999 12:06:42 -0700
From: Arne Jamtgaard <arnej@fc.hp.com>
To: Yannick Girard <yannick@royaume.com>
Subject: Re: my random doesn't return number!!
Message-Id: <36FBDAC2.1A22@fc.hp.com>

Yannick Girard wrote:

> Hi,
 
> I'm giving you my code of random generation ...
 
> CAn you tell me why it's doesn't return any number??
> -------------------------------------------------------
> srand();
> @keys = keys %hash;
> $rand_key = $keys[int rand @keys];
> $numero = $hash{$rand_key};
> --------------------------------------------------------
 
> Thanks i need a Urgent REsponse!

Sorry, Yanick, I can't tell you why it doesn't return a 
number.  It seems to work.

I had to add a line to init %hash, and another to print 
$numero, but other than that, the thing seems to work just 
fine...

If this is a subroutine, are you sure that the hash is scoped
correctly?

Arne


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

Date: Thu, 25 Mar 1999 13:33:23 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Need Help with Simple Program
Message-Id: <x3yr9qdv2q4.fsf@tigre.matrox.com>


Ophir Marko <ophir@saifun.com> writes:

> #! /local/perl/bin/perl -w
> $index=0;
> while(<>){
>  $i=0;
>  while ($i <= $#_){
>   ++$i;
>  }
> $index=$index+$#_+1;
> }
> $t=0;
> $a=123;
> open(FILE2, ">file");
> if ($index eq $a){
>  print FILE2 $index, "\n";
>  ++$t;
> }
> close(FILE2);
> 
> Please note that there are some relics of a previous script in here.
> Disregard them

Ok. What is your question?



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

Date: Fri, 26 Mar 1999 19:17:50 GMT
From: hilaryk8088@my-dejanews.com
Subject: newbie questions
Message-Id: <7dgmgi$8so$1@nnrp1.dejanews.com>

I have three questions

1) where can I get a copy of perl 5.003 2) how can I get the modules for them
and how do I configure them to run in perl ie, I have inherited some code
that refers to Local::Time, how can I install and configure this module so
that my script can use it. 3) I want to do a search for \t\n and replace it
with \n on a string ($string), can someone explain what is wrong with this
syntax.

$string=s/\t\n/\n/g

Thanks in advance

Hiilary

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 26 Mar 1999 14:56:05 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: hilaryk8088@my-dejanews.com
Subject: Re: newbie questions
Message-Id: <36FBE655.507EA27B@giss.nasa.gov>

[courtesy copy of post sent to cited author]

hilaryk8088@my-dejanews.com wrote:
> 
> I have three questions

hmm.  treating c.l.pl.misc as a magic lantern...

> 1) where can I get a copy of perl 5.003 

Unless you have code relying on bugs or features
peculiar to perl5.003, then perl5.00502 (the current
stable release) should work fine for you.  The
phrase "require 5.003;" means 5.003 _or_better_.

check out http://language.perl.com/info/software.html

2) how can I get the modules for them
> and how do I configure them to run in perl ie, I have inherited some code
> that refers to Local::Time, how can I install and configure this module so
> that my script can use it. 

you mean "Time::Local", right?  That's part of the
standard Perl distribution: it comes bundled with
perl5.00502.

3) I want to do a search for \t\n and replace it
> with \n on a string ($string), can someone explain what is wrong with this
> syntax.
> 
> $string=s/\t\n/\n/g

the syntax is fine, and it does what you mean (but
maybe not what you want?):

my $s = "hi\t\nhello\t\nbiz";
$s =~ s/\t\n/\n/g;  # "$s" is now "hi\nhello\nbiz"

	Jay Glascoe
-- 
"'C' is for 'Cookie'.  That's good enough for me."
  --Cookie Monster


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

Date: 26 Mar 1999 20:10:10 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: newbie questions
Message-Id: <36fbe9a2$0$211@nntp1.ba.best.com>

hilaryk8088@my-dejanews.com wrote:
> I have three questions

> 1) where can I get a copy of perl 5.003

Well, I'm pretty sure you can get historical versions going back at
least a little ways from CPAN, but I suspect you may actually be
interested in getting the latest stable version. If so, you could check
out the following address:

http://www.perl.com/pace/pub/perldocs/latest.html

> 2) how can I get the modules for them
> and how do I configure them to run in perl ie, I have inherited some code
> that refers to Local::Time, how can I install and configure this module so
> that my script can use it.

I don't think there is a Local::Time module. There's a localtime
function, and a Time::Local module; the latter is included in the
standard Perl distribution, so you shouldn't have to install and
configure it unless you've got an old/wacky Perl installation.

You can check out CPAN for modules not included in the standard
distribution, for example by starting at:

http://www.perl.com/

and browsing the CPAN links.

 3) I want to do a search for \t\n and replace it
> with \n on a string ($string), can someone explain what is wrong with this
> syntax.

> $string=s/\t\n/\n/g

Sure. This is patented Perl Newbie Mistake #4: using an assignment
operator ( = ) instead of a tie operator ( =~ ). The correct form for
the above statement would be:

$string =~ s/\t\n/\n/g

I've only made that mistake, oh, about 276 times during my Perl
apprenticeship.

-- 
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: Fri, 26 Mar 1999 15:36:29 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: John Callender <jbc@shell2.la.best.com>
Subject: Re: newbie questions
Message-Id: <36FBEFCD.513187B1@giss.nasa.gov>

John Callender wrote:
> 
> > $string=s/\t\n/\n/g
> 
> Sure. This is patented Perl Newbie Mistake #4: using an assignment
> operator ( = ) instead of a tie operator ( =~ ).

<snip>

oops... I totally missed that!  But, I still maintain
that it's a syntactically valid statement.  :-P

	Jay Glascoe


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

Date: Fri, 26 Mar 1999 10:27:47 -0800
From: pault12@postoffice.pacbell.net
Subject: Re: Perl and Databases on NT. Which module to use
Message-Id: <36FBD1A3.16966625@postoffice.pacbell.net>

> Hi folks,
>
> Just after some quick advice.
>
> I have Perl/Apache running on NT and am currently using Win32::ODBC to
> connect to an Oracle database. Is this the best module to use or should
> I be using something else such as DBI/DBD::Oracle.
>
> My Perl scripts only peform Select/Update commands and I am currently
> achieving 0.28 secs connection times using Microsoft's Oracle ODBC
> driver. The SQL commands peform at similiar speeds in other applications
> such as SQL*Plus.
>
> I suppose my real concern is how this system will perform under multiple
> concurrent connections (10-20 users).
>

6-8 months ago I played  with some perl / DBI becnhmarks.
I used some trivial select / update statements changing the number
of records in the table e t.c. As I remember, accessing some table
with DBD:Oracle on NT was significantly faster than accessing
the same Oracle table using DBD:ODBC.  I was using ODBC
driver from Oracle. Unfortunately, all that materials now gone
with the wind, so I can't recall the exact numbers...  as far as I
remember it was like 10-20% or so.  I think that it is _always_
better to use DBD:Oracle with Oracle. It is realy good DBD.

Rgds.Paul.

> Thanks in advance for your help
>
> Tony Stallan
> Clearview Systems Inc.

--

 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
   Email: paul@qub.com     o Perl Application Server
   http:  www.pault.com    o XML Tube
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=




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

Date: Fri, 26 Mar 1999 11:12:11 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Problem about REGULAR EXPRESSION
Message-Id: <36FBDC0B.250C8EFA@mail.cor.epa.gov>

Ryan Ngi wrote:
> There is $sentence= "aaabbbcccaaakkkdddeeeaaa";
> 
> I want to pull "bbbccc"  out of the sentence.
> i use $sentence=~m/aaa(\S*)aaa/;
> 
> the command will pull bbbcccaaakkkdddeee out
> but i want only bbbccc
> 
> please suggest an easy simple way to do it.

In Perl there are lots of simple ways to do it.
You'll want to read up on ways yourself, so
type 'perldoc perlre' at the command line to
get more info.

Your problem is that * is a greedy operator.  It
matches as far to the right as it can.  Luckily
for you, Perl has a remedy.  Try:
   $sentence =~ m/aaa(\w*?)aaa/; 
Then go read about the properties of something-?
as a regex.  You'll be glad you did.

David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 26 Mar 1999 20:01:14 GMT
From: stenew@my-dejanews.com
Subject: regexp on block of text
Message-Id: <7dgp22$b58$1@nnrp1.dejanews.com>

I have a file that has data in the following format:
======================Cut Here=========================
SET QUOTED_IDENTIFIER  ON    SET ANSI_NULLS  ON
GO

Create Procedure AccessedByINS
      @FolderID as INT,
      @AccessedByID as INT,
      @Body as VARCHAR(255),
      @CreatedBy as INT

As
	INSERT INTO AccessedByINS (FolderID, AccessedByID, Body, CreatedBy,
ChangedBy)
	VALUES(@FolderID, @AccessedByID, @Body, @CreatedBy, @CreatedBy)

	return


GO
====================Cut Here========================

I am trying to get it to look like this:
==================Begin Output====================
/*
AccessedByINS
      @FolderID as INT,
      @AccessedByID as INT,
      @CreatedBy as INT

*/

int InsPD::AccessedByINS()
{
	RETCODE ret;

	if((ret = dbInit("AccessedByINS")) != SUCCEED)
		return ret;
        dbPushParam("@FolderID", INT);
        dbPushParam("@AccessedByID", INT);
        dbPushParam("@CreatedBy", INT);

	return dbExec();
}

===================End Output===================

The script I am using is this:

################### Begin Perl Script #######################
#! d:\perl\bin\perl.exe

# open input file
# open output file
# search input file for create statements and output them to output file

my($inFileName, $outFileName) = @ARGV;

my($funcName, $argument, $type);

open(INFILE, "$inFileName") || die "Unable to open $inFileName: $!\n";
open(OUTFILE, ">$outFileName") || die "Unable to create $outFileName: $!\n";

sub FuncHeader()
{
    my ($FILE, $func)  = @_;

    print $FILE "int InsPD::$func()\n";
    print $FILE "{\n\tRETCODE ret;\n\n\tif((ret = dbInit(\"$funcName\")) !=
SUCCEED)\n\t\treturn ret;\n";
}


sub FuncBody()
{
    my($FILE, $arg, $type) = @_;

    print $FILE "\tdbPushParam(\"$arg\", $type);\n";
}

sub FuncEnd() {
    my($FILE) = @_;

    print $FILE "\treturn dbExec();\n\n}\n\n";
}

$/ = '';

LOOP: while ( <> ) {
    if ( /Create Procedure (.*?)      \n/sm ) { # /s makes . cross line
boundaries
        print OUTFILE "\/*\n$1\n*\/\n\n";

        $string = $1;

        for ($string) {
            /^(\w+)/    && do {
                ($funcName) = split(/ /);
                chomp($funcName);
                &FuncHeader(*OUTFILE, $funcName);
                next;
                };
            /\@/         && do {
                ($argument, $as, $type) = split(/ /);
                &FuncBody(*OUTFILE, $argument, $type);
                next;
                };
        }

        &FuncEnd(*OUTFILE);

        next LOOP;
    }
}
###################### End Perl Script #######################

The problem is with the for loop.  I can get the first line out of $string,
but I can't seem to get it to loop over string, and process each succeeding
line. For example: Using this data, when I get to the for loop, $string looks
like:  DB<2> p $string AccessedByINS  @FolderID as INT,  @AccessedByID as
INT,  @CreatedBy as INT

I am able to get the AccessedByINS, but not all the parameters.  What am I not
understanding?

Thanks,

Steve Newell

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 26 Mar 1999 15:40:18 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: "Patrice M.I. Parmentier" <ppa@itmasters.com>
Subject: Re: Sorry to be angry, but i do not know what is wrong.
Message-Id: <m3lngkj87h.fsf@joshua.panix.com>

"Patrice M.I. Parmentier" <ppa@itmasters.com> writes:

> $pid = open (HPIPE, "| buggything") or die "Cannot pipe buggything\n";

> The name specified is not recognized as an internal or external
> command, operable program or batch file.

The error message suggests that there is nothing called "buggything"
in your PATH.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Fri, 26 Mar 1999 19:16:22 GMT
From: Zinnie Jones <zephria1@hotmail.com>
Subject: Unprintable ASCII characters
Message-Id: <36FBDD38.89B86B88@hotmail.com>

Does anyone have a perl script that will scan a file and print out all
lines that have ascii characters that are "unprintable".  I think that
is
ascii values > 255.





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

Date: Fri, 26 Mar 1999 11:56:33 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Unprintable ASCII characters
Message-Id: <MPG.1165864b6119090b9897d8@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <36FBDD38.89B86B88@hotmail.com> on Fri, 26 Mar 1999 19:16:22 
GMT, Zinnie Jones <zephria1@hotmail.com> says...
> Does anyone have a perl script that will scan a file and print out all
> lines that have ascii characters that are "unprintable".  I think that
> is ascii values > 255.

ASCII is a seven-bit character set, so there are no ASCII values > 127, 
let alone 255.  To conform with the C-Standard definition of 'printable' 
using seven-bit ASCII (while accepting the newline that ends each line 
in the file), this will do:

  /[^\n -~]/ and print while <>;

To be explicit about the values,

  /[^\n\x20-\x7E]/ and print while <>;

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 26 Mar 1999 12:44:29 -0800
From: "J|rgen Exner" <juex@my-dejanews.com>
Subject: Re: Unprintable ASCII characters
Message-Id: <7dgrc9$n1h@news.dns.microsoft.com>

Zinnie Jones <zephria1@hotmail.com> wrote in message
news:36FBDD38.89B86B88@hotmail.com...
> Does anyone have a perl script that will scan a file and print out all
> lines that have ascii characters that are "unprintable".

Please explain what you mean with "unprintable". Do you conside a tab
unprintable, a line feed unprintable, a carriage return unprintable, an
escape unprintable, a German umlaut-u unprintable, ...?

> I think that is ascii values > 255.

There are no ASCII values >255, ACSII is limited to 7-bit, which is 127
'characters'.

jue
--
J|rgen Exner





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

Date: Fri, 26 Mar 1999 20:46:21 +0100
From: Mark Geza 19-68 <mark@sunserv.kfki.hu>
Subject: WebPDB Publication Database Engine
Message-Id: <36FBE40D.DBEF17E6@sunserv.kfki.hu>

Hi,

have a look at my WebPDB Publication Database Engine written in PERL

    http://www.phy.bme.hu/comp/webpdb/index.html

G.I.Mark (mark@sunserv.kfki.hu)




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

Date: Thu, 25 Mar 1999 13:56:11 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: WHY: open (HPIPE, "| notexistfile") or die "..."; DOES NOT DIE ???
Message-Id: <x3ypv5xv1o5.fsf@tigre.matrox.com>


"Patrice M.I. Parmentier" <ppa@itmasters.com> writes:

> 
> I want to open a pipe for writing to the stdin of a program:
> 
> open (HPIPE, "| xxxx") or die "...";
> 
> !!! The open never fails, even when xxxx does not exist !!!
> WHY???

I get:

Can't exec "xxx": No such file or directory at - line 1.

Notice that using open() for IPC actually uses fork() to spawn a child
process. Does your OS support fork()? If it does, the open() will not
fail, since the fork() didn't fail. But the exec() will fail.
You should also read some more docs. From perlipc:

     Be careful to check both the open() and the close() return
     values.  If you're writing to a pipe, you should also trap
     SIGPIPE.  Otherwise, think of what happens when you start up
     a pipe to a command that doesn't exist: the open() will in
     all likelihood succeed (it only reflects the fork()'s
     success), but then your output will fail--spectacularly.
     Perl can't know whether the command worked because your
     command is actually running in a separate process whose
     exec() might have failed.  Therefore, while readers of bogus
     commands return just a quick end of file, writers to bogus
     command will trigger a signal they'd better be prepared to
     handle.  Consider:
 
         open(FH, "|bogus");
         print FH "bang\n";
         close FH;


> In addition, i have the following problem:
> - I open a pipe with an existing xxxx program
> - I write to xxxx via HPIPE and i see that xxxx receive the piped data
> - I kill xxxx
> - The perl script still runs, no SIGPIPE signal is sent ; i can still
> write to the pipe... (where are sent the data???)

How do you kill your program?
Are you sure it is dead?

> GENERAL QUESTION:
> How to know when the pipe is broken???

Trap SIGPIPE.


HTH,
Ala



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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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