[18687] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 855 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 8 14:08:07 2001

Date: Tue, 8 May 2001 11:05:15 -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: <989345114-v10-i855@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 8 May 2001     Volume: 10 Number: 855

Today's topics:
    Re: Base 6 sieve. (Anno Siegel)
        CGI::Cookie problem <bcoon@sequenom.com>
        Connecting to SQL Server through ODBC using Perl <anonymous@anonymous.anonymous>
        Connecting to SQL Server through ODBC using Perl <anonymous@anonymous.anonymous>
        difference of arrays ?? <sfarris9@home.com>
    Re: difference of arrays ?? (Anno Siegel)
    Re: difference of arrays ?? (Logan Shaw)
    Re: difference of arrays ?? <ren@tivoli.com>
    Re: difference of arrays ?? nobull@mail.com
    Re: difference of arrays ?? (Anno Siegel)
    Re: Disguising Perl scripts <wsegrave@mindspring.com>
    Re: file manipulations <ren@tivoli.com>
    Re: Get back errors from calling command line? <danparker276@yahoo.com>
    Re: Help on optimization wanted <ren@tivoli.com>
        hex to binary <MrEye@reply_to_group.hate_spam.com>
    Re: hex to binary (Peter J. Acklam)
    Re: hex to binary <ren@tivoli.com>
    Re: How can you tell which modules are loaded? <todd@designsouth.net>
    Re: How can you tell which modules are loaded? nobull@mail.com
    Re: How can you tell which modules are loaded? (Logan Shaw)
        Invoking Perl script from a web page <peter@dollshouse.com>
    Re: Invoking Perl script from a web page <todd@designsouth.net>
        Javascript within perl <mikegray@charter.net>
    Re: Newbie: how can I shorten a repetitive regular expr <mischief@velma.motion.net>
    Re: PL/SQL and DBI. <todd@designsouth.net>
        Price for work? <bcoon@sequenom.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 8 May 2001 17:44:29 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Base 6 sieve.
Message-Id: <9d9b9t$jbu$1@mamenchi.zrz.TU-Berlin.DE>

According to Abigail <abigail@foad.org>:
> 
> As Anno pointed out yesterday, a sieve based on a base 6 numbering
> system uses less memory. Here's an implementation, which is hopefully
> reasonable efficient.

[code reluctantly snipped]

That's very pretty.

While my original impulse was to go to higher bases (than the original
10) and use as many primes as possible, somewhere on a bus today it
dawned on me too that a small base might be the ticket.  Well, the
remaining small base, 6.

Your scrub routine is highly optimized.  I had expected having to
do something complicated before the loop to get in sync.  The idea
of establishing a preliminary limit to get some complications out of
the middle rounds is new to me and noteworthy.  Also noteworthy is
the tasteful use of a bare block to align the final lines with the
corresponding ones inside the loop.

You are one of the few programmers who don't only have a distinctive
personal style, but a whole range of such, one for each occasion.
This is clearly one not of the more jocular programs.  I is also, if
I'm not very wrong, written with the idea in mind that it could be
the prototype for a seriously fast prime generator written in C or
assembler.

Anno


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

Date: Tue, 08 May 2001 10:01:41 -0700
From: Bryan Coon <bcoon@sequenom.com>
Subject: CGI::Cookie problem
Message-Id: <3AF82675.B84F4DF8@sequenom.com>

I am writing my own mysql-perl based user authentication script, which
works great with one exception.  Once the user successfully logs in, the
next page they see is not behaving properly.

The order of events for that returning page in the cgi are:
1. Header printed with cookie
2. Start html printed
3. A check for the cookie is made
4. Something is printed, based on the results of that check.
5. End html is printed.

The problem is with 3 and 4.  The user logs in successfully, but on the
returning page, the cookie is not seen.  If the user clicks on any link,
or anything that reloads that page, then the checks work fine.

Thanks!

