[18173] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 341 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 23 09:05:42 2001

Date: Fri, 23 Feb 2001 06:05:16 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <982937116-v10-i341@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 23 Feb 2001     Volume: 10 Number: 341

Today's topics:
    Re: Difficult Split Question (Christopher Burke)
    Re: Difficult Split Question (Gwyn Judd)
        file size <Per-fredrik.Pollnow@epk.ericsson.se>
    Re: file size <peb@bms.umist.ac.uk>
    Re: file size <peb@bms.umist.ac.uk>
    Re: file size <Per-fredrik.Pollnow@epk.ericsson.se>
    Re: file size <Per-fredrik.Pollnow@epk.ericsson.se>
        get vs. post (was Re: newbie question) egwong@netcom.com
    Re: get vs. post (was Re: newbie question) egwong@netcom.com
    Re: help with variables in my email (Anno Siegel)
    Re: help with variables in my email (Anno Siegel)
    Re: help with variables in my email (Abigail)
    Re: help with variables in my email (Anno Siegel)
    Re: Help: CGI Question: Can I display Loading page befo <somewhere@planet.earth>
        I have finished my homework: ForCron.pm (comments pleas <johnlin@chttl.com.tw>
    Re: Is a function/class library for processing of SMTP- lvirden@cas.org
        knifflige perl probleme ... <ahoehma@inatec.com>
        Modules problem. To stupid to understand? <lurvas@excite.com>
    Re: Newbie needs help <jonni@ifm.liu.se>
    Re: Newbie needs help <graham.wood@iona.com>
    Re: newbie question <laclac@global2000.net>
    Re: newbie question (Damian James)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 23 Feb 2001 07:35:42 GMT
From: craznar@hotmail.com (Christopher Burke)
Subject: Re: Difficult Split Question
Message-Id: <9051BD691craznar@130.102.2.1>

tjla@guvfybir.qlaqaf.bet (Gwyn Judd) wrote in 
<slrn99924m.7lf.tjla@thislove.dyndns.org>:

>I was shocked! How could Christopher Burke <craznar@hotmail.com>
>say such a terrible thing:
>
>>No - with quotes, you turn
>>x,y,"pqr,st",z into ('x','y','pqr,st','z')
>>
>>What I want is to turn
>>x,y,def(pqr,st),z into ('x','y','def(pqr,st)','z')
>>
>>A big enough difference to lose me in regex land...
>
>Well you should have tried to use the one in the FAQ first. Then when
>you failed, posting what you had done and mentioning that it was a
>variation on the one in the FAQ would have helped you avoid people
>saying "this is in the FAQ". Get it? :)
>

I tried my best, but people like you just have too much time to accuse. 
After the last time I got flamed, I spent several hours looking at docs, 
examples and the O'Reilly Perl book. I asked a couple of Perl gurus - they 
didn't know (one came up with an answer later).

So in short you get get fscked..


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

Date: Fri, 23 Feb 2001 10:46:46 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Difficult Split Question
Message-Id: <slrn99cfsk.m2s.tjla@thislove.dyndns.org>

I was shocked! How could Christopher Burke <craznar@hotmail.com>
say such a terrible thing:

>I tried my best, but people like you just have too much time to accuse. 
>After the last time I got flamed, I spent several hours looking at docs, 
>examples and the O'Reilly Perl book. I asked a couple of Perl gurus - they 
>didn't know (one came up with an answer later).
>
>So in short you get get fscked..

What is that sound? I do believe it is the sound of a million killfile
entries. You lose.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Time and tide wait for no man.


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

Date: Fri, 23 Feb 2001 14:25:34 +0100
From: "Per- Fredrik Pollnow" <Per-fredrik.Pollnow@epk.ericsson.se>
Subject: file size
Message-Id: <975nob$7e6$1@newstoo.ericsson.se>

Hi,

