[22860] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5081 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 6 00:06:14 2003

Date: Thu, 5 Jun 2003 21:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 5 Jun 2003     Volume: 10 Number: 5081

Today's topics:
    Re: and if I killed this programmer *I'd* go to jail.. <jkeen@concentric.net>
    Re: and if I killed this programmer *I'd* go to jail.. <mbudash@sonic.net>
    Re: and if I killed this programmer *I'd* go to jail.. <bobx@linuxmail.org>
    Re: and if I killed this programmer *I'd* go to jail.. (Jay Tilton)
    Re: Changing form output (Ralph Snart)
    Re: DMake (newbie) (Daniel L Newhouse)
        Extracting data from a database and storing it. <thepotplants@yahoo.com>
    Re: Extracting data from a database and storing it. <mbudash@sonic.net>
    Re: Extracting data from a database and storing it. <thepotplants@yahoo.com>
    Re: Extracting data from a database and storing it. <mbudash@sonic.net>
    Re: Extracting data from a database and storing it. <thepotplants@yahoo.com>
    Re: Extracting data from a database and storing it. <thepotplants@yahoo.com>
    Re: Extracting data from a database and storing it. <mbudash@sonic.net>
    Re: formatted STDERR of an child process (Charles DeRykus)
    Re: Passthru and UNC path <bwalton@rochester.rr.com>
    Re: Push adding space to start of items <krahnj@acm.org>
    Re: sends email from the Windows machine (@|)
        switches to stop errant one-liner at first warning <jidanni@jidanni.org>
    Re: switches to stop errant one-liner at first warning (Jay Tilton)
    Re: switches to stop errant one-liner at first warning <skuo@mtwhitney.nsc.com>
    Re: switches to stop errant one-liner at first warning <skuo@mtwhitney.nsc.com>
    Re: switches to stop errant one-liner at first warning (Tad McClellan)
    Re: Upload without cgi.pm or cgi-lib <usenet@expires082003.tinita.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 06 Jun 2003 00:37:21 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: and if I killed this programmer *I'd* go to jail..
Message-Id: <bbono1$ars@dispatch.concentric.net>