Here is some of the code below:

sub writeCookie {
  my ($login, $password) = @_;

  my $level = verifyDB($login, $password);     # Verifys in mysql
username and pass, returns user level (silver, gold, etc.)
  if ($level ne "" && $login ne "") {
    my $c = new CGI::Cookie(-name => "Oreo",
                            -value => [$login,$level],
                            -path => '/');
    pageStart("Login Successful!", "", "", $c);   # pageStart simply
prints header(), start_html(), and some site specific style,
javascripts, layouts
                                                                 #
pageStart(title_string, javascript, onLoad (or click or whatever),
cookie)
    navBar();                                                # Generic
navigation bar
    indexPage();                                            # Generic
html
    pageEnd();
  } elsif ($level eq "" && $login ne "") {
    print redirect("$cgibin/login.cgi");
  } else {
    my $c = new CGI::Cookie(-name => "Oreo",  # Same error occurs during
logout
                            -value => [$login,$level],
                            -path => '/');
    pageStart("Logged Out", "", "", $c);
    navBar();
    indexPage();
    pageEnd();
  }
}




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

Date: Tue, 8 May 2001 11:22:37 -0500
From: Anonymous <anonymous@anonymous.anonymous>
Subject: Connecting to SQL Server through ODBC using Perl
Message-Id: <3af81f65_3@anonymous>

I am having a problem connecting to SQL Server. I have been using perl to
connect through ODBC to an MS Access database and everything was working
fine. Now I am plugging in a new ODBC connection to a SQL Server and I get
an error. I am hoping I am just making a syntax error.

The error I receive is:

Can't call method "Sql" on an undefined value at
c:\inetpub\wwwroot\ivm\test.pl line 10.

The code I am using is:

#!/usr/local/bin/perl

use Win32::ODBC;

$dsn = "SQL_IMS_LOCAL";

$sql = "SELECT * FROM profiles WHERE emp_number=8908;";

$db = new Win32::ODBC($dsn);

$db->Sql($sql);

($ErrNum, $ErrText, $ErrConn) = $db->Error();

if ($ErrNum) {

&printErrorHeader;

}

print <<ENDTEST;

Content type: text/html\n\n

<html>

<head><title>Test</title>

</head>

<body>

<table>

<tr>

<td>

ENDTEST


$db->FetchRow();

( $emp_number, $name, $password, $mas_loc, $email ) = $db->Data(
"emp_number", "name", "password", "mas_loc", "email" );

print "$emp_number, $name, $password, $mas_loc, $email<br>";

$db->Close();


print <<ENDTEST;

<br><br>test

</td>

</tr>

</table>

</body>

</html>

ENDTEST




  --------== Posted Anonymously via Newsfeeds.Com ==-------
     Featuring the worlds only Anonymous Usenet Server
    -----------== http://www.newsfeeds.com ==----------


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

Date: Tue, 8 May 2001 11:42:13 -0500
From: Anonymous <anonymous@anonymous.anonymous>
Subject: Connecting to SQL Server through ODBC using Perl
Message-Id: <3af82170_2@anonymous>

I am having a problem connecting to SQL Server. I have been using perl to
connect through ODBC to an MS Access database and everything was working
fine. Now I am plugging in a new ODBC connection to a SQL Server and I get
an error. I am hoping I am just making a syntax error.

The error I receive is:

Can't call method "Sql" on an undefined value at
c:\inetpub\wwwroot\ivm\test.pl line 10.

The code I am using is:

#!/usr/local/bin/perl

use Win32::ODBC;

$dsn = "SQL_IMS_LOCAL";

$sql = "SELECT * FROM profiles WHERE emp_number=8908;";

$db = new Win32::ODBC($dsn);

$db->Sql($sql);

($ErrNum, $ErrText, $ErrConn) = $db->Error();

if ($ErrNum) {

&printErrorHeader;

}

print <<ENDTEST;