I was wondering and I have search the internet but find nothing about how to
see how big a file is in bytes. for an example I want to know how big my
passwd file is in /etc/. Any suggestions ?




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

Date: Fri, 23 Feb 2001 13:39:27 +0000
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: file size
Message-Id: <3A96680F.9B87442@bms.umist.ac.uk>

Per- Fredrik Pollnow wrote:
> I was wondering and I have search the internet but find nothing about how to
> see how big a file is in bytes. for an example I want to know how big my
> passwd file is in /etc/. Any suggestions ?

how about using the stat function?

perldoc -f stat

or page 224 in the camel.

Paul


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

Date: Fri, 23 Feb 2001 13:42:26 +0000
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: file size
Message-Id: <3A9668C2.98DF8A2E@bms.umist.ac.uk>

> Per- Fredrik Pollnow wrote:
> > I was wondering and I have search the internet but find nothing about how to
> > see how big a file is in bytes. for an example I want to know how big my
> > passwd file is in /etc/. Any suggestions ?
> 
> how about using the stat function?
> 
> perldoc -f stat
> 
> or page 224 in the camel.

If you're only interested in the file size then you can use the -s file
test operator which returns the size of the file in bytes.

e.g.  print -e "/etc/passwd";

Paul


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

Date: Fri, 23 Feb 2001 14:41:27 +0100
From: "Per- Fredrik Pollnow" <Per-fredrik.Pollnow@epk.ericsson.se>
Subject: Re: file size
Message-Id: <975om5$95p$1@newstoo.ericsson.se>

thanx..
"Paul Boardman" <peb@bms.umist.ac.uk> wrote in message
news:3A9668C2.98DF8A2E@bms.umist.ac.uk...
> > Per- Fredrik Pollnow wrote:
> > > I was wondering and I have search the internet but find nothing about
how to
> > > see how big a file is in bytes. for an example I want to know how big
my
> > > passwd file is in /etc/. Any suggestions ?
> >
> > how about using the stat function?
> >
> > perldoc -f stat
> >
> > or page 224 in the camel.
>
> If you're only interested in the file size then you can use the -s file
> test operator which returns the size of the file in bytes.
>
> e.g.  print -e "/etc/passwd";
>
> Paul




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

Date: Fri, 23 Feb 2001 14:44:22 +0100
From: "Per- Fredrik Pollnow" <Per-fredrik.Pollnow@epk.ericsson.se>
Subject: Re: file size
Message-Id: <975ork$9dq$1@newstoo.ericsson.se>


"Paul Boardman" <peb@bms.umist.ac.uk> wrote in message
news:3A96680F.9B87442@bms.umist.ac.uk...
> Per- Fredrik Pollnow wrote:
> > I was wondering and I have search the internet but find nothing about
how to
> > see how big a file is in bytes. for an example I want to know how big my
> > passwd file is in /etc/. Any suggestions ?
>
> how about using the stat function?
>
> perldoc -f stat
>
> or page 224 in the camel.
>
> Paul

Ahha there is a perldoc :) thanx...




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

Date: 23 Feb 2001 06:18:37 GMT
From: egwong@netcom.com
Subject: get vs. post (was Re: newbie question)
Message-Id: <974vbt$7ca4$2@newssvr05-en0.news.prodigy.com>

Joseph M. Suprenant <laclac@global2000.net> wrote:
> Thanks!
> but what do you see is wrong with my code, that is making my program to not
> work?

As Damian said, your problem is that you're not using CGI.pm.  For
god's sake, please do use it and save yourself *a lot* of trouble
and heartache.  If it's too big for you, try something like CGI::Lite
instead.  Just about anything you'll ever want to do with CGI can
be done with CGI.pm.

Now, specifically, *your* script was trying to read $ENV{QUERY_STRING}
in a POST'ed html form.  Unfortunately for you $ENV{QUERY_STRING} refers
to the stuff after the '?' in the url, so you need to change method='POST'
to method='GET'.  Reading POST'ed data is somewhat more complicated.