"Sara" <genericax@hotmail.com> wrote in message
news:776e0325.0306050958.319bfc19@posting.google.com...
> This is one of the less ugly examples what I've inherited from my
> "ancestral" programmers here. I think he must have had a C-to-Perl
> script he ran to produce his Perl Code..
>
> 805:       for($i=0;$i<=$#g_INFO;$i++){
> 806:          if($g_INFO[$i][$x_ID] ne $id){  next; }
> 807:          @tmp1 = split(/;/,$g_INFO[$i][$_TEXT]);
> 808:          for($j=0;$j<=$#tmp1;$j++){
> 809:             $tmp1[$j] =~ s/^(\s)*//g;
> 810:             @tmp2 = split(/,/,$tmp1[$j]);
> 811:             if($tmp2[0] == $level){  return "$tmp2[1]";     }
>

C-style for loops; lack of whitespace for readability .... What's not to
like?




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

Date: Fri, 06 Jun 2003 00:44:08 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: and if I killed this programmer *I'd* go to jail..
Message-Id: <mbudash-23B469.17440705062003@typhoon.sonic.net>

"Sara" <genericax@hotmail.com> wrote in message
news:776e0325.0306050958.319bfc19@posting.google.com...
> This is one of the less ugly examples what I've inherited from my
> "ancestral" programmers here. I think he must have had a C-to-Perl
> script he ran to produce his Perl Code..
>
> 805:       for($i=0;$i<=$#g_INFO;$i++){
> 806:          if($g_INFO[$i][$x_ID] ne $id){  next; }
> 807:          @tmp1 = split(/;/,$g_INFO[$i][$_TEXT]);
> 808:          for($j=0;$j<=$#tmp1;$j++){
> 809:             $tmp1[$j] =~ s/^(\s)*//g;
> 810:             @tmp2 = split(/,/,$tmp1[$j]);
> 811:             if($tmp2[0] == $level){  return "$tmp2[1]";     }
>

hey! i WROTE that code!

now, er, let's see, what does it do again?... %^/

-- 
Michael Budash


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

Date: Fri, 06 Jun 2003 01:19:49 GMT
From: "Bob X" <bobx@linuxmail.org>
Subject: Re: and if I killed this programmer *I'd* go to jail..
Message-Id: <V_RDa.3918$xM5.2521874@news2.news.adelphia.net>

I hope you slap him and SLAP HIM HARD!




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

Date: Fri, 06 Jun 2003 01:35:25 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: and if I killed this programmer *I'd* go to jail..
Message-Id: <3edfeed0.182482916@news.erols.com>

genericax@hotmail.com (Sara) wrote:

: This is one of the less ugly examples what I've inherited from my
: "ancestral" programmers here.

Awful stuff.

Do the uglier portions simply cause temporary blindness, or do they
have raw killing power?



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

Date: Thu, 05 Jun 2003 23:30:36 GMT
From: snart@nospam.com (Ralph Snart)
Subject: Re: Changing form output
Message-Id: <slrnbdvkmb.12ch.snart@cluttered.com>

On 5 Jun 2003 11:15:44 -0700, Steve <techadmin@shaw.ca> wrote:
>format, right now we receive the data like this,
>  
> Client= ABC enterprises
>  
> is there a way to present it in the following format,
>  
> Client                         ABC Enterprises

yes that change would be trivial.

>I understand that changes need to be made to the code beloew but all
>the books I have read do not give me the know how to make the
>appropriate changes. Please comment all changes and additions, thanks.

the code that you pasted has nothing to do with formatting the message,
it merely sends it.  (and badly, at that.)

>I am using STMP maail, 

you should use a module.  how about Net::SMTP, the documentation for
which can be found here:

  http://www.perldoc.com/perl5.8.0/lib/Net/SMTP.html

to format your message, you may want to start with something along
these lines:

use CGI ':cgi';

for (param()) {
   print "$_=" . param($_) . "\n";
}

that gives you the output that you didn't want.  changing it should
be easy.

-rs-


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

Date: 5 Jun 2003 15:34:28 -0700
From: daniel_newhouse@earthlink.net (Daniel L Newhouse)
Subject: Re: DMake (newbie)
Message-Id: <a338abd3.0306051434.792959e0@posting.google.com>

"Randy Kobes" <randy@theoryx5.uwinnipeg.ca> wrote in message news:<%UeBa.22991$NC4.107303@news1.mts.net>...
> 
> Is it nmake that has problems with command.com, or certain
> things that Perl assumes are possible (like STDERR redirection
> via a 2>&1 syntax) that give problems? If it's the latter, then I think
> it's easier to fix a few things in Perl (generally in ExtUtils::MakeMaker
> and friends) that do these things, rather than trying to get dmake
> to work with VC++.
> 
> best regards,
> randy kobes

The only thing addressing the reason for the incompatibility I have
seen is the following line from readme.win32:

The nmake Makefile also has known incompatibilities with the
"command.com" shell that comes with Windows 9x.  You will need to
use dmake and makefile.mk to build under Windows 9x.

I have learned that the patch does not need to be run for DMake to
work, it was included only as a reference.  Besides that the only
thing specific to Visual C++ I have seen in DMake is the OSEnvironment
variable, and I am not sure what I should set that to.


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

Date: Fri, 6 Jun 2003 11:46:37 +1200
From: "ThePotPlants" <thepotplants@yahoo.com>
Subject: Extracting data from a database and storing it.
Message-Id: <yDQDa.11861$JA5.247587@news.xtra.co.nz>

Hi all.

I'm writing an App which extracts data from a database and stores in text
files.
So far it connects, selects and writes @rows to a file. But there are no
delimiters.

I want to reinsert the data into a table later, so I need delimeters (lots
of null fields) and ideally a header

What would be the best way to do this? I'm considering datadumper and using
a "|" as my field delimeter.

Anyone got any better ideas? (is there some magic tool i don't know about?)

Thanks.

Pete




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

Date: Thu, 05 Jun 2003 23:58:34 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Extracting data from a database and storing it.
Message-Id: <mbudash-2F4EE8.16583405062003@typhoon.sonic.net>

In article <yDQDa.11861$JA5.247587@news.xtra.co.nz>,
 "ThePotPlants" <thepotplants@yahoo.com> wrote:

> Hi all.
> 
> I'm writing an App which extracts data from a database and stores in text
> files.
> So far it connects, selects and writes @rows to a file. But there are no
> delimiters.
> 
> I want to reinsert the data into a table later, so I need delimeters (lots
> of null fields) and ideally a header
> 
> What would be the best way to do this? I'm considering datadumper and using
> a "|" as my field delimeter.
> 
> Anyone got any better ideas? (is there some magic tool i don't know about?)
> 
> Thanks.
> 
> Pete
> 
> 

let's see the code that writes to the text file... prolly as easy as:

join '|', @data;

-- 
Michael Budash


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

Date: Fri, 6 Jun 2003 12:44:43 +1200
From: "ThePotPlants" <thepotplants@yahoo.com>
Subject: Re: Extracting data from a database and storing it.
Message-Id: <2uRDa.11936$JA5.247546@news.xtra.co.nz>

##sub called using: current directory and tablename
   &extract_tab($curr_dir, $tab)

sub extract_tab

    open OUTFILE, ">$curr_dir/$tab.ctl"; # open file to write to.
    print "=> Getting $tab \n" ;

    my  $sth = $dbh->prepare( "SELECT * FROM $tab" )
        or die "Can't prepare SQL statement: $DBI::errstr\n";

    $sth->execute
        or die "Can't execute SQL statement: $DBI::errstr\n";

    while ( my @row = $sth->fetchrow_array() ) {
        print OUTFILE "@row\n";
    }

    warn "Problem in fetchrow_array(): ", $sth->errstr(), "\n"
    if $sth->err();

    close OUTFILE;
    return 1;
}





"Michael Budash" <mbudash@sonic.net> wrote in message
news:mbudash-2F4EE8.16583405062003@typhoon.sonic.net...
> In article <yDQDa.11861$JA5.247587@news.xtra.co.nz>,
>  "ThePotPlants" <thepotplants@yahoo.com> wrote:
>
> > Hi all.
> >
> > I'm writing an App which extracts data from a database and stores in
text
> > files.
> > So far it connects, selects and writes @rows to a file. But there are no
> > delimiters.
> >
> > I want to reinsert the data into a table later, so I need delimeters
(lots
> > of null fields) and ideally a header
> >
> > What would be the best way to do this? I'm considering datadumper and
using
> > a "|" as my field delimeter.
> >
> > Anyone got any better ideas? (is there some magic tool i don't know
about?)
> >
> > Thanks.
> >
> > Pete
> >
> >
>
> let's see the code that writes to the text file... prolly as easy as:
>
> join '|', @data;
>
> --
> Michael Budash




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

Date: Fri, 06 Jun 2003 00:50:13 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Extracting data from a database and storing it.
Message-Id: <mbudash-E72E4A.17501305062003@typhoon.sonic.net>

In article <2uRDa.11936$JA5.247546@news.xtra.co.nz>,
 "ThePotPlants" <thepotplants@yahoo.com> wrote:

> "Michael Budash" <mbudash@sonic.net> wrote in message
> news:mbudash-2F4EE8.16583405062003@typhoon.sonic.net...
>
> > In article <yDQDa.11861$JA5.247587@news.xtra.co.nz>,
> >  "ThePotPlants" <thepotplants@yahoo.com> wrote:
> >
> > > Hi all.
> > >
> > > I'm writing an App which extracts data from a database and stores 
> > > in text files. So far it connects, selects and writes @rows to a 
> > > file. But there are no delimiters.
> > >
> > > I want to reinsert the data into a table later, so I need 
> > > delimeters (lots of null fields) and ideally a header
> > >
> > > What would be the best way to do this? I'm considering datadumper 
> > > and using a "|" as my field delimeter.
> > >
> > > Anyone got any better ideas? (is there some magic tool i don't 
> > > know about?)
> > >
> >
> > let's see the code that writes to the text file... prolly as easy as:
> >
> > join '|', @data;
> >
>
> 
> [snip]
>
>     while ( my @row = $sth->fetchrow_array() ) {
>         print OUTFILE "@row\n";

print OUTFILE (join '|', @row), "\n";

>     }
>
> [snip]
>


hth -

-- 
Michael Budash


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

Date: Fri, 6 Jun 2003 12:58:48 +1200
From: "ThePotPlants" <thepotplants@yahoo.com>
Subject: Re: Extracting data from a database and storing it.
Message-Id: <cHRDa.11955$JA5.248801@news.xtra.co.nz>

what I'm wanting is:


BEGINDATA
19|19|HOME1|262|4|175|2|2|0|0|N|60|60|DEX|1|HPLMN Address 1|HPLMN Address
2|HPLMN xxx|HPLMN xxx|HPLMN xxx|26204|HPLMN Contact|0049 12345678||Home
Network|278|7|600|600|1995-JAN-01 00:00:00|1999-JAN-01 00:00:00|
21|21|TEST1|262|2|172|2|2|0|35|N|60|9999|TS1|2|TEST1 Address 1|TEST1 Address
2|TEST1 xxx|TEST1 xxx|TEST1 xxx|26202|TEST1 Contact|0049
87654321||TEST1|278|7|||1995-JAN-01 00:00:00|1999-JAN-01 00:00:00|
22|22|TEST2|240|8|199|2|2|0|35|Y|60|9999|TS2|2|TEST2 Address 1|TEST2 Address
2|TEST2 xxx|TEST2 xxx|TEST2 xxx|24008|TEST2 Contact|0046

what I've got now is:

7369 SMITH CLERK 7902 17-DEC-80 800  20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975  20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850  30

Because my app will connect to both Oracle and Sybase db's I want a generic
approach, to unload and reload.
I could write database specific sub  routines.. but i'd prefer to avoid it
if I can..


"Michael Budash" <mbudash@sonic.net> wrote in message
news:mbudash-2F4EE8.16583405062003@typhoon.sonic.net...
> In article <yDQDa.11861$JA5.247587@news.xtra.co.nz>,
>  "ThePotPlants" <thepotplants@yahoo.com> wrote:
>
> > Hi all.
> >
> > I'm writing an App which extracts data from a database and stores in
text
> > files.
> > So far it connects, selects and writes @rows to a file. But there are no
> > delimiters.
> >
> > I want to reinsert the data into a table later, so I need delimeters
(lots
> > of null fields) and ideally a header
> >
> > What would be the best way to do this? I'm considering datadumper and
using
> > a "|" as my field delimeter.
> >
> > Anyone got any better ideas? (is there some magic tool i don't know
about?)
> >
> > Thanks.
> >
> > Pete
> >
> >
>
> let's see the code that writes to the text file... prolly as easy as:
>
> join '|', @data;
>
> --
> Michael Budash




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

Date: Fri, 6 Jun 2003 13:08:48 +1200
From: "ThePotPlants" <thepotplants@yahoo.com>
Subject: Re: Extracting data from a database and storing it.
Message-Id: <BQRDa.11969$JA5.248914@news.xtra.co.nz>

Too right it does :)

It works a treat!. Many thanks

Pete

7369|SMITH|CLERK|7902|17-DEC-80|800||20
7499|ALLEN|SALESMAN|7698|20-FEB-81|1600|300|30
7521|WARD|SALESMAN|7698|22-FEB-81|1250|500|30
7566|JONES|MANAGER|7839|02-APR-81|2975||20
7654|MARTIN|SALESMAN|7698|28-SEP-81|1250|1400|30
7698|BLAKE|MANAGER|7839|01-MAY-81|2850||30
7782|CLARK|MANAGER|7839|09-JUN-81|2450||10
7788|SCOTT|ANALYST|7566|19-APR-87|3000||20
7839|KING|PRESIDENT||17-NOV-81|5000||10
7844|TURNER|SALESMAN|7698|08-SEP-81|1500|0|30
7876|ADAMS|CLERK|7788|23-MAY-87|1100||20
7900|JAMES|CLERK|7698|03-DEC-81|950||30
7902|FORD|ANALYST|7566|03-DEC-81|3000||20
7934|MILLER|CLERK|7782|23-JAN-82|1300||10


> > > join '|', @data;
> >         print OUTFILE "@row\n";

> print OUTFILE (join '|', @row), "\n";
>
> hth -
>
> Michael Budash




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

Date: Fri, 06 Jun 2003 01:16:38 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Extracting data from a database and storing it.
Message-Id: <mbudash-61DC4A.18163805062003@typhoon.sonic.net>

In article <BQRDa.11969$JA5.248914@news.xtra.co.nz>,
 "ThePotPlants" <thepotplants@yahoo.com> wrote:
 
> > > > join '|', @data;
> > >         print OUTFILE "@row\n";
> 
> > print OUTFILE (join '|', @row), "\n";
> >
>
> Too right it does :)
> 
> It works a treat!. Many thanks
> 
> Pete
> 
> 7369|SMITH|CLERK|7902|17-DEC-80|800||20
> 7499|ALLEN|SALESMAN|7698|20-FEB-81|1600|300|30
> 7521|WARD|SALESMAN|7698|22-FEB-81|1250|500|30
> 7566|JONES|MANAGER|7839|02-APR-81|2975||20
> 7654|MARTIN|SALESMAN|7698|28-SEP-81|1250|1400|30
> 7698|BLAKE|MANAGER|7839|01-MAY-81|2850||30
> 7782|CLARK|MANAGER|7839|09-JUN-81|2450||10
> 7788|SCOTT|ANALYST|7566|19-APR-87|3000||20
> 7839|KING|PRESIDENT||17-NOV-81|5000||10
> 7844|TURNER|SALESMAN|7698|08-SEP-81|1500|0|30
> 7876|ADAMS|CLERK|7788|23-MAY-87|1100||20
> 7900|JAMES|CLERK|7698|03-DEC-81|950||30
> 7902|FORD|ANALYST|7566|03-DEC-81|3000||20
> 7934|MILLER|CLERK|7782|23-JAN-82|1300||10
> 

great - glad to help. but please don't top post - put your answers after 
the originals like everyone else ...

-- 
Michael Budash


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

Date: Fri, 6 Jun 2003 02:52:09 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: formatted STDERR of an child process
Message-Id: <HG1HAx.JLp@news.boeing.com>

In article <bbkfeu$om4$1@pentheus.materna.de>,
Michael Korte <michael.korte@materna.de> wrote:
>I´ve a tricky question :
>
>My perlscript is starting a process (In my case : ldapdelete / ldapmodify)
>and it switches the STDERR into my Logfile
>like this :
>
>open(LOGG,">>logfile.log") or die "could not open logfile.log";
>open(STDERR, ">&LOGG") || die "STDERR: $!\n";
>
>This works fine, but all STDERRoutput, of course, is being written directly
>into the file. All Entries I´m creating from the actual script
>are formatted like :
>
>[03.06.2003] [ERROR] "Some Error String "
>
>Does somebody know a possibility to format the STDERR from the childprocess
>before writing into the file ?
>My first suggestion was to write it into a tmpfile, for later formatting
>these entries, but in this case I would not get the
>real time when the Error occureds...
>
>Maybe I can first send the STDERR into a  function ?
>

CGI::Carp be useful for logging in non-CGI settings. 

Catches compiler errors and will nicely timestamp STDERR 
output automatically for you. You can even customize the 
the logging.

Something like:

BEGIN {
  use CGI::Carp qw(carpout);
  open(LOG, ">>logfile.log") or
    die("Unable to open log: $!\n");
  carpout( \*LOG);
}
carp( "this'll appear first in the log\n");
warn "then this'll appear in the log\n";

will appear in the log as:

[Thu Jun  5 19:44:38 2003] myscript.pl: this'll appear first in the log
[Thu Jun  5 19:44:38 2003] myscript.pl: then this'll appear in the log

--
Charles DeRykus


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

Date: Fri, 06 Jun 2003 03:25:01 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Passthru and UNC path
Message-Id: <3EE007C1.4070105@rochester.rr.com>

RayGun wrote:

> I am trying to use passthru and a UNC path.  It complains that it
> cannot find the directory.
> 
> i.e. passthru("perl //somewhere/somedir/test.pl 2>&1");
 ...


What is "passthru"?  A function exported from some module?  If so, 
please let us know which module.

I note that if you use "system", the above seems to work on Windoze 98SE 
at least.  Note that the syntax would be like:

   system("perl //computername/sharename/dirname/filename.pl");

when using UNC path stuff.
-- 
Bob Walton



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

Date: Fri, 06 Jun 2003 02:17:03 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Push adding space to start of items
Message-Id: <3EDFF994.4EC72AD4@acm.org>

Mark Smith wrote:
> 
> Can anyone help me.  I'm processing some information.  If it meets a
> condition I push the value (and \n) onto an array. If I output the
> array, after the first line I get a space on every newline.
> 
> Why is this happening and how can I stop it?  It is not from the
> values I put in the array.

perldoc -q "Why do I get weird spaces when I print an array of lines"


John
-- 
use Perl;
program
fulfillment


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

Date: 5 Jun 2003 16:32:23 -0700
From: aknntp@yahoo.com (@|)
Subject: Re: sends email from the Windows machine
Message-Id: <f54c6679.0306051532.276e2a36@posting.google.com>

> I am trying to write a program that sends email from the Windows machine.

FWIW, here is an working example that runs on Windows 2000. 
It uses 'LOGIN' smtp authentication, but that is configurable. Also,
don't forget to check out the constructive suggestions in the post
following it...
 
http://groups.google.com/groups?q=aknntp+smtp&hl=en&lr=&ie=UTF-8&selm=ui8g7vkpkeu2vkid19t9hgljlo8bnbuing%404ax.com&rnum=1

- AK


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

Date: Fri, 06 Jun 2003 07:29:06 +0800
From: Dan Jacobson <jidanni@jidanni.org>
Subject: switches to stop errant one-liner at first warning
Message-Id: <87el28w1bx.fsf@jidanni.org>

For my use of one liners, I cannot find a switch on the perlrun man
page to kill the script at the first
"Use of uninitialized value in substitution (s///) at -e line 1, <> line 1."
And perl -nwe 'use strict;...' would get executed for each line, and
doesn't stop it anyway.

Anyway, what switches can I use to stop this mistake
$ perl -nwe 'if($a=~s/a/b/){print $a}' file
at the first warning, but at the same time not loading it up to spoil
the one-linerness?  Sort of like sh -e.
-- 
http://jidanni.org/ Taiwan(04)25854780


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

Date: Fri, 06 Jun 2003 01:23:55 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: switches to stop errant one-liner at first warning
Message-Id: <3edfe832.180788711@news.erols.com>

Dan Jacobson <jidanni@jidanni.org> wrote:

: For my use of one liners, I cannot find a switch on the perlrun man
: page to kill the script at the first
: "Use of uninitialized value in substitution (s///) at -e line 1, <> line 1."

There isn't one.  Do it in the code.

: And perl -nwe 'use strict;...' would get executed for each line,

use() influences compilation only.  It does not get executed on each
iteration.  

: and doesn't stop it anyway.

Nor is it meant to.  "use strict 'vars';" would force you to declare
variables, but you never have to define them.

: Anyway, what switches can I use to stop this mistake
: $ perl -nwe 'if($a=~s/a/b/){print $a}' file
: at the first warning, but at the same time not loading it up to spoil
: the one-linerness?  Sort of like sh -e.

Maybe (untested)...

    perl -ne 'use warnings FATAL => qw(uninitialized); print $a if
$a=~s/a/b/' file

or how about (untested again)...

    perl -nwe 'defined $a||die; print $a if $a=~s/a/b/' file

Not a great example, though.  $a never gets assigned anything, so is
always undef.



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

Date: Thu, 5 Jun 2003 18:27:15 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: switches to stop errant one-liner at first warning
Message-Id: <Pine.GSO.4.21.0306051822360.6114-100000@mtwhitney.nsc.com>

On Fri, 6 Jun 2003, Dan Jacobson wrote:

> For my use of one liners, I cannot find a switch on the perlrun man
> page to kill the script at the first
> "Use of uninitialized value in substitution (s///) at -e line 1, <> line 1."
> And perl -nwe 'use strict;...' would get executed for each line, and
> doesn't stop it anyway.
> 
> Anyway, what switches can I use to stop this mistake
> $ perl -nwe 'if($a=~s/a/b/){print $a}' file
> at the first warning, but at the same time not loading it up to spoil
> the one-linerness?  Sort of like sh -e.
> 



There's no such switch.  The 'perlrun' documentation does mention
handling of warnings as fatal errors via '__WARN__' hooks.  Try:

$ perl -nwe 'BEGIN{ $SIG{__WARN__} = sub { die $_[0];}} if($a=~s/a/b/){print $a}' file

The program stops after the first warning.

-- 
Hope this helps,
Steven



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

Date: Thu, 5 Jun 2003 18:41:14 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: switches to stop errant one-liner at first warning
Message-Id: <Pine.GSO.4.21.0306051835390.6114-100000@mtwhitney.nsc.com>

On Fri, 6 Jun 2003, Jay Tilton wrote:

> Dan Jacobson <jidanni@jidanni.org> wrote:
> 
> : For my use of one liners, I cannot find a switch on the perlrun man
> : page to kill the script at the first
> : "Use of uninitialized value in substitution (s///) at -e line 1, <> line 1."
> 

(snipped)

> Maybe (untested)...
> 
>     perl -ne 'use warnings FATAL => qw(uninitialized); print $a if
> $a=~s/a/b/' file
> 

(snipped)




Interesting.  I've not been using 'warnings' to its full potential.
After looking at Jay's example and reading 'perllexwarn' for the
first time, I tested the following:

$ perl -mwarnings=FATAL,uninitialized -nwe 'if($a=~s/a/b/){print $a}' file
Use of uninitialized value in substitution (s///) at -e line 1, <> line 1.

Yea, it works.

Does that count as using a 'perlrun' switch?  :)

-- 
Regards,
Steven



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

Date: Thu, 5 Jun 2003 20:06:22 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: switches to stop errant one-liner at first warning
Message-Id: <slrnbdvq8e.pgf.tadmc@magna.augustmail.com>

Dan Jacobson <jidanni@jidanni.org> wrote:
> For my use of one liners, I cannot find a switch on the perlrun man
> page to kill the script at the first

[warning]


Why do you want to kill the script at the first warning?


> And perl -nwe 'use strict;...' would get executed for each line, and
> doesn't stop it anyway.


Warnings never affect how your program executes, they are not fatal.


> Anyway, what switches can I use to stop this mistake
> $ perl -nwe 'if($a=~s/a/b/){print $a}' file
> at the first warning, 


There isn't one.


> but at the same time not loading it up to spoil
> the one-linerness?


I only know how to do a spoiled one:

   perl -nwe '$SIG{__WARN__} = sub { die $_[0] }; ...real code here' file

-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 5 Jun 2003 23:50:23 GMT
From: Tina Mueller <usenet@expires082003.tinita.de>
Subject: Re: Upload without cgi.pm or cgi-lib
Message-Id: <bbokvv$c1euo$1@ID-24002.news.dfncis.de>

GhostNr1 wrote:
> I just can't find any upload that is
> not useing cgi.pm becouse I don't use that and I don't whant to use it.

1. uhm... then don't use it. it's allowed to not use it.
2. why don't you want to use it?
3. look at the source

-- 
http://www.tinita.de/     \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
- my mail address expires end of august 2003 -


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

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


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