Content type: text/html\n\n

<html>

<head><title>Test</title>

</head>

<body>

<table>

<tr>

<td>

ENDTEST


$db->FetchRow();

( $emp_number, $name, $password, $mas_loc, $email ) = $db->Data(
"emp_number", "name", "password", "mas_loc", "email" );

print "$emp_number, $name, $password, $mas_loc, $email<br>";

$db->Close();


print <<ENDTEST;

<br><br>test

</td>

</tr>

</table>

</body>

</html>

ENDTEST




  --------== Posted Anonymously via Newsfeeds.Com ==-------
     Featuring the worlds only Anonymous Usenet Server
    -----------== http://www.newsfeeds.com ==----------


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

Date: Tue, 08 May 2001 16:32:20 GMT
From: steve farris <sfarris9@home.com>
Subject: difference of arrays ??
Message-Id: <3AF81F04.5B1F9402@home.com>

Anybody know a one liner to get the difference of two arrays?

e.g.

@a = qw/one two three/;
@b = qw/one three/;

@a - @b = ("two")



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

Date: 8 May 2001 16:39:45 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: difference of arrays ??
Message-Id: <9d97gh$gph$1@mamenchi.zrz.TU-Berlin.DE>

According to steve farris  <sfarris9@home.com>:
> Anybody know a one liner to get the difference of two arrays?
> 
> e.g.
> 
> @a = qw/one two three/;
> @b = qw/one three/;
> 
> @a - @b = ("two")

That's a FAQ, and "perldoc -q difference" would have taken you there.
Please check the FAQ before posting.

Anno


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

Date: 8 May 2001 12:10:08 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: difference of arrays ??
Message-Id: <9d999g$gm4$1@boomer.cs.utexas.edu>

In article <9d97gh$gph$1@mamenchi.zrz.TU-Berlin.DE>,
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>According to steve farris  <sfarris9@home.com>:
>> Anybody know a one liner to get the difference of two arrays?
>> 
>> e.g.
>> 
>> @a = qw/one two three/;
>> @b = qw/one three/;
>> 
>> @a - @b = ("two")
>
>That's a FAQ, and "perldoc -q difference" would have taken you there.

Not exactly.  The question was whether anyone knows a one-liner, and
the answer in the FAQ is 7 lines.

Also, the FAQ answers a slightly different question than what I think
the original poster was asking.  The FAQ tells how to find elements
that are in one but not both.  Based on the notation used, it seems the
question was how to find those in @a but not @b.  That is, the set the
poster desires is the intersection of @a and the set that the FAQ's
answer delivers.

To put it another way, if I understood the question right, then if you
have this:

	@a = qw/one two three/;
	@b = qw/one three four/;

then, @a - @b should be qw/two/ and @b - @a should be qw/four/ ,
whereas the FAQ says the answer it would give is qw/two four/ .

Anyway, one possible one-liner is this:

	@a_minus_b = grep { my $x = $_ ; not grep ($x eq $_, @b) } @a;

Not the prettiest or the most efficient, but it is one line.

  - Logan
-- 
my  your   his  her   our   their   _its_
I'm you're he's she's we're they're _it's_


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

Date: 08 May 2001 11:47:15 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: difference of arrays ??
Message-Id: <m3u22vhjos.fsf@dhcp9-172.support.tivoli.com>

On Tue, 08 May 2001, sfarris9@home.com wrote:

> Anybody know a one liner to get the difference of two arrays?

See the FAQ: "How do I compute the difference of two arrays?  How do I
compute the intersection of two arrays?"

Normally, you can find this by typing something like:

perldoc -q "difference"

In this case, several FAQs are found, so something more specific such
as:

perldoc -q "difference.*arrays"

-- 
Ren Maddox
ren@tivoli.com


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

Date: 08 May 2001 18:11:32 +0100
From: nobull@mail.com
Subject: Re: difference of arrays ??
Message-Id: <u94ruvn4u3.fsf@wcl-l.bham.ac.uk>