As I said before, *please* use CGI.pm.  It'll make your life much easier.
If you want to roll your own, then at the very least, read through the
CGI specs at
  http://www.w3.org/CGI/

ERic

p.s. If you follow up, put the quoted text at the top and your own
     comments at the bottom.  Remember, not everyone has read the
     entire thread.


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

Date: 23 Feb 2001 07:13:29 GMT
From: egwong@netcom.com
Subject: Re: get vs. post (was Re: newbie question)
Message-Id: <9752ip$1fu8$1@newssvr05-en0.news.prodigy.com>

egwong@netcom.com wrote:
> Joseph M. Suprenant <laclac@global2000.net> wrote:
>> Thanks!
>> but what do you see is wrong with my code, that is making my program to not
>> work?
>
> Now, specifically, *your* script was trying to read $ENV{QUERY_STRING}
> in a POST'ed html form.  Unfortunately for you $ENV{QUERY_STRING} refers
> to the stuff after the '?' in the url, so you need to change method='POST'
> to method='GET'.  Reading POST'ed data is somewhat more complicated.

Well, this is technically correct, but it's not your problem.  Sorry about
that.  My fingers move faster than my brain.

The problem lies in your HTML,
 print"<input type=\"text\" name\"inc\" size=2 maxlength=3>";

should be
 print"<input type=\"text\" name=\"inc\" size=2 maxlength=3>";
                               ^^^

Okay, I've probably lost all credability now, but I still maintain that
using CGI.pm is for the best.

ERic (a little abashed)

p.s. Thanks to Damian James for pointing out my mistake!


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

Date: 23 Feb 2001 11:42:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: help with variables in my email
Message-Id: <975ib3$8c$1@mamenchi.zrz.TU-Berlin.DE>

You posted your reply above the quoted text.  Don't do that.
(Corrective surgery performed.)

According to Rick Meldrum  <richard.meldrum@fmr.com>:
> "John T." wrote:
>
> > I currently have a script that opens a text file then emails the content
> > of the text file line by line.  I would like to enter the current date
> > into the email.  I tried assigning the current date to a variable and
> > added the variable within the text file.  All I seem to get back is the
> > $variablename in the email.  What is it that I'm doing wrong?

[...]

> Perl does no automatic expansion of variables within variables. (It doesn't
> look for "$value" inside $_)
> Now if you're trying a simple  while(<>){ print}  loop,  try adding eval:
> 
> while (<TEXT_FILE>){
>     eval $_;

Yikes!  If you're lucky this will run into a syntax error before it burns
your house.  If anything, it's

      eval "qq($_)";

though even that can be destructive with a malicious TEXT_FILE.  It
will also fail when a line contains unbalanced parentheses.

>     print $_;
> }

If you give public advice, be sure you know what you are talking about.
The Text::Template module is designed to do this kind of thing.

Anno


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

Date: 23 Feb 2001 11:45:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: help with variables in my email
Message-Id: <975ig6$8c$2@mamenchi.zrz.TU-Berlin.DE>

According to Jon Ericson  <Jonathan.L.Ericson@jpl.nasa.gov>:
> "John T." <j2lab.nospam@my-deja.com> writes:
> 
> > I currently have a script that opens a text file then emails the content
> > of the text file line by line.  I would like to enter the current date
> > into the email.  I tried assigning the current date to a variable and
> > added the variable within the text file.  All I seem to get back is the
> > $variablename in the email.  What is it that I'm doing wrong?
> 
> Umm... eval? (See perldoc -f eval)
> 
>   $ perl -ne '$_ = eval $_;print "$_\n"'
>   $0
>   -e
>   $^O
>   cygwin
>   $]
>   5.006001

This is nonsense!  Refer to my reply to Rick Meldrum's posting who
gave similarly useless and dangerous advice.

Anno


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

Date: 23 Feb 2001 12:18:00 GMT
From: abigail@foad.org (Abigail)
Subject: Re: help with variables in my email
Message-Id: <slrn99cl7o.j9m.abigail@tsathoggua.rlyeh.net>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDCCXXXIII
September MCMXCIII in <URL:news:975ib3$8c$1@mamenchi.zrz.TU-Berlin.DE>:
`` You posted your reply above the quoted text.  Don't do that.
`` (Corrective surgery performed.)
`` 
`` According to Rick Meldrum  <richard.meldrum@fmr.com>:
`` > "John T." wrote:
`` >
`` > > I currently have a script that opens a text file then emails the content
`` > > of the text file line by line.  I would like to enter the current date
`` > > into the email.  I tried assigning the current date to a variable and
`` > > added the variable within the text file.  All I seem to get back is the
`` > > $variablename in the email.  What is it that I'm doing wrong?
`` 
`` [...]
`` 
`` > Perl does no automatic expansion of variables within variables. (It doesn't
`` > look for "$value" inside $_)
`` > Now if you're trying a simple  while(<>){ print}  loop,  try adding eval:
`` > 
`` > while (<TEXT_FILE>){
`` >     eval $_;
`` 
`` Yikes!  If you're lucky this will run into a syntax error before it burns
`` your house.  If anything, it's
`` 
``       eval "qq($_)";
`` 
`` though even that can be destructive with a malicious TEXT_FILE.  It
`` will also fail when a line contains unbalanced parentheses.

Well, yeah, but so can "use MODULE.pm" with a malicious module.

That's no reason to start any posting with a scary warning against
the use of use (or require, or do).



Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


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

Date: 23 Feb 2001 13:44:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: help with variables in my email
Message-Id: <975pfv$82h$2@mamenchi.zrz.TU-Berlin.DE>

According to Abigail <abigail@foad.org>:
> Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDCCXXXIII
> September MCMXCIII in <URL:news:975ib3$8c$1@mamenchi.zrz.TU-Berlin.DE>:
> `` According to Rick Meldrum  <richard.meldrum@fmr.com>:

[...]

> `` > Now if you're trying a simple  while(<>){ print}  loop,  try adding eval:
> `` > 
> `` > while (<TEXT_FILE>){
> `` >     eval $_;
> `` 
> `` Yikes!  If you're lucky this will run into a syntax error before it burns
> `` your house.  If anything, it's
> `` 
> ``       eval "qq($_)";
> `` 
> `` though even that can be destructive with a malicious TEXT_FILE.  It
> `` will also fail when a line contains unbalanced parentheses.
> 
> Well, yeah, but so can "use MODULE.pm" with a malicious module.
> 
> That's no reason to start any posting with a scary warning against
> the use of use (or require, or do).

Absolutely.  I just didn't want to leave the impression that my
suggestion was watertight, security-wise.

Anno


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

Date: Fri, 23 Feb 2001 14:31:30 +0100
From: "Dimitri Gunsing" <somewhere@planet.earth>
Subject: Re: Help: CGI Question: Can I display Loading page before the cgi exports all the data ?
Message-Id: <975on2$kir$1@omaha.pbnec.nl>

> 1. Can I display a "Loading Page" to tell user his request is being
processed untill the process's done,
> it will display the report page?

Yes, by using a DHTML script in a hidden frame. You can then turn the
message off via the first frame. I don't have the code but I know it's on
many DHTML sites. Have you tried www.dynamicdrive.com?


> 2. If I can NOT display the loading page, can I set up some kind of script
> to avoid the user sumbmit same request again and again when the first one
is being processed ?

Again yes, redirect your form output to a javascript function that disables
the submit button. I use the same trick.

First add OnSubmit to your FORM element like :
<form name="form" method="post" action="query.cgi" onsubmit="return
validate()">
 .....
</form>

Then the script :
 <script language="JavaScript1.2">
  <!--
   function validate() {
    << validation code here >>

    // and then the piece of code that you will need to disable the button
    if (document.all||document.getElementById){
     //screen thru every element in the form, and hunt down "submit" and
"reset"
     for (i=0;i<form.length;i++) {
      var tempobj=form.elements[i]

if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset"
) {
       //disable em
       tempobj.disabled=true
      }
     }
    }
    return true;
   }
   //-->
    </script>

I use it all the time and works fine. Only tested in explorer though. Don't
know if it works in NS.





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

Date: Fri, 23 Feb 2001 12:02:08 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: I have finished my homework: ForCron.pm (comments please)
Message-Id: <974neq$5bu@netnews.hinet.net>


Dear all,

With the help of comp.lang.per.misc
I finished the homework that I gave myself: ForCron.pm

The goals of this module are:

1. When run under cron, redirect outputs to program's .log file.
2. Avoid multiple running instances.
(Assume every program has a .conf file, flock on it,
and also provide a filehandle for program to read it.)

Synopsis (normal run - output to console):

hello.pl
hello, world

hello.pl
another hello.pl is running

Synopsis (used in cron - output to hello.log):

cat hello.cron
* * * * * hello.pl                 # this rely on -t
45 * * * * perl -s hello.pl -cron  # this is safer

cat hello.log
Fri Feb 23 11:42:00 2001
hello, world
Fri Feb 23 11:43:00 2001
hello, world
Fri Feb 23 11:44:00 2001
hello, world
Fri Feb 23 11:45:00 2001: in process  <-- re-entrance rejected
Fri Feb 23 11:45:00 2001
hello, world
Fri Feb 23 11:46:00 2001
hello, world
Fri Feb 23 11:47:00 2001
hello, world

Just a homework of myself, but I would like to have your comments.

Thank you very much.

John Lin


-------------------------------- hello.pl
#!/usr/bin/perl
use ForCron;
print <ForCron::INI>;
sleep 20;

-------------------------------- hello.conf
hello, world

-------------------------------- ForCron.pm
package ForCron;
use strict;
use Fcntl ':flock';
use File::Basename;

my($file,$dir,$ext) = fileparse($0,qr/\..*/);
my $logfile = "$dir/$file.log";
my $inifile = "$dir/$file.".($^O eq 'MSWin32'? 'ini': 'conf');
if(not open INI,"+<$inifile") { warn "can't open $inifile\n"; exit }
my $lock = flock INI,LOCK_EX|LOCK_NB;
if($main::cron or !-t) {
    if(open STDOUT,">>$logfile") {
        open STDERR,">&STDOUT";
        print scalar localtime,$lock? '': ': in process',"\n";
    }
}
else { warn "another $file$ext is running\n" unless $lock }
exit unless $lock;

1





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

Date: 23 Feb 2001 12:08:43 GMT
From: lvirden@cas.org
Subject: Re: Is a function/class library for processing of SMTP-mails available?
Message-Id: <975jsb$16g$3@srv38.cas.org>


According to Cameron Laird <claird@starbase.neosoft.com>:
:you already have everything you need on your system; procmail
:<URL: http://starbase.neosoft.com/~claird/comp.mail.misc/procmail.html >
:is a widely-used special-purpose filter for just such situations
:as yours appears to be.  It has, in particular, the capability
:to select messages based on sender and subject.

and a horridly designed language;  UGGG!

I've used mailagent in the past - that uses perl scripts for the filtering
(which is a little easier to bear).


A tcl option is the personal.tcl mailbot at
<URL: http://www.purl.org/NET/akupries/soft/mail/> .

I suspect there are others.

Certainly if you don't need to have anything more than one expert in
house who sets things up and clearly documents what they have done, with
no need of future changes, procmail is an option.

However, if you have need for non-technical users to daily make changes,
etc. to the filtering, I would fear for my job if I suggested procmail...

-- 
-- 
"See, he's not just anyone ... he's my son."  Mark Schultz
<URL: mailto:lvirden@cas.org> <URL: http://www.purl.org/NET/lvirden/>
Even if explicitly stated to the contrary, nothing in this posting


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

Date: Fri, 23 Feb 2001 14:54:39 +0100
From: "Andreas Höhmann" <ahoehma@inatec.com>
Subject: knifflige perl probleme ...
Message-Id: <975q2v$n720p$1@ID-25523.news.dfncis.de>

$rErrors =

                    key1 => { subkey1=>1, subkey2=>2 },
                    key2 => { subkey2=>4 }
                 };

for $testkey ( 'key1', 'key2', 'key3' )
{
        print "before : " , %$rErrors , "\n";

        if ( exists $rErrors->{$testkey}->{'subkey1'} )
        {
                print "subkey 1 existiert.\n";
        }

        print "after  : " , %$rErrors , "\n";
}

erzeugt folgende ausgabe : --->

before : key1HASH(0x80fe3c0)key2HASH(0x8109888)
subkey 1 existiert.
after    : key1HASH(0x80fe3c0)key2HASH(0x8109888)
before : key1HASH(0x80fe3c0)key2HASH(0x8109888)
after    : key1HASH(0x80fe3c0)key2HASH(0x8109888)
before : key1HASH(0x80fe3c0)key2HASH(0x8109888)
after    : key1HASH(0x80fe3c0)key2HASH(0x8109888)key3HASH(0x8109a5c)

wiso wird beim letzen testfall ein neuer key in den hash eingefügt ?!?
wiso steigt perl nicht aus, wo es doch ein undef dereferenzieren will ?!?

effekt tritt unter windows ( intershopperl ) und linux ( perl 5.6 ) auf.

cu andreas




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

Date: Fri, 23 Feb 2001 12:50:21 +0100
From: Lurviga Ben <lurvas@excite.com>
Subject: Modules problem. To stupid to understand?
Message-Id: <lurvas-832E91.12502123022001@news.umu.se>

I've tried looking in 'Programming Perl' and the FAQs but it seems that 
I'm to stupid to understand what I'm doing wrong.

So I would like to ask two things:

1  What am I doing wrong in the code below?

2  Where can I find an explaination of the content of the BEGIN
   block? I've tried reading 'Programming Perl' 3:ed and the
   perlmod page but I still doesn't get it.

Note: I'm using MacPerl which is based on 5.004.


Below are four files, when I do a syntax check on the content of 
'news.pl' I get the following error messages:

File "Dokument:Scripts:Perl:JEM:Util.pm"; Line 16:  Subroutine 
formatDate redefined.
File "Dokument:Scripts:Perl:JEM:Util.pm"; Line 20:  Subroutine 
formatTime redefined.
File "Dokument:Scripts:Perl:JEM:Util.pm"; Line 24:  Subroutine trim 
redefined.

But I can't figure out why I get this. I assume I'm doing some basic 
error ...

I would be grateful for a pointer where to look.

                  jem

--- file news.pl
#! perl -w

use strict;

use JEM::Info::PairParse;

--- file PairParse.pm
package JEM::Info::PairParse;
use strict;

BEGIN{
   use Exporter   ();
   use vars    qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
   $VERSION    = 0.1;
   @ISA        = qw(Exporter);
   @EXPORT     = qw(&parse);
   %EXPORT_TAGS   = ();
   @EXPORT_OK     = ();
}

use vars @EXPORT_OK;

use JEM::Error;
use JEM::Util;

sub parse {
   # content deleted
}

1;
--- file Error.pm
package JEM::Error;
use strict;

BEGIN{
   use Exporter   ();
   use vars    qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
   $VERSION    = 0.1;
   @ISA        = qw(Exporter);
   @EXPORT     = qw(&logFatalError &logWarning);
   %EXPORT_TAGS   = ();
   @EXPORT_OK     = ();
}
use vars @EXPORT_OK;

use Jem::Util;

sub logFatalError {
   # content deleted
}

sub logWarning {
   # content deleted
}

1;
--- file Util.pm
package JEM::Util;
use strict;

BEGIN{
   use Exporter   ();
   use vars    qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
   $VERSION    = 0.1;
   @ISA        = qw(Exporter);
   @EXPORT     = qw(&formatDate &formatTime &trim);
   %EXPORT_TAGS   = ();
   @EXPORT_OK     = ();
}

use vars @EXPORT_OK;

sub formatDate{
   # content deleted
}

sub formatTime{
   # content deleted
}

sub trim {
   # content deleted
}
1;

-- 
Lurviga Ben
lurvas@excite.com


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

Date: Fri, 23 Feb 2001 13:42:32 +0100
From: "Jonas Nilsson" <jonni@ifm.liu.se>
Subject: Re: Newbie needs help
Message-Id: <975lpi$r7m$1@newsy.ifm.liu.se>

> My test script works fine on its own when I run the script directly from
> the console of the unix box (BSD) but when I try and run the same code
> as a function, it does not respond with an error or a decent output, I
> can tell its gone into the function but nothing more.

If the problems arises when you run the program as a cgi-script, this is
what you're missing:

print "Content-type: text/html\n\n";

This is the first line(s) the webbrowser needs to know that the following
output is html (or text).
/jN


--
 _____________________     _____________________
|   Jonas Nilsson     |   |                     |
|Linkoping University |   |      Telephone      |
|       IFM           |   |      ---------      |
| Dept. of Chemistry  |   | work: +46-13-285690 |
|  581 83 Linkoping   |   | fax:  +46-13-281399 |
|      Sweden         |   | home: +46-13-130294 |
|_____________________|   |_____________________|




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

Date: Fri, 23 Feb 2001 11:02:13 -0000
From: "Graham Wood" <graham.wood@iona.com>
Subject: Re: Newbie needs help
Message-Id: <975geq$e4s$1@spider.iona.com>

> My test script works fine on its own when I run the script directly from
> the console of the unix box (BSD) but when I try and run the same code
> as a function, it does not respond with an error or a decent output, I
> can tell its gone into the function but nothing more.
>
> the code is:
>
> sub file_move {
>             $Config{'recipient'}="mememei";
>             #print "cp /home/sushil
> /www/cgi-bin/ma/formmail/aliases.txt";
>             system "cp -f /home/dmog/aliases /www/cgi-bin/ma/formmail";
>
>
> }
You can get Perl to give you some assistance.  This might tell you
something:
             system "cp -f /home/dmog/aliases /www/cgi-bin/ma/formmail" ||
                print "Couldn't run cp command because $!\n";
$! contains the last error message printed by the system. The message will
be printed out if the system call fails for some reason.

Graham Wood




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

Date: Fri, 23 Feb 2001 05:47:25 GMT
From: "Joseph M. Suprenant" <laclac@global2000.net>
Subject: Re: newbie question
Message-Id: <3A9600A4.93319E21@global2000.net>

Thanks!
but what do you see is wrong with my code, that is making my program to not
work?

Damian James wrote:

> Thus spake Joseph M. Suprenant on Fri, 23 Feb 2001 03:44:56 GMT:
> >Hi I am trying to learn perl
>
> Lots of luck! The best resources for learning about Perl features are the
> documents that come with Perl itself, and should be installed on your
> machine. If you're running some sort of *nix, these can be accessed via the
> man program, or through a utility called perldoc, which will have been
> installed with perl (if you're stuck on windows, perldoc is your only
> hope). If you type 'perldoc perltoc' at your shell prompt, you will see a
> list of the documents available. If you don't like reading stuff in this
> format, there is also a pod2html utility.
>
> >...
> >
> >The following is my code:
> >#!/usr/bin/perl
> >##
>
> You should really use the -w command line switch (or the 'warnings' pragma
> under perl 5.6.0), and the 'strict' pragma.
>
> use warnings;
> use strict;
>
> >
> >read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> >...
> >        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> >
>
> You will really be saving yourself a lot of bother if you use the CGI
> module, which comes with the standard Perl distribution (and has done for a
> long time), rather than implementing your own CGI parsing code. Below is a
> short program that does what you were trying to do, using the CGI module.
>
> #!/usr/bin/perl -w
> use strict;
>
> use CGI;
>
> my $cgi = CGI->new();
> print $cgi->header,
>       $cgi->start_html;
>
> if ($cgi->param()) {
>     print $cgi->dump()
> }
> else {
>     # Your fill-out form
>     # printing code should
>     # go here. Do check the
>     # methods provided by
>     # CGI for generating
>     # the markup for this.
>     print "test";
> };
> print $cgi->end_html;
> __END__
>
> One other thing I noticed in your code -- you were finding it necessary to
> escape a lot of '"'s. You should read 'perldoc perlop' and go over the
> section on perl's "Quote and Quotelike Operators", which you should find
> saves you a bit of hassle there.
>
> HTH,
> Cheers,
> Damian
> --
> #!/usr/bin/perl -w
> use strict;$|=1;$:=79;for $; (split//,<DATA>){print" "x($:-$_),
> $;,"\x"x600,"\b"x($:-$_+1)for 0..--$:;print$;}; __END__
> Just another Perl Hacker



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

Date: 23 Feb 2001 06:36:08 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: newbie question
Message-Id: <slrn99c15i.r21.damian@puma.qimr.edu.au>

Thus spake Joseph M. Suprenant on Fri, 23 Feb 2001 05:47:25 GMT:
>Thanks!

Joseph - here are some points to consider if you are going to get on in the
newgroup here:

	1. Do not top-post (commonly referred to here as 'jeopardy style'
	posting. It is a convention in this group to intersperse your post
	such that your reply follows the test to which it is referring.

	2. I forgot to point out earlier, but most posts where the subject line
	does not contain a description of the problem do not get answered. 

	See:

	http://perl.plover.com/Questions.html

>but what do you see is wrong with my code, that is making my program to not
>work?
>

I'm afraid I didn't look, so I didn't see. The first thing I noticed was,
as I pointed out, that you had not enabled warnings, or the strict pragma.
I guess I should have pointed out that these options will find many
bugs for you. When you post a question here, people often won't answer at
all if you haven't tried with these. It ammounts to asking a person to do
what your computer could do for you. This is considered rude.

Further, I have shown you a different way to do this, anticipating that you
will run into more problems if you continue the way you are going. 

In any case, I believe the problem in your code, apart from that you had
not enabled warnings or the strict pragma (a lack of which will lead many
people here to assume the code is broken and read no further), and apart
from not using the CGI module, which again, is a major problem in a program
that is dealing with CGI, had to do with the conditional at the end of your
parse-loop. I strongly urge you to use the CGI module for this, but it
looks like your hash of form values would not get populated:

if ($hash{blah} eq "") {...

under 'use strict' and -w will give an error message something like "Use of
uninitialised value in string equals". You should look at the perldata manual
(type 'perldoc perldata' at the command prompt) under hashes, and also try
'perldoc -f exists', to find out exactly what to do in a test like the one here.

That said, you really want to be using the CGI module to do this. Try
typing 'perldoc CGI' at the command line.

HTH
Cheers,
Damian
-- 
#!/usr/bin/perl -w
use strict;$|=1;$:=79;for $; (split//,<DATA>){print" "x($:-$_),
$;,"\x"x600,"\b"x($:-$_+1)for 0..--$:;print$;}; __END__
Just another Perl Hacker 


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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 341
**************************************


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