[17602] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5022 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 4 00:05:33 2000

Date: Sun, 3 Dec 2000 21:05:09 -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: <975906309-v9-i5022@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 3 Dec 2000     Volume: 9 Number: 5022

Today's topics:
        basics... <sbh@hydsys.com>
    Re: basics... <bwalton@rochester.rr.com>
    Re: changing CHMOD permission with a .cgi script <VincentMurphy@mediaone.net>
    Re: Comparing two directory hierachies? (Chris Fedde)
    Re: file locking on windows- which method is best? fallenang3l@my-deja.com
    Re: finding content type (Chris Fedde)
    Re: Help with /\d+\s*(S+)/ Please (Chris Fedde)
    Re: Help with /\d+\s*(S+)/ Please <ned911@home.com>
    Re: Help with sendmail (Chris Fedde)
        How to do 'sort -u' with Perl for windows? <huyv@usa.net>
    Re: How to do 'sort -u' with Perl for windows? (Chris Fedde)
    Re: How to do 'sort -u' with Perl for windows? <bwalton@rochester.rr.com>
    Re: IO::Socket send exits on failure (Chris Fedde)
    Re: modems and perl (Chris Fedde)
    Re: Newbie who can't get Perl started in Win98 <jeff@vpservices.com>
    Re: Newbie who can't get Perl started in Win98 (Garry Williams)
    Re: Newbie who can't get Perl started in Win98 <glburton@mindspring.com>
    Re: Newbie who can't get Perl started in Win98 <glburton@mindspring.com>
    Re: Perl and Microsoft Access Problem stlassociates@usa.net
    Re: qmail - perl (Chris Fedde)
    Re: Regex multiline html <VincentMurphy@mediaone.net>
    Re: Regex multiline html (Garry Williams)
    Re: Regex multiline html (Garry Williams)
    Re: Regex multiline html <mbudash@sonic.net>
        regular expression help <ddb@crystal.uwa.edu.au>
    Re: regular expression help <bwalton@rochester.rr.com>
    Re: Retrieving Files from a Linux Parition to DOS/NT (Chris Fedde)
    Re: Using goto (Shawn Smith)
    Re: Using goto (Shawn Smith)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 4 Dec 2000 15:12:22 +1100
From: "silas horsley" <sbh@hydsys.com>
Subject: basics...
Message-Id: <3a2b19f7@iridium.webone.com.au>

I'm just beginning on the CGI/Perl road...
In the world of perl5, can I get away with just using CGI.pm to do basic
form manipulation?
Thanks,
Si






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

Date: Mon, 04 Dec 2000 04:13:03 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: basics...
Message-Id: <3A2B1A73.1EC2C9FC@rochester.rr.com>

silas horsley wrote:
> 
> I'm just beginning on the CGI/Perl road...
> In the world of perl5, can I get away with just using CGI.pm to do basic
> form manipulation?
> Thanks,
> Si
Yes, that's what it's for.
-- 
Bob Walton


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

Date: Mon, 04 Dec 2000 02:07:08 GMT
From: Vinny Murphy <VincentMurphy@mediaone.net>
Subject: Re: changing CHMOD permission with a .cgi script
Message-Id: <m3hf4kga10.fsf@vmurphy-hnt1.athome.net>

>>>>> "Eric" == EM  <me@privacy.net> writes:

    Eric> `chmod 777 /path/to/file.ext`; can be used with directory also

But what if on a windoze system?

'perldoc -f chmod'  is what he wants for portability.

--Vinny

    Eric> ------- Eric

    Eric> "Bostjan Kocan" <webmajster@fiver.si> wrote in message
    Eric> news:MyAW5.41607$GU1.5019@news.siol.net...
    >> Hi!
    >> 
    >> I would like to change a permission of a file from 644 to 777 but
    >> with a .cgi script... I need to automate things and I have like 200
    >> files to
    Eric> change
    >> per day and doing it by hand is not a good solution...
    >> 
    >> I know it can be done with a simle .cgi command but heaven't had the
    >> luck
    Eric> to
    >> spot one in the tutorials...
    >> 
    >> Does anyone have any idea on how this command would look?
    >> 
    >> Thanks to anyone that would help me!
    >> 
    >> 




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

Date: Mon, 04 Dec 2000 02:43:00 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Comparing two directory hierachies?
Message-Id: <UwDW5.18$T3.135400448@news.frii.net>

In article <9050aq$fre$1@nnrp1.deja.com>,
Henrik  <henrik.jonsson@se.adtranz.com> wrote:
>Is there any module that can be used to compare two directory
>hierarchies? Like the command dircmp on unix.
>
>I have looked at CPAn but I didn't find anything.
>
>Thanks!
>
>/Henrik
>

What sort of comparison are you looking for? Most unixoid OS's have
a diff command that accepts lots of options.  On my system 'diff
-ru' gives a nice easily parsable output that can then be feed
through a perl script.

If you are trying to synch two directories then you might look at
non perl tools like 'pax(1)', 'cpio(1)'  and tar(1). Or if they are on
different boxes, take a look at rdist, rsync and maybe cfengine depending
on your needs.

Good Luck
chris
-- 
    This space intentionally left blank


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

Date: Mon, 04 Dec 2000 01:58:15 GMT
From: fallenang3l@my-deja.com
Subject: Re: file locking on windows- which method is best?
Message-Id: <90etnl$upq$1@nnrp1.deja.com>

In article <90erub$4vl$1@news.ox.ac.uk>,
  "Luke Lindsay" <luke@lindsay777.freserve.co.uk> wrote:
> I am converting some programs which process cgi data and generate
html from
> Linux to windows.
>
> Under Linux, I use flock for shared and exclusive file locking.
However,
> flock is, as far as I know, not supported under windows.  I have
tried using
> a simple filelocking mechanism which stores the pid of the process
holding
> the lock (lockfile::simple written by Raphael Manfredi, downloaded
from
> cpan).  This works for exclusive locks, but the I would also like to
be able
> to use shared locks. Is there a way to implement shared locks under
windows?
> If so, which implantation is best?
>
> TIA
>
> Luke
>
>

Wouldn't that be a subject to race conditions? Here's what I do for
exclusive locks (I will work on how to implement shared locks soon):

use Fcntl;
my $success;
my $try;
my $max_try = 10;

until ($success) {
	# This effectively emulates exclusive locks on Win95/98
platforms
	$success = sysopen LOCK, "auth/session.lck", O_CREAT | O_WRONLY
| O_EXCL;
	if (++$try == $max_try && !$success) {
		die "Couldn't create topic.lck: $!"
	}
        select(undef, undef, undef, 0.08) unless $success; # Sleep for
0.08 of a second iff failed
}

# this is a locked out part of the script. Only one process is allowed
to be here since this is kind of like mandatory file locking
# do whatever

close LOCK
    or die "Couldn't close session.lck: $!\n";
unlink "auth/session.lck"
    or die "Couldn't unlink session.lck: $!\n";

I'm sorry if the formatting breaks.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 04 Dec 2000 04:24:25 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: finding content type
Message-Id: <Z%EW5.27$T3.170654720@news.frii.net>

In article <S3BW5.6867$Nw6.23040@news.iol.ie>, EM <me@privacy.net> wrote:
>i have a script to allow people to upload files to a directory where others
>can then download
>how do i find the content type of the file uploaded?
>

You'll have to check the magic number of the file or feed it to
file(1) on unix.  On other platforms you might be able to make a
guess by looking at the suffix of the file name provided.  there
might be other approaches too.  You might find out about them by
posting your question to a group that has 'cgi' somewhere in it's
name.

Good Luck
chris
-- 
    This space intentionally left blank


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

Date: Mon, 04 Dec 2000 03:59:32 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Help with /\d+\s*(S+)/ Please
Message-Id: <EEEW5.25$T3.170846720@news.frii.net>

In article <3A2AE9BE.FF4FAB93@home.com>, Ned  <ned911@home.com> wrote:
>See below.  Appreciate the help.
>
>Data:  Name|Date|VacDay|SicDay|Comments
>
>Joe Smith|10-21-2000 09:35|1|0|Vacation
>Jane Smith|11-15-2000 10:35|0|1|Dr Appointment
>
>@idx = ();
>   for (@file) {
> ($item) = /\d+\s*(\S+)/;
> push @idx, uc($item);
>   }
> @file = @file [sort{$idx[$b] cmp $idx[$a]}0..$#idx];
>
>It is a descending sort - December should come before November.
>

Um..  I'm having a bit of trouble matching this re with the data...
Using the debugger I get the following:

    main::(datesorteg:8):       my ($item) = /\d+\s*(\S+)/;
      DB<1> 
    main::(datesorteg:9):       push @idx, uc($item);
      DB<1> p $item
    -21-2000
      DB<2> 

Is '-21-2000' realy what you want as your sort key?

I suspect that you realy want someting more like
    /(\d+-\d+-\d+ \d+:\d+)/;

But then you'll want to convert that into a sortable key
    $item = join("-", (/(\d+)-(\d+)-(\d+) (\d+):(\d+)/)[2,0,1,3,4]);

Well that's all the time I have to give to this problem. Given the
miss-match in Perl knowledge between the computed index sort
technique and the odd re I suspect that is is an example of Cargo
Cult programming or maybe I'm just seeing an inconsistant fragment
of a larger program.  My testing code appears below:

    #!/usr/bin/perl
    use warnings;
    use strict;
    my @file = <DATA>;

    my @idx = ();
    for (@file) {
        my $item = join("-", (/(\d+)-(\d+)-(\d+) (\d+):(\d+)/)[2,0,1,3,4]);
	push @idx, uc($item);
    }
    @file = @file [sort{$idx[$b] cmp $idx[$a]}0..$#idx];

    print @file;

    __END__
    Joe Smith|10-21-2000 09:35|1|0|Vacation
    Jane Smith|11-15-2000 10:35|0|1|Dr Appointment


-- 
    This space intentionally left blank


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

Date: Mon, 04 Dec 2000 04:24:36 GMT
From: Ned <ned911@home.com>
Subject: Re: Help with /\d+\s*(S+)/ Please
Message-Id: <3A2B1C69.F9F4FA8C@home.com>

Chris,

Thanks You very much you have solved the problem.  I had figured it was
something in the pattern match but wasn't quite sure what was going on.  Again,
thank you.

Ned

Chris Fedde wrote:

> In article <3A2AE9BE.FF4FAB93@home.com>, Ned  <ned911@home.com> wrote:
> >See below.  Appreciate the help.
> >
> >Data:  Name|Date|VacDay|SicDay|Comments
> >
> >Joe Smith|10-21-2000 09:35|1|0|Vacation
> >Jane Smith|11-15-2000 10:35|0|1|Dr Appointment
> >
> >@idx = ();
> >   for (@file) {
> > ($item) = /\d+\s*(\S+)/;
> > push @idx, uc($item);
> >   }
> > @file = @file [sort{$idx[$b] cmp $idx[$a]}0..$#idx];
> >
> >It is a descending sort - December should come before November.
> >
>
> Um..  I'm having a bit of trouble matching this re with the data...
> Using the debugger I get the following:
>
>     main::(datesorteg:8):       my ($item) = /\d+\s*(\S+)/;
>       DB<1>
>     main::(datesorteg:9):       push @idx, uc($item);
>       DB<1> p $item
>     -21-2000
>       DB<2>
>
> Is '-21-2000' realy what you want as your sort key?
>
> I suspect that you realy want someting more like
>     /(\d+-\d+-\d+ \d+:\d+)/;
>
> But then you'll want to convert that into a sortable key
>     $item = join("-", (/(\d+)-(\d+)-(\d+) (\d+):(\d+)/)[2,0,1,3,4]);
>
> Well that's all the time I have to give to this problem. Given the
> miss-match in Perl knowledge between the computed index sort
> technique and the odd re I suspect that is is an example of Cargo
> Cult programming or maybe I'm just seeing an inconsistant fragment
> of a larger program.  My testing code appears below:
>
>     #!/usr/bin/perl
>     use warnings;
>     use strict;
>     my @file = <DATA>;
>
>     my @idx = ();
>     for (@file) {
>         my $item = join("-", (/(\d+)-(\d+)-(\d+) (\d+):(\d+)/)[2,0,1,3,4]);
>         push @idx, uc($item);
>     }
>     @file = @file [sort{$idx[$b] cmp $idx[$a]}0..$#idx];
>
>     print @file;
>
>     __END__
>     Joe Smith|10-21-2000 09:35|1|0|Vacation
>     Jane Smith|11-15-2000 10:35|0|1|Dr Appointment
>
> --
>     This space intentionally left blank



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

Date: Mon, 04 Dec 2000 03:23:19 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Help with sendmail
Message-Id: <H6EW5.23$T3.170907136@news.frii.net>

In article <2yBW5.2179$NN6.11028@newsfeed.slurp.net>,
Ted Weber <tweber@abcdefg.com> wrote:
>
>I can't get our ISP to put things back the way they were. My email
>works OK, but is much slower logging into the mailserver than it used
>to be. Can anyone help me with this?
>

I'd recommend that you isolate the problem to a few lines of code.
Then, if you have not worked out the problem yet you will be able
to post a small fragment of code that is failing and the readers
of this group  will have a much better chance of pointing out the
problem.

Good Luck
chris
-- 
    This space intentionally left blank


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

Date: Mon, 04 Dec 2000 03:56:07 GMT
From: "DH" <huyv@usa.net>
Subject: How to do 'sort -u' with Perl for windows?
Message-Id: <975902166.439730@news.aei.ca>

Hi all,

I would like to have the equivalent of Unix command  'sort  -u' to run  on
windows.

Is it long to do it with Perl for Windows?

Thanks in advance for any  help.

DH.




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

Date: Mon, 04 Dec 2000 04:20:11 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: How to do 'sort -u' with Perl for windows?
Message-Id: <%XEW5.26$T3.170584064@news.frii.net>

In article <975902166.439730@news.aei.ca>, DH <huyv@usa.net> wrote:
>Hi all,
>
>I would like to have the equivalent of Unix command  'sort  -u' to run  on
>windows.
>
>Is it long to do it with Perl for Windows?
>
>Thanks in advance for any  help.
>

The quickest thing to do would be to look at the perl power tools site.
and grab a perl implementation of sort:

    http://language.perl.com/ppt/

Another approach would be to grap the cygwin packages and use it's
implementation of sort:

    http://cygwin.com/

chris
-- 
    This space intentionally left blank


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

Date: Mon, 04 Dec 2000 04:54:53 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: How to do 'sort -u' with Perl for windows?
Message-Id: <3A2B2441.1A7F3E0@rochester.rr.com>

DH wrote:
> 
> Hi all,
> 
> I would like to have the equivalent of Unix command  'sort  -u' to run  on
> windows.
> 
> Is it long to do it with Perl for Windows?
 ...
> DH.
You could download Cygwin -- it provides a sort with -u that works fine,
along with lots of other Unix goodies you are used to.  There isn't much
to doing it in Perl, though:

    @a=(11,8,2,3,4,5,6,7,8,5,8,9,8,10);
    my %h=map {$_,1} @a;
    my @s=sort {$a<=>$b} keys %h;
    print join ', ',@s;

-- 
Bob Walton


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

Date: Mon, 04 Dec 2000 03:07:57 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: IO::Socket send exits on failure
Message-Id: <hUDW5.20$T3.170847232@news.frii.net>

In article <903qqb$7lr$1@bob.news.rcn.net>,
Henry_Barta  <hbarta@enteract.com> wrote:
>    I'm using an IO::Socket::INET socket to connect to a another
>    Perl program and send data. If the other Perl program exits,
>    the one that initiated the connection exits when calling
>    IO::Socket::send with the diagnostic message:
>
>send: Cannot determine peer address at ./<scriptname>.pl line 81
>
>    I would much prefer that it just return an 'undef' so I could
>    handle this within my program.
>
>    Is there a known workaround for this problem? Should I use bare
>    sockets? Put the code that does the send in an 'eval'? (I'm
>    vaguely familiar with the notion of using an 'eval' to run
>    something that might die.)
>
>    Did a deja news search and found someone who experienced the
>    same problem, but did not find any followups to that post.
>

The common way of handling this kind of thing in Perl is to place the code
in question inside an eval{} and examine $@ for errors.  Also IO::Socket
provides a 'connected' method that can be used to check socket status.

Good Luck
chris
-- 
    This space intentionally left blank


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

Date: Mon, 04 Dec 2000 03:14:48 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: modems and perl
Message-Id: <I_DW5.22$T3.171043840@news.frii.net>

In article <90ekh3$o07$1@nnrp1.deja.com>,  <sfriend@my-deja.com> wrote:
>Hello,
>can anyone tell me  whether I can use
>perl to connect for my unix machine
>to a remote NT machine via a modem?
>if so how??
>

Perl can easily dial a modem on a unixoid box and send/recieve data with
another box over the connection. Look in deja news archives for that topic.

Good Luck
chris
-- 
    This space intentionally left blank


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

Date: Sun, 03 Dec 2000 19:23:23 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Newbie who can't get Perl started in Win98
Message-Id: <3A2B0E2B.432AB32C@vpservices.com>

Gary Burton wrote:
> 
> I have the book "Programming Perl", 3rd edition.  I am reading it from 
> page 1 on, and I can't seem to execute the first command in the book:
> 
> % perl -e 'print "Hello, world!\n";'

You need to read the FAQ from activeState outlining the differences
between Perl on windoze and Perl on other platforms.  It specifically
mentions that single quotes can not be used for one-liners.  So you need
to replace the single quotes with double quotes and the double quotes
with a qq() operator:

    perl -e "print qq(Hello, world!\n);"

One-liners are one of the areas where there is the most divergence
between windoze Perl and other Perls.  For other simple tasks, they are
pretty much the same.

-- 
Jeff


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

Date: Mon, 04 Dec 2000 03:35:14 GMT
From: garry@zweb.zvolve.net (Garry Williams)
Subject: Re: Newbie who can't get Perl started in Win98
Message-Id: <ShEW5.400$Xq5.21434@eagle.america.net>

On Sun, 03 Dec 2000 18:29:47 -0800, Gary Burton
<glburton@mindspring.com> wrote:
>I have the book "Programming Perl", 3rd edition.  I am reading it
>from page 1 on, and I can't seem to execute the first command in the
>book:
>
>% perl -e 'print "Hello, world!\n";'  
>
>I am using Windows 98.  ...
>
>When I execute it, I get "Can't find string terminator "'" anywhere
>before EOF at -e line 1.

The Windows shell is broken.  It will not recognize a single quote for
grouping a single parameter.  The only way to group "words" as a
single parameter in the Windows shell is to use double quotes.  That
creates a problem whenever you want double quotes in the value of the
-e option.  

Probably the easiest way to deal with that is to use an alternative
quoting character like qq//.  (See the perlop manual page section
"Quote and Quote-like Operators".)  That way your program would
become: 

    [C:\] perl -e "print qq/Hello, world!\n/;"

Although this is a reasonable work-around, I would recommend getting
another shell for Windows.  Bash is a good choice.  It works almost
the same as the Unix version and will be fine for learning Perl on
Windows.  

    http://sources.redhat.com/cygwin/ 

Hope this helps.  

-- 
Garry Williams


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

Date: Sun, 03 Dec 2000 20:57:43 -0800
From: Gary Burton <glburton@mindspring.com>
Subject: Re: Newbie who can't get Perl started in Win98
Message-Id: <3A2B2447.84F15591@mindspring.com>

Thanks!  You helped me a lot!

Jeff Zucker wrote:
> 
> Gary Burton wrote:
> >
> > I have the book "Programming Perl", 3rd edition.  I am reading it from
> > page 1 on, and I can't seem to execute the first command in the book:
> >
> > % perl -e 'print "Hello, world!\n";'
> 
> You need to read the FAQ from activeState outlining the differences
> between Perl on windoze and Perl on other platforms.  It specifically
> mentions that single quotes can not be used for one-liners.  So you need
> to replace the single quotes with double quotes and the double quotes
> with a qq() operator:
> 
>     perl -e "print qq(Hello, world!\n);"
> 
> One-liners are one of the areas where there is the most divergence
> between windoze Perl and other Perls.  For other simple tasks, they are
> pretty much the same.
> 
> --
> Jeff


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

Date: Sun, 03 Dec 2000 20:58:08 -0800
From: Gary Burton <glburton@mindspring.com>
To: garry@zvolve.com
Subject: Re: Newbie who can't get Perl started in Win98
Message-Id: <3A2B2460.4A8CAB87@mindspring.com>

Thanks!  You helped me a lot!

Garry Williams wrote:
> 
> On Sun, 03 Dec 2000 18:29:47 -0800, Gary Burton
> <glburton@mindspring.com> wrote:
> >I have the book "Programming Perl", 3rd edition.  I am reading it
> >from page 1 on, and I can't seem to execute the first command in the
> >book:
> >
> >% perl -e 'print "Hello, world!\n";'
> >
> >I am using Windows 98.  ...
> >
> >When I execute it, I get "Can't find string terminator "'" anywhere
> >before EOF at -e line 1.
> 
> The Windows shell is broken.  It will not recognize a single quote for
> grouping a single parameter.  The only way to group "words" as a
> single parameter in the Windows shell is to use double quotes.  That
> creates a problem whenever you want double quotes in the value of the
> -e option.
> 
> Probably the easiest way to deal with that is to use an alternative
> quoting character like qq//.  (See the perlop manual page section
> "Quote and Quote-like Operators".)  That way your program would
> become:
> 
>     [C:\] perl -e "print qq/Hello, world!\n/;"
> 
> Although this is a reasonable work-around, I would recommend getting
> another shell for Windows.  Bash is a good choice.  It works almost
> the same as the Unix version and will be fine for learning Perl on
> Windows.
> 
>     http://sources.redhat.com/cygwin/
> 
> Hope this helps.
> 
> --
> Garry Williams


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

Date: Mon, 04 Dec 2000 03:07:44 GMT
From: stlassociates@usa.net
Subject: Re: Perl and Microsoft Access Problem
Message-Id: <90f1pt$1r5$1@nnrp1.deja.com>

In article <908ubl$np1$1@tabloid.unh.edu>,
  "Timothy Frye" <thf@cisunix.unh.edu> wrote:
> out and ran just that part of the program to no avail.  The problem is this;
> after SELECTing the appropriate values,
> fetchrow_array returns only the last value that was selected.  Here is the
> code:
<snip>
> $id = $APP->param("id");
>
> $dbh = DBI->connect('DBI:ODBC:TroubleCalls', '{ RaiseError => 1}') || die
> "Couldn't connect to database: " . DBI->errstr;

Does connect statement work?   I'd review the perldoc DBI.

my $dbh = DBI->connect( 'dbi:ODBC:DSN', userid, password, {RaiseError => 1,
PrintError => 1} ) or die $DBI::errstr; In case of no userid or password use
'' or "".

> $statement = "SELECT * FROM TroubleCalls WHERE TroubleID = $id"

$id is tainted, look into a bind parameter. my $sql = qq{select call, handle,
trouble, start, end, notes, time, dept, caller from TroubleCalls where
TroubleID = ?};

It's much better to use column names in the select statement.  Add a column
or rebuild the table in a different column order and everything breaks when
using select *.

> $sth = $dbh->prepare($statement);
Error checking is not needed with RaiseError and PrintError.

$sth->execute($id);

($call, $handle, $trouble, $start, $end, $notes, $time, $dept,
$caller) = $sth->fetchrow_array();

warn "fetchrow error: " . $sth->errstr if $sth->err; #	If you want to
include the error checking.  Again, PrintError/RaiseError provides feed back
on errors.  Very, very useful for development.

$sth->finish();
>
> print header, start_html;
>
> print "\$call = $call<br>\n"
> print "\$handle = $handle<br>\n"
> print "\$trouble = $trouble<br>\n"
> print "\$start = $start<br>\n"
> print "\$end = $end<br>\n"
> print "\$notes = $notes<br>\n"
> print "\$time = $time<br>\n"
> print "\$dept = $dept<br>\n"
> print "\$caller = $caller<br>\n"
>
> print end_html;
> ###################End Code############################
>
> The problem is that when this executes,  I get this as the printout:
> $call = Tim
> $handle =
> $trouble =
> $start =
> $end =
> $notes =
> $time =
> $dept =
> $caller =
>
> and that first value of Tim should show up as the value for $caller.  If I
> ask for only one value, I get the value that I asked for.  Anymore than that
> and I get the last value selected showing up as the first value printed out
> and nothing else (as above).


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 04 Dec 2000 02:30:51 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: qmail - perl
Message-Id: <vlDW5.17$T3.170617344@news.frii.net>

In article <3A2AF67B.BC4D15AE@omon.net.au>,
Michael Salleo  <michael@omon.net.au> wrote:
>Hi,
>
>I'm looking for any tutorials or documentation on anyone who has used
>qmail and perl together nicely.
>
>Any help would be appreciated.
>

What aspect of Qmail are you trying to automate with perl?  If you want to
just post mail or pop it off then the MIME::whatever, Net::SMTP and
Net::POP3 modules should do it for you.  If you want to do something deeper
like manage qmail's configuration you are probably going to need to coble
something together.  Still it would not hurt to ask your question in a news
group that has 'qmail' somewhere in its name.


Good Luck
chris
-- 
    This space intentionally left blank


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

Date: Mon, 04 Dec 2000 02:19:36 GMT
From: Vinny Murphy <VincentMurphy@mediaone.net>
Subject: Re: Regex multiline html
Message-Id: <m3elzog9g9.fsf@vmurphy-hnt1.athome.net>


   Tony> Hi

   Tony> Have been trying to remove five lines in one chunk from
   Tony> html pages. Single lines are no problem but need to
   Tony> remove their following <BR> tags also. Removing the <BR>
   Tony> tags seperately does not work because it removes every one
   Tony> in the page(the way I did it anyway:) Have looked at the
   Tony> /m, /s, modifiers. Would appreciate if someone might know
   Tony> where I am going wrong here?
   Tony> Thanks.

   Tony> #!/usr/bin/perl -w
   Tony> use strict;

   Tony> while(<DATA>) {
   Tony>     #s/^Phone.*//sm;    # works for one line
   Tony>     #s/^Phone.*\n.*\n.*\n.*\n.*\n//sm;  # these don't work
   Tony>     #s/\APhone.*\n.*\n.*\n.*\n.*\n\Z//sm;
   Tony>     #s/^Phone.*\n.*\n.*\n.*\n.*\n$//sm;
   Tony>     #s/\APhone.*<BR>.*<BR>\Z//sm;
   Tony>     #s/^Phone.*\n<BR>\n.*\n.*\n<BR>\n//sm;
   Tony>     #s/\APhone.*\n<BR>\n.*\n.*\n<BR>\Z\n//sm;
   Tony>     print;
   Tony> }
   Tony> __END__
   Tony> <BR>
   Tony> more html stuff above here
   Tony> <BR> # remove from here vvvvvvvvvvvvvvvvvvvvvvvvvv
   Tony> Phone: Int. 555 5555 5555, Fax: Int. 555 5555 5555
   Tony> <BR>
   Tony> <A HREF="mailto:me@myisp.com">E-mail</A>
   Tony> me@myisp.com
   Tony> <BR> # to here ----------------------------------- 
   Tony> </EM>
   Tony> </FONT>
   Tony> 

you probably want to use the range operator ...  

print while <DATA>;		# show all output.
print '-' x 72, "\n";
while ( <DATA> ) {
  #            BEGIN TOKEN    ...      END TOKEN
  next if /\# remove from here/ ... /\# to here .*$/;
  # notice the three dots. ------^
  print;
}

__DATA__
<BR>
more html stuff above here
<BR> # remove from here vvvvvvvvvvvvvvvvvvvvvvvvvv
Phone: Int. 555 5555 5555, Fax: Int. 555 5555 5555
<BR>
<A HREF="mailto:me@myisp.com">E-mail</A>
me@myisp.com
<BR> # to here ----------------------------------- 
</EM>
</FONT>


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

Date: Mon, 04 Dec 2000 03:47:11 GMT
From: garry@zweb.zvolve.net (Garry Williams)
Subject: Re: Regex multiline html
Message-Id: <3tEW5.402$Xq5.21434@eagle.america.net>

On Mon, 04 Dec 2000 02:19:36 GMT, Vinny Murphy
<VincentMurphy@mediaone.net> wrote:
>   Tony> Have been trying to remove five lines in one chunk from
>   Tony> html pages. Single lines are no problem but need to
>   Tony> remove their following <BR> tags also. Removing the <BR>

[snip]

>you probably want to use the range operator ...  
>
>print while <DATA>;		# show all output.
>print '-' x 72, "\n";
>while ( <DATA> ) {
>  #            BEGIN TOKEN    ...      END TOKEN
>  next if /\# remove from here/ ... /\# to here .*$/;
>  # notice the three dots. ------^

This is from the perlop manual page:

  Range Operators

    Binary ".." is the range operator,

Notice the *two* dots.  

>  print;
>}

Did you even try to run the code you posted?  

    readline() on closed filehandle main::DATA at x line 3.
    ------------------------------------------------------------------------
    readline() on closed filehandle main::DATA at x line 5.

Why would you post such a thing?  

-- 
Garry Williams


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

Date: Mon, 04 Dec 2000 04:15:39 GMT
From: garry@zweb.zvolve.net (Garry Williams)
Subject: Re: Regex multiline html
Message-Id: <LTEW5.403$Xq5.21932@eagle.america.net>

On Mon, 04 Dec 2000 03:47:11 GMT, Garry Williams
<garry@zweb.zvolve.net> wrote:
>On Mon, 04 Dec 2000 02:19:36 GMT, Vinny Murphy
><VincentMurphy@mediaone.net> wrote:
>
>Did you even try to run the code you posted?  
>
>    readline() on closed filehandle main::DATA at x line 3.
>    ------------------------------------------------------------------------
>    readline() on closed filehandle main::DATA at x line 5.

Make that: 

    $ perl x
    <BR>
    more html stuff above here
    <BR> # remove from here vvvvvvvvvvvvvvvvvvvvvvvvvv
    Phone: Int. 555 5555 5555, Fax: Int. 555 5555 5555
    <BR>
    <A HREF="mailto:me@myisp.com">E-mail</A>
    me@myisp.com
    <BR> # to here -----------------------------------
    </EM>
    </FONT>
    ------------------------------------------------------------------------
    $

In other words, your code removes *everything*.  

-- 
Garry Williams


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

Date: Sun, 03 Dec 2000 20:16:30 -0800
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Regex multiline html
Message-Id: <mbudash-FBBDD4.20163003122000@news.pacbell.net>

In article <3tEW5.402$Xq5.21434@eagle.america.net>, garry@zvolve.com 
wrote:

> On Mon, 04 Dec 2000 02:19:36 GMT, Vinny Murphy
> <VincentMurphy@mediaone.net> wrote:
> >   Tony> Have been trying to remove five lines in one chunk from
> >   Tony> html pages. Single lines are no problem but need to
> >   Tony> remove their following <BR> tags also. Removing the <BR>
> 
> [snip]
> 
> >you probably want to use the range operator ...  
> >
> >print while <DATA>;		# show all output.
> >print '-' x 72, "\n";
> >while ( <DATA> ) {
> >  #            BEGIN TOKEN    ...      END TOKEN
> >  next if /\# remove from here/ ... /\# to here .*$/;
> >  # notice the three dots. ------^
> 
> This is from the perlop manual page:
> 
>   Range Operators
> 
>     Binary ".." is the range operator,
> 
> Notice the *two* dots.  
> 
[snip]

fyi, there most certainly is such a thing as '...' (*three* dots) 
mentioned on exactly the same perlop manual page 26 lines down from your 
reference...

hth-
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Mon, 04 Dec 2000 12:01:03 +0800
From: Douglas du Boulay <ddb@crystal.uwa.edu.au>
Subject: regular expression help
Message-Id: <3A2B16FF.CBEE05AF@crystal.uwa.edu.au>


In fortran the hollerith format descriptor is of form

        xxhxx_arbitrary_characters

where xx is an integer number of characters,
the subsequent 'h' implies what follows is a character string
and xx arbitrary characters follow. (additional characters may
exist beyond the final 's' but they should be preserved intact)

What i wanted was a simple conversion of 

xxhxx_arbitrary_characters  into "xx_arbitrary_characters"

I thought I could do this with something simple like:

  s/(\d+)h(.{\1})/\"$2\"/ig ;

but apparently not.
How do I convert \1 to a numerical value on the fly ?
My experiments with evaluations ?{ \1} were not
a great success.

thanks
Doug


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

Date: Mon, 04 Dec 2000 04:34:17 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: regular expression help
Message-Id: <3A2B1F6E.2D589067@rochester.rr.com>

Douglas du Boulay wrote:
> 
> In fortran the hollerith format descriptor is of form
> 
>         xxhxx_arbitrary_characters
> 
> where xx is an integer number of characters,
> the subsequent 'h' implies what follows is a character string
> and xx arbitrary characters follow. (additional characters may
> exist beyond the final 's' but they should be preserved intact)
> 
> What i wanted was a simple conversion of
> 
> xxhxx_arbitrary_characters  into "xx_arbitrary_characters"
> 
> I thought I could do this with something simple like:
> 
>   s/(\d+)h(.{\1})/\"$2\"/ig ;
> 
> but apparently not.
> How do I convert \1 to a numerical value on the fly ?
> My experiments with evaluations ?{ \1} were not
> a great success.
 ...
> Doug
It looks like you'll need to break it into two statements:  one that
finds the character count, and another that does the match.  Maybe
something like:

$h='5habcdegarbage3hcatxxxx3hdogxxx';
while(1){
   last unless my $n=$h=~/(\d+)h/i;
   last unless $h=~s/\d+h(.{$n})/$1/i;
   print "h is now:$h\n";
}

Note that that won't do a very good job of detecting valid Fortran
syntax.  For example, the statement:

   a2h=32

would be "converted" erroneously to a=32 -- so you'll have to know that
the string you supply contains only syntactially-appropriate Fortran
hollerith strings before applying this.  You'd be better off writing a
Fortran parser. Maybe use Parse::Yapp; would work?
-- 
Bob Walton


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

Date: Mon, 04 Dec 2000 02:20:24 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Retrieving Files from a Linux Parition to DOS/NT
Message-Id: <IbDW5.16$T3.171082752@news.frii.net>

In article <3A2A5A31.6DAC682@sirius.com>,
Wayne Watson  <mtn_view@sirius.com> wrote:
>A  few years ago I had Linux and NT running together and somehow
>clobbered Linux. That is, I can no
>longer boot Linux. However, I have a Linux partition that contains some
>useful Perl scripts and a
>number of very useful C programs.Although I had put them on a tape, it
>is now very difficult to get
>them from the tape. I would like to  write a perl script to access the
>partition and rumble through
>the filesystem there to pick off the source files and put them into a
>DOS/NT partition. I have no
>idea whether I can somehow selectively grab the partition. I imagine
>(hope!) there's a file or
>partition open statement that gets me to the partition I'd like to
>search. Is what I'm asking
>possible?
>

Perhaps your question could be better answered by posting it to a group
that has Microsoft, NT, Linux, or clueless somewhere in it's name.

Good Luck
chris
-- 
    This space intentionally left blank


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

Date: Mon, 04 Dec 2000 03:11:52 GMT
From: SPAM_loginprompt@yahoo.com (Shawn Smith)
Subject: Re: Using goto
Message-Id: <3a2b0911.10051965@netnews.worldnet.att.net>

On Sat, 2 Dec 2000 20:54:21 -0500, tadmc@metronet.com (Tad McClellan)
wrote:

>Shawn Smith <SPAM_loginprompt@yahoo.com> wrote:
>>On Sat, 2 Dec 2000 09:34:09 -0500, tadmc@metronet.com (Tad McClellan)
>>wrote:
>>
>>
>>>(But perl is really a compile-and-go thingie. It is _both_
>>> a compiler and an interpreter. A floor wax and a dessert
>>> topping.
>>>)
>>
>>Ted 
>
>
>Yes Shaun?

ROTFLOL.

Sorry. 

Tad you have been more than helpful, you have been patient and
tolerant. All that you say below makes things crystal clear.

Thanks a ton. 

>>can you point me to a doc that covers the compile-ang-go thingie.
>
>
>It is the same one I already pointed you to, perlrun:
>
>------------------------------
>After locating your program, Perl compiles the entire program to an
>internal form.  If there are any compilation errors, execution of the
>program is not attempted.  (This is unlike the typical shell script,
>which might run part-way through before finding a syntax error.)
>
>If the program is syntactically correct, it is executed.  If the program
>runs off the end without hitting an exit() or die() operator, an implicit
>C<exit(0)> is provided to indicate successful completion.
>------------------------------
>
>
>>I am guessing that perl interprets the script, and then perl does not
>>run the code, but instead makes an exe that it loads into memory, and
>>it never saves the exe to file?
>
>
>Kinda sorta.
>
>perl _is_ the binary (I cannot bring myself to use "exe").
>
>It first compiles your entire program (and modules, if any)
>and makes an internal representation, called byte codes.
>Then in runs the byte codes as an interpreter, all within
>the perl binary. perl is a kind of "virtual machine" there
>is no "other" binary. This is similar to how Pascal compilers 
>and Java work also.
>
>
>-- 
>    Tad McClellan                          SGML consulting
>    tadmc@metronet.com                     Perl programming
>    Fort Worth, Texas


__

Shawn Smith 
My freeware: http://sites.netscape.net/shawnspad 




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

Date: Mon, 04 Dec 2000 03:17:36 GMT
From: SPAM_loginprompt@yahoo.com (Shawn Smith)
Subject: Re: Using goto
Message-Id: <3a2c0bbd.10736217@netnews.worldnet.att.net>

On Sun, 3 Dec 2000 13:52:07 +1100, mgjv@tradingpost.com.au (Martien
Verbruggen) wrote:

>On Sun, 03 Dec 2000 01:54:47 GMT,
>	Shawn Smith <SPAM_loginprompt@yahoo.com> wrote:
>> On Sat, 2 Dec 2000 09:34:09 -0500, tadmc@metronet.com (Tad McClellan)
>> wrote:
>> 
>> 
>>>(But perl is really a compile-and-go thingie. It is _both_
>>> a compiler and an interpreter. A floor wax and a dessert
>>> topping.
>>>)
>> 
>> Ted can you point me to a doc that covers the compile-ang-go thingie.
>
>(pssst... His name is Tad. With an a :))

Tad not Ted, Tad not Ted, Tad not Ted, Tad ...

>> I am guessing that perl interprets the script, and then perl does not
>> run the code, but instead makes an exe that it loads into memory, and
>> it never saves the exe to file?
>
>I can't actually easily find a good spot in the documentation that goes
>into detail on this. The Camel (Programming Perl) goes into quite some
>detail in chapter 18 (third edition).

I will check that out, but Tad has made things pretty clear.

>The perlcompile documentation goes into some detail, albeit a bit
>unstructured.
>
>It's not really important to know how exactly this works to work with
>Perl. As long as you understand that there is a compilation and a run
>phase, you're happy. Some things happen during compilation, some during
>run.
>
>Just to clarify one thing: The compilation phase does not compile Perl
>into machine code. That never happens in the normal life cycle of a perl
>program.
>
>If you want to know the details, read perlcompile, and get access to a
>copy of Programming Perl.

I have it, and like the humor in it. I have read  a lot of dry books
on coding but this is the best written text I have ever read because
of the humor.

I like your .sig too. Reminds me of how we are all living a few
seconds in the past (the time it takes our senses to register what has
occurred).

>Martien
>-- 
>Martien Verbruggen              | Since light travels faster than
>Interactive Media Division      | sound, isn't that why some people
>Commercial Dynamics Pty. Ltd.   | appear bright until you hear them
>NSW, Australia                  | speak?


__

Shawn Smith 
My freeware: http://sites.netscape.net/shawnspad 




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

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 V9 Issue 5022
**************************************


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