steve farris <sfarris9@home.com> writes:

> Anybody know a one liner to get the difference of two arrays?

Anybody read the FAQ?

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


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

Date: 8 May 2001 17:58:02 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: difference of arrays ??
Message-Id: <9d9c3a$jbu$2@mamenchi.zrz.TU-Berlin.DE>

According to Logan Shaw <logan@cs.utexas.edu>:
> In article <9d97gh$gph$1@mamenchi.zrz.TU-Berlin.DE>,
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> >According to steve farris  <sfarris9@home.com>:
> >> Anybody know a one liner to get the difference of two arrays?
> >> 
> >> e.g.
> >> 
> >> @a = qw/one two three/;
> >> @b = qw/one three/;
> >> 
> >> @a - @b = ("two")
> >
> >That's a FAQ, and "perldoc -q difference" would have taken you there.
> 
> Not exactly.  The question was whether anyone knows a one-liner, and
> the answer in the FAQ is 7 lines.

[good answer snipped]

You mean I should *read* the question before replying?  What next?

Anno


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

Date: Tue, 8 May 2001 10:45:16 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Disguising Perl scripts
Message-Id: <9d94v8$17j$2@slb7.atl.mindspring.net>

"jimbo" <jimbo@soundimages.co.uk> wrote in message
news:3hPJ6.8673$4A4.37620@NewsReader...
> > _fixes_ your program but makes it totally unrecogizable!  Yeesh, any of
> you
> > born in the south!?
>
> Where's the south?
>

Just because we talk slowly does mean we think slowly. ;-)

The answer to your question is that University of Alabama is located in the
"south" to which you alluded. ;-)

War Eagle! Now let's get back OT.

Bill Segraves
Auburn, AL




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

Date: 08 May 2001 11:15:03 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: file manipulations
Message-Id: <m33dafizqw.fsf@dhcp9-172.support.tivoli.com>

On Tue, 8 May 2001, giles.pepper@brunel.ac.uk wrote:

> I have a directory (linux) with a hundred or so files.  Some of
> these filenames contain spaces which I want to remove.  Can anyone
> give me a clue as to how I would use a perl script to go through the
> directory and check and rename if neccessary the file.  I have used
> a bit of perl for other things but have not had experience of this
> sort of thing.  Any help appreciated.  Regards

Way back in 1990, Larry Wall wrote a Perl "rename" script for just
this type of situation.  I'm not exactly sure where the best place to
get that script is, but it's only 104 lines (with the old-style
built-in nroff man page included), so I'll just include it here:

===== cut here =====
#!/usr/local/bin/perl
'di';
'ig00';
#
# $Header: rename,v 4.0 91/03/20 01:11:53 lwall Locked $
#
# $Log:	rename,v $
# Revision 4.0  91/03/20  01:11:53  lwall
# 4.0 baseline.
# 
# Revision 3.0.1.2  90/08/09  03:17:57  lwall
# patch19: added man page for relink and rename
# 

($op = shift) || die "Usage: rename perlexpr [filenames]\n";
if (!@ARGV) {
    @ARGV = <STDIN>;
    chop(@ARGV);
}

%seen=();
foreach (@ARGV) {
    $was = $_;
    eval $op;
    die $@ if $@;
    if ($seen{ $_ }) {
	print STDERR "$was and $seen{$_} would both rename to $_.\n";
	exit(-1);
    }
    $seen{ $_ } = $was;
    $_ = $was;			# Undo the change for the next pass.
}

for (@ARGV) {
    $was = $_;
    eval $op;
    die $@ if $@;
    if ($was eq $_) {
	print STDOUT "$was unchanged.\n";
    } else {
	print STDOUT "$was -> $_\n";
	rename($was,$_);
	if ($!) {
	    die ("Error while renaming: $!");
	}
    }
}
##############################################################################

	# These next few lines are legal in both Perl and nroff.

 .00;			# finish .ig
 
'di			\" finish diversion--previous line must be blank
 .nr nl 0-1		\" fake up transition to first page again
 .nr % 0			\" start at page 1
';<<'.ex'; #__END__ ############# From here on it's a standard manual page ############
 .TH RENAME 1 "July 30, 1990"
 .AT 3
 .SH NAME
rename \- renames multiple files
 .SH SYNOPSIS
 .B rename perlexpr [files]
 .SH DESCRIPTION
 .I Rename
renames the filenames supplied according to the rule specified as the
first argument.
The argument is a Perl expression which is expected to modify the $_
string in Perl for at least some of the filenames specified.
If a given filename is not modified by the expression, it will not be
renamed.
If no filenames are given on the command line, filenames will be read
via standard input.
 .PP
For example, to rename all files matching *.bak to strip the extension,
you might say
 .nf

	rename 's/\e.bak$//' *.bak

 .fi
To translate uppercase names to lower, you'd use
 .nf

	rename 'y/A-Z/a-z/' *

 .fi
 .SH ENVIRONMENT
No environment variables are used.
 .SH FILES
 .SH AUTHOR
Larry Wall
 .SH "SEE ALSO"
mv(1)
 .br
perl(1)
 .SH DIAGNOSTICS
If you give an invalid Perl expression you'll get a syntax error.
 .SH BUGS
 .I Rename
does not check for the existence of target filenames, so use with care.
 .ex
===== cut here =====

-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 8 May 2001 10:34:06 -0700
From: "Krusty" <danparker276@yahoo.com>
Subject: Re: Get back errors from calling command line?
Message-Id: <X7WJ6.195$IJ1.42391@news.pacbell.net>

Thanks, the 2>&1 works for errors like if is spell the plink command wrong,
but plink errors, like 'connection refused' don't show up, I guess they are
not part of standard error?  Any suggestions, to get that output?  I'll look
at the plink docs.



"Mark Jason Dominus" <mjd@plover.com> wrote in message
news:3af7f966.abb$47@news.op.net...
> In article <gqIJ6.1302$B13.169795@news.pacbell.net>,
> Krusty <danparker276@yahoo.com> wrote:
> >my script goes like
> >$cmd = "plink -ssh me@255.0.0.0 dir"; #orwhat ever
> >open (FH, "$cmd |");
> >while (<FH>){
> >#never gets in here on an error message like 'can't connect to server'
> >}
> >
> >How can I get it to display the error messages as well as the out put?
>
> Try
>
>         open (FH, "$cmd 2>&1 |");
>
> A different strategy is:
>
>         while (<FH>) {
>           ...
>         }
>         close FH;               # this sets $?
>         if ($? != 0) {
>           warn "plink did not succeed";
>         }
>
>
> --
> @P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub
p{
>
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^or
d
> ($p{$_})&6];$p{$_}=/
^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
> close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep
rand(2)if/\S/;print
>




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

Date: 08 May 2001 10:37:25 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Help on optimization wanted
Message-Id: <m3bsp3j1hm.fsf@dhcp9-172.support.tivoli.com>

On 8 May 2001, iltzu@sci.invalid wrote:

> Note that if you try to use a list repeat in scalar context, you end
> up tickling a bug in current perls:
> 
>     print join "_", scalar((1, 2, 3) x 4);   # prints: "1_2_3333"

This is probably already well-known, but I found it interesting:

  print join "_", $x = scalar((1, 2, 3) x 4);  # prints: "1_2_3333"
  print $x                                     # prints: "3333"

I guess this means that the nature of the bug is that the intermediate
arguments to the comma operator get left on the stack and then the
next list operator to come along (in that statement) gets them.

What happens if there is no such list operator?  That is, do these
items get automatically cleared off the stack at the end of the
statement?

Also, it only seems to be a problem with the comma operator:

  @a = qw/a b c/;
  print join "_", scalar((@a) x 4);            # prints: "3333"
  print join "_", scalar((@{[1, 2, 3]}) x 4);  # prints: "3333"
  print join "_", scalar((@a[0, 1, 2]) x 4);   # prints: "cccc"

I suppose it's not very surprising that an array doesn't exhibit the
behavior, but that a slice also doesn't even though the semantics of a
slice parallel that of the comma operator seems slightly more
surprising.

Also,

  print join "_", scalar((do{1,2,3}) x 4);     # prints: "3333"

so insulating the comma operator inside a do{} avoids the bug, and,

  print join "_", scalar(((1,2,3),4)x4);       # prints: "3_4444"

the bug does not propagate to the arguments of the comma operator.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 8 May 2001 12:03:13 -0400
From: "MrEye" <MrEye@reply_to_group.hate_spam.com>
Subject: hex to binary
Message-Id: <9d959b$8kb$1@trsvr.tr.unisys.com>

How do we convert a binary into hex? Here is the statement I have used

$HEXITS = sprintf "%b", (oct (join "", "0x", $HEXITS));

The output instead becomes '%b' rather than a binary number.




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

Date: 08 May 2001 18:25:04 +0200
From: jacklam@math.uio.no (Peter J. Acklam)
Subject: Re: hex to binary
Message-Id: <cxcy9s7st9b.fsf@masterblaster.uio.no>

"MrEye" <MrEye@reply_to_group.hate_spam.com> writes:

> How do we convert a binary into hex? Here is the statement I have used
> 
> $HEXITS = sprintf "%b", (oct (join "", "0x", $HEXITS));
> 
> The output instead becomes '%b' rather than a binary number.

Either of these should do the trick

  $out = unpack('B32', pack('N', hex $in));
  $out = sprintf '%b', hex $in;

Peter

-- 
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;


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

Date: 08 May 2001 11:34:42 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: hex to binary
Message-Id: <m3y9s7hk9p.fsf@dhcp9-172.support.tivoli.com>

On Tue, 8 May 2001, MrEye@reply_to_group.hate_spam.com wrote:

> How do we convert a binary into hex? Here is the statement I have
> used

You mean hex to binary?

> $HEXITS = sprintf "%b", (oct (join "", "0x", $HEXITS));
> 
> The output instead becomes '%b' rather than a binary number.

I believe "%b" was added in 5.6, so perhaps you're running an older
Perl than that?

-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 08 May 2001 16:39:13 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: Re: How can you tell which modules are loaded?
Message-Id: <RiVJ6.78273$U4.17311490@news1.rdc1.tn.home.com>

"Lou Moran" <lmoran@wtsg.com> wrote in message
news:5j2gftk8p7f1g75g1up16e3r7b52vd6632@4ax.com...
> --Say I sit at diff't boxes with diff't OSes but they all have Perl.
>
> --How can I tell which modules are loaded?

Maybe write a little script to dive into each directory in @INC and spit out
files that end with ".pm"? But I think there's a way to have perl tell you.
I can't remember right now.

--
-todd




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

Date: 08 May 2001 17:41:55 +0100
From: nobull@mail.com
Subject: Re: How can you tell which modules are loaded?
Message-Id: <u98zk7n67g.fsf@wcl-l.bham.ac.uk>

Lou Moran <lmoran@wtsg.com> writes:

> --Say I sit at diff't boxes with diff't OSes but they all have Perl.  
> 
> --How can I tell which modules are loaded?

The list of _loaded_ modules is keys(%INC).

I suspect you mean the list of installed modules.

perldoc perllocal

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


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

Date: 8 May 2001 12:19:54 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: How can you tell which modules are loaded?
Message-Id: <9d99rq$gnf$1@boomer.cs.utexas.edu>

In article <u98zk7n67g.fsf@wcl-l.bham.ac.uk>,  <nobull@mail.com> wrote:
>Lou Moran <lmoran@wtsg.com> writes:
>> --How can I tell which modules are loaded?
>
>I suspect you mean the list of installed modules.
>
>perldoc perllocal

Or, if you want an answer from within Perl:

	perl -MExtUtils::Installed -le \
		'print join ("\n", ExtUtils::Installed->new()->modules());'

"perldoc ExtUtils::Installed" will tell you more.

  - Logan
-- 
my  your   his  her   our   their   _its_
I'm you're he's she's we're they're _it's_


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

Date: Tue, 8 May 2001 17:36:33 +0100
From: "Peter Lowndes" <peter@dollshouse.com>
Subject: Invoking Perl script from a web page
Message-Id: <tfg807akgp0le7@xo.supernews.co.uk>

I have written a perl script to log details about visitors to my company's
web site. I would like to insert a call to this script at the top of each of
the pages but don't know how to just call the script as a simple command in
html or javascript. As a work around I am using the IMG tag to call the perl
script but it generates errors in the site's transfer log because the script
doesn't actually return an image. Is there an easy way to return an image
(one pixel will do) or another syntax that calls the script without
expecting anything back?

At the moment I have something like this in the html header

<script>
<!--
var x
 ..... some javascript to put data into x ....
file://-->
</script>

and then this in the body

<script>
<!--
document.write('<IMG WIDTH=1 HEIGHT=1 SRC="/cgi-bin/script99.pl?'+x+'">')
file://-->
</script>





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

Date: Tue, 08 May 2001 17:01:55 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: Re: Invoking Perl script from a web page
Message-Id: <7EVJ6.78339$U4.17324990@news1.rdc1.tn.home.com>

"Peter Lowndes" <peter@dollshouse.com> wrote in message
news:tfg807akgp0le7@xo.supernews.co.uk...
> I have written a perl script to log details about visitors to my company's
> web site. I would like to insert a call to this script at the top of each
of
> the pages but don't know how to just call the script as a simple command
in
> html or javascript. As a work around I am using the IMG tag to call the
perl
> script but it generates errors in the site's transfer log because the
script
> doesn't actually return an image. Is there an easy way to return an image
> (one pixel will do) or another syntax that calls the script without
> expecting anything back?

yeah, try one of these in your html:

<!--#exec cgi="script.cgi"-->
    or
<!--#exec cmd="/path/script.cgi"-->

-todd




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

Date: Tue, 8 May 2001 12:36:07 -0400
From: "MikeG" <mikegray@charter.net>
Subject: Javascript within perl
Message-Id: <tfg8c8nndpqu0f@corp.supernews.com>

Is it possible to use JavaScript within Perl?
Im trying to make a HTML editor and want to alert the user if they are about
to overwrite an existing file.
Below is the code, if I can't use this within the script can someone please
suggest an example of perl code that I could use to get the same effect?

function conf() {
if (confirm("File exists, overwrite?") )

{
parent.location='http://www.mydomain.com/savechanges.cgi';
}

else
{
alert('File has not been overwriten');
 }
}
</SCRIPT>




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

Date: Tue, 08 May 2001 15:58:48 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Newbie: how can I shorten a repetitive regular expression?
Message-Id: <tfg5to7heqhm29@corp.supernews.com>

John W. Krahn <krahnj@acm.org> wrote:
> David Wake wrote:
>> 
>> It seems as if there must be some way of shortening code like this.
>> Can anyone help?
>> 
>>     if ( m{CONTACT\sINFORMATION\s+
>>                   Name:\s+
>>                   (\w[\w\s]+?)\s+     #name
>>                   City:\s+
>>                   (\w[\w\s]+?)\s+     #city
>>                   State:\s+
>>                   (\w[\w\s]+?)\s+     #state
>>                   Zip\sCode:\s+
>>                   (\w[\w\s]+?)\s+     #zip
>>                   }sx ){
>>     print "Name = $1 \n" ;
>>     print "City = $2 \n" ;
>>     print "State = $3 \n" ;
>>     print "Zip = $4 \n" ;
>> }

>     if ( /CONTACT\sINFORMATION\s+
>                   Name:\s+
>                   (\S.*\S)\s+     #name
>                   City:\s+
>                   (\S.*\S)\s+     #city
>                   State:\s+
>                   (\S.*\S)\s+     #state
>                   Zip\sCode:\s+
>                   (\S.*\S)\s+     #zip
>                   /x ){


Still not nearly as short as it could be.

      my $re = qr/\s+(\S.*\S)\s+/;
      if (/CONTACT\sINFORMATION\s+
                   Name:$re       #name
                   City:$re       #city
                   State:$re      #state
                   Zip\sCode:$re  #zip
                   /x 

If you know that those things are in that order, though,
as you must based on the fact that they are in order in
the original regex, and you are sure you'll never see
colons in the rest of the contact information section
of your input...

     my $re = qr/\s+(\S.*\S)\s+/;
     /CONTACT\sINFORMATION\s+
         :$re  #name
         :$re  #city
         :$re  #state
         :$re  #zip
     /x

If you want something which at least resembles a label...

     my $lbl = qr/\S.*\S:/;
     my $re = qr/\s+(\S.*\S)\s+/;
     /CONTACT\sINFORMATION\s+
         $lbl$re  #name
         $lbl$re  #city
         $lbl$re  #state
         $lbl$re  #zip
     /x

Or even...

    my $re = qr/\S.*\S:\s+(\S.*\S)\s+/;
    /CONTACT\sINFORMATION\s+
        $re  #name
        $re  #city
        $re  #state
        $re  #sip
    /x


Chris

-- 
Try not. Do, or do not. The Force is binary. -- Yoda,
The Empire Strikes Back (paraphrased)



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

Date: Tue, 08 May 2001 16:32:08 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: Re: PL/SQL and DBI.
Message-Id: <ccVJ6.78248$U4.17308472@news1.rdc1.tn.home.com>


"Paul Kersey" <mk@ticklets.com> wrote in message
news:9d8b0c$dk5$1@news1.xs4all.nl...
> > > Does anybody have experience on using DBI with
> > > oracle Pl/SQL?Please give me an example. What should I do if I want to
> > pass
> > > in one variable to PL/SQL and get a returned recordset?
> > > Thanks!
> >
> > Isn't the whole point of DBI (Independant) that the database doesn't
> matter?
> > Or did I miss the point of the question?
>
> Yes you did,


Oh, my bad.

-todd




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

Date: Tue, 08 May 2001 09:28:53 -0700
From: Bryan Coon <bcoon@sequenom.com>
Subject: Price for work?
Message-Id: <3AF81EC4.EF841C65@sequenom.com>

Sorry for the repeat post, I am having some problems viewing my own
posts from different machines (same news server tho??).

Anyways, I have been asked to do some freelance work for a local company
here in San Diego, and am trying to get some sort of ballpark idea how
much to charge them.

The job involves some website tweaking (uploading files, creating new
directories, etc) which should only take about an hour (at most).  They
also want some modifications made to an existing htaccess/htpasswd
management software package, which should take 4-5 hours (roughly).  All
told, to be very cautious with my time lets just say 1 work day (8
hours).

I have been programming perl for about a year, and programmed in other
languages (proprietary) for 2 years before that.  But everything was for
the company I worked for, so I dont really have a fair idea what is
reasonable on the open market.

I hear stories about people charging like 50k to host and create some
cheesy static pages.  I hear that programmers are quite expensive.

Does anyone have any input on this?  Maybe some quotes for similar work,
or maybe a link to some sites?  Any info is helpful!

Thanks!
Bryan



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 855
**************************************


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