[23228] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5449 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 5 14:06:38 2003

Date: Fri, 5 Sep 2003 11:05:10 -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           Fri, 5 Sep 2003     Volume: 10 Number: 5449

Today's topics:
    Re: [newbie] dbi question <postmaster@castleamber.com>
    Re: A suggestion for perldoc <bik.mido@tiscalinet.it>
    Re: Basic Aspects of AI                                 <another.wise.guy@macon.georgia.usa>
    Re: Basic Aspects of AI (Arthur T. Murray)
    Re: Basic Aspects of AI (Bradley K. Sherman)
    Re: Basic Aspects of AI <usenet@dwall.fastmail.fm>
        DB not saving everything (spyderscripts)
        finding instance of object <cyberjeff@sprintmail.com>
        maximum input buffer length exceeded: 1048576 <rtavares@tec.dsr.telecom.pt>
    Re: maximum input buffer length exceeded: 1048576 <minceme@start.no>
    Re: My perl script is "Killed" - Ran out of memory (Marcus Brody)
        NT: perl 5.8.0: system call - commnad split into multip (Eric)
    Re: NT: perl 5.8.0: system call - commnad split into mu <usenet@dwall.fastmail.fm>
    Re: perl  -w  example.pl <tcurrey@no.no.no.i.said.no>
    Re: Perl, javascript and CGI <REMOVEXtwoheadsX@tiscaliX.co.uk>
        Regexp Help (raven)
        Repost Search (Jimmy)
    Re: Repost Search <tom.wong@verizon.net>
    Re: Repost Search <tom.wong@verizon.net>
    Re: Repost Search <usenet@dwall.fastmail.fm>
    Re: Repost Search <krahnj@acm.org>
        Search (Jimmy)
    Re: Telling perl to expect input data to be in UTF8 (no <Graham.T.Wood@oracle.com>
    Re: Telling perl to expect input data to be in UTF8 (pl <Graham.T.Wood@oracle.com>
    Re: Telling perl to expect input data to be in UTF8 <usenet@dwall.fastmail.fm>
    Re: View NG with Net::NNTP <shondell@cis.ohio-state.edu>
        Weird interaction between Net::FTP and DBI / DBD::Oracl (Peter Mutsaers)
    Re: What ever happened to comp.lang.perl ? <islaw@adexec.com>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 05 Sep 2003 17:13:53 +0200
From: John Bokma <postmaster@castleamber.com>
Subject: Re: [newbie] dbi question
Message-Id: <3f58a897$0$1753$58c7af7e@news.kabelfoon.nl>

tsheets wrote:

> I am new to perl, and expecially dbi, but am trying to figure the best 
> way to accomplish the following:
> 
> I have an HTML form, that lets the user select which fields to include 
> in the results.  Also, a text box for the where clause.
> 
> for example, the table contains firstname, lastname, phone, address, and 
> zip.
> 
> Lets say you only want firstname, lastname, and zip (checkboxes), where 
> lastname = smith.
> 
> So far, I have been able to figure out which boxes are checked, and 
> store that in a variable to pass to the select statement, and build the

Be *extremely* careful with building a select statement from a form. 
Never ever trust what a user enters. Check each field and make sure it 
matches *only* characters that are allowed. Don't try to fix silently 
but report an error (for example if you expect a number make sure it is 
a number, don't throw away non-digits but warn if you get anything that 
is not a digit, see also URL in my sig).

> resulting HTML table with the correct headings.  But, I am not sure how 
> to go about processing only the fields selected with the data returned 
> from the query.
> 
> I have read several examples, and the perldoc, but about the closest 
> thing I have understood is getting the entire row, and only printing out 

you can do:

SELECT Name, Address, Phone FROM table WHERE Name='John';

this gives all rows with Name John and only the columns Name, Address 
and Phone. So you can specify which columns you want.

> the interesting fields.  Is this my best bet, or am I just not 
> understanding something (like bind_columns maybe)?  The fact that any 
> number or combination of boxes can be checked really has me stumped.

You could do something like:

@cols = ();
@checkboxes = qw(name phone address);

foreach checkbox (@checkboxes)
	push(@cols, checkbox) if checked(checkbox);
}

query = "select " . join(", ", @cols) . " from table ...";

(pseudo perl)

Note that I specify the column names. Don't just get all checkboxes and 
build the query based on the names (e.g. someone could create a checkbox 
with a weird name which could change the query in a bad way).

HTH,

-- 
Kind regards,       feel free to mail: mail(at)johnbokma.com (or reply)
                     virtual home: http://johnbokma.com/  ICQ: 218175426
John                web site hints: http://johnbokma.com/websitedesign/



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

Date: Fri, 05 Sep 2003 17:13:13 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: A suggestion for perldoc
Message-Id: <6m0hlvges6gtae3itg6ndguvfqprhked11@4ax.com>

On 3 Sep 2003 21:00:32 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:

>The hard part, it seems to me, is generating an initial mass of such
>tips.  If it's going to be run in a fortune-cookie manner, you need a
>hundred, better more.  They would have to be short, too.  I can't think

Well, I suggested 2 that came to mind soon...

>of too many of those, but then I'm just one.  I think the 03 thing to
>do is set up a wiki.

Some friends of mine working on a cluster at our University's
department (mostly on a volounteering basis!) were thinking of a
possible service of general/public utility for the lab.

I *think* that setting up a wiki for this task would be OK, but I'm a
bit concerned about the visibility it might have amongst all those
/.*perl.*/ domains out there...


Michele
-- 
# This prints: Just another Perl hacker,
seek DATA,15,0 and  print   q... <DATA>;
__END__


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

Date: Fri, 05 Sep 2003 17:04:03 +0000
From: "Another Wise Guy - Macon, GA USA" <another.wise.guy@macon.georgia.usa>
Subject: Re: Basic Aspects of AI                                                                                                              -Another Wise Guy - Macon, GA USA
Message-Id: <lc36b.824$h5.278@fe01.atl2.webusenet.com>
Keywords: Just Another Internet Wise Guy - Macon, Georgia USA


> So, this is my query. Giving a good understanding of AI and 
> spreading its contents is basic for getting more minds 
> involved in it. Thank you very much in advance.

The key is to make a bunch of artificial minds and have *them*
get involved in AI research.


-- 
----------------------------------------------------------------------
|  Just Another Internet Wise Guy                     Macon, GA USA  |
----------------------------------------------------------------------




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

Date: 5 Sep 2003 08:30:10 -0800
From: uj797@victoria.tc.ca (Arthur T. Murray)
Subject: Re: Basic Aspects of AI
Message-Id: <3f58ac02@news.victoria.tc.ca>
Keywords: artificial intelligence, AI, AI4U, Seed AI

> [...] We are preparing a subject for university... 
> we'd like to teach an introductory course on AI and 
> we are doing the previous research before deciding the 
> contents that give a better view of this exciting topic.

http://www.amazon.com/exec/obidos/ASIN/0595654371/ -- "AI For You"
(AI4U) is an AI textbook that you might consider using as an AI Lab 
supplement to pre-Singularity textbooks of artificial intelligence.

> It would be really helpful and a lot more interesting if you could
> give me your opinion on which are the basic areas to cover... or,
> in other words, what would you consider essential for the best
> understanding of the subject.

http://mentifex.virtualentity.com/acm.html has essential DIY AI steps.

http://mentifex.virtualentity.com/perl.html is a Perl AI Weblog.
 
> I have posted this message in different groups. 
> Basically because I think not everyone may know about everything,
> but maybe about some aspects of AI yes. Really interested also!!

http://www.kurzweilai.net/mindx/profile.php?id=26 - Mind-eXchange
is where readers share ideas and support for Open Source AI projects.
 
> So, this is my query. Giving a good understanding of AI and 
> spreading its contents is basic for getting more minds 
> involved in it. Thank you very much in advance.


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

Date: 5 Sep 2003 12:11:51 -0400
From: bks@panix.com (Bradley K. Sherman)
Subject: Re: Basic Aspects of AI
Message-Id: <bjack7$djo$1@panix1.panix.com>
Keywords: artificial intelligence, AI, AI4U, Seed AI

In article <3f58ac02@news.victoria.tc.ca>,
Arthur T. Murray <uj797@victoria.tc.ca> wrote:
> ...
>http://www.amazon.com/exec/obidos/ASIN/0595654371/ -- "AI For You"
>(AI4U) is an AI textbook that you might consider using as an AI Lab 
>supplement to pre-Singularity textbooks of artificial intelligence.
> ...

Hey guys, over here in comp.human-factors we thought AI died
sometime around 1967.  Is that the Sigularity referred to
or is there something going on that we should know about?

Do you guys know what happened to the Ontology zeitgeist that
passed through a couple of years ago? 

    --bks



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

Date: Fri, 05 Sep 2003 17:26:00 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Basic Aspects of AI
Message-Id: <Xns93ED88A4BA0EDdkwwashere@216.168.3.30>


Bradley K. Sherman <bks@panix.com> wrote:

[crossposted to, among other places, comp.lang.perl.misc...]

> Hey guys, over here in comp.human-factors we thought AI died
> sometime around 1967.  Is that the Sigularity referred to
> or is there something going on that we should know about?

I'm not sure what connection this has with Perl.  There's a lot of 
DWIMery in perl, but I don't think it's self-aware (yet).

-- 
David Wall


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

Date: 5 Sep 2003 09:16:15 -0700
From: sulfericacid@qwest.net (spyderscripts)
Subject: DB not saving everything
Message-Id: <32b6332f.0309050816.2978ab6f@posting.google.com>

I have an html form to upload files with.  The uploads are sent to
their own directory, which works.  But..the database isn't saving
everything.  It's only saving the last file to database (if you
uploaded 4 files, all 4 files are uploaded but the database only shows
#4).  Could this be because I'm using localtime() as the key?  I was
told that even though it's one form, the time each of them are
actually uploaded will be different.

Thanks for your help.



if ( param('upload1') ) {

my $num = 1;

&dirty_work($num);

}

if ( param('upload2') ) {

my $num = 2;

&dirty_work($num);
}

if ( param('upload3') ) {

my $num = 3;

&dirty_work($num);
}

if ( param('upload4') ) {

my $num = 4;
&dirty_work($num);
}







sub dirty_work {
my $num = shift;
    # take form data
    my $remotefile = param("upload$num");
# make new variable to prevent overwriting of form data
    my $filename = $remotefile;
    
    my $title = param("title$num");
    my $desc = param("desc$num");
    
    # remove all directories in the file name path
    $filename =~ s/^.*[\\\/]//;

    # full file path to upload directory (must include filename)
    my $localfile = "/home/sulfericacid/public_html/playground/upload/files/$filename";

    # full url to upload directory (cannot include filename or an end
slash /)
    my $url = "http://sulfericacid.perlmonk.org/playground/upload/files";

    my $type = uploadInfo($remotefile)->{'Content-Type'};
    unless ( $type eq 'image/pjpeg' || $type eq 'image/gif' || $type
eq 'image/bmp') {
        print "Wrong!  This is not a supported file type.";
        exit;
    }

    # open a new file and transfer bit by bit from what's in the
buffer
    open( SAVED, ">>$localfile" );    # || die $!;
    while ( $bytesread = read( $remotefile, $buffer, 1024 ) ) {
        print SAVED $buffer;
    }
    close SAVED;

    chmod $mode, "$localfile";        # or die "can't chmod: $!";

    # required since module was not preinstalled on server
    use lib "/home/sulfericacid/public_html/lib/";
    use Image::Info qw(image_info dim);
  
    # assigning info to a filename (better be an image)
    my $info =
      image_info("$localfile");
   # if for any reason we can't open the file, this error trap should
pick it up
    if ( my $error = $info->{error} ) {
        #die "Can't parse image info: $error\n";
    }
    # unommit next line if you want to use/post the image's color
    #my $color = $info->{color_type};

    # declaring the width and heighth of your image
    my ( $w, $h ) = dim($info);

my $combo = join("::", $filename, $title, $desc, $w, $h);
$upload{localtime()} = "$combo";



    print "<br>";
    print "<b>File:</b><br>";
    print
qq(File was uploaded to <a
href="$url\/$filename">$url\/$filename</a><br>);
    print
qq(&lt;p style =\"background:url\($url\/$filename\)\;width:$w\;height:$h\;\"&gt;);
print "<br>";
}


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

Date: Fri, 05 Sep 2003 15:56:18 GMT
From: Jeff Thies <cyberjeff@sprintmail.com>
Subject: finding instance of object
Message-Id: <3F58B342.468C3B1D@sprintmail.com>

  I have an object and I like to print the instance of the object;

my $object_name=new MyObj();
my $object_name2=new MyObj();

package MyObj;

sub new{
my $class = shift;
my $self = {};

 ...

sub printInstance{
my $self=shift;

print " I'd like to print $object_name, can I do that or do I need to
pass it in directly as a property?: my $object_name=new
MyObj('object_name');";

 ...

I don't remember reading about that in the perl OO guides, but I may
have missed it.

  Cheers,
Jeff


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

Date: Fri, 5 Sep 2003 17:43:47 +0100
From: "Raquel Marques" <rtavares@tec.dsr.telecom.pt>
Subject: maximum input buffer length exceeded: 1048576
Message-Id: <e336b.1474$lA1.1038379@newsserver.ip.pt>


  Hello, when I run a script in perl, it returns the above message.
 Any ideas how can I solve this problem .

Thanks

Raquel Marques




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

Date: Fri, 5 Sep 2003 17:03:41 +0000 (UTC)
From: Vlad Tepes <minceme@start.no>
Subject: Re: maximum input buffer length exceeded: 1048576
Message-Id: <bjafld$k8b$1@troll.powertech.no>

Raquel Marques <rtavares@tec.dsr.telecom.pt> wrote:

>
>   Hello, when I run a script in perl, it returns the above message.
>  Any ideas how can I solve this problem .

http://www.google.com/search?q=maximum+buffer+perl+1048576

First hit has the answer: You probably have trouble with newlines.
Perl reads line by line, and has encountered a line that is over 1 MB.

Things you can try: (1) Convert the file to proper lineendings (this
depends on your platform), (2) read in smaller chunks of the file with
read(), or (3) alter the input record separator ( $/, see perldoc
perlvar ). 

-- 
Vlad


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

Date: 5 Sep 2003 10:17:11 -0700
From: dna@888.nu (Marcus Brody)
Subject: Re: My perl script is "Killed" - Ran out of memory
Message-Id: <1ab76986.0309050917.5004791a@posting.google.com>

>Don't store as much!  (If you told us what you were doing, I might be
>able to tell you how to not store as much.


It's (somebody elses) biological data.  This isn't even the raw data,
which would be too huuuuge to even imagine....  Therefore it isnt my
fault I am storing so much.  Biological data is notorious ;-)

I am parsing it to extract/aggregate the small percentage which is
useful to me.

>Aggregating how?  sum, count, min, max by group?  by how many groups?

Essentially, there are a couple of useful things in the "excel" (tab
delimetid) files I want to grab hold of.  Each file is a table with
columns denoting ID number, gene name, lots of associated info,
various results, normalisations and statistical calculations etc. 
Each row is the results of a single "experiment", giving values for
the above fields.

The same gene appears in many experiments.  I want to aggregate the
data for genes togethor for one of the results.  E.g. So for each
gene, I have every result for one type of experiment ordered togethor.
 To give an example of my data structure, this is what I spit out at
the end:



foreach my $key (keys %genes) {

	#This is the gene name, followed by how many experiments were for
that gene
	print "$key   $genes{$key}{occurences}\t";

	#These are all the values for the experimental results for that gene.
	#The number of results varies from gene to gene.
	foreach my $value ( @{$genes{$key}{result_value}} ) {
		print "$value\t"; 
	}
	print "\n";
} 

#please excuse poor code, I am a newbie to *all of this*
Furthermore, there is some other associated info in that hash, wich i
am not printing out at this stage, but may wish to when the thing is
working.


>> I guestimate that my data structure contains 250 million
>> variables (all very simple - either decimal points (to about 6
places)
>> or short names).
>
>This is what the input data structure is, or this is what the working
>memory structure is?  If stored in standar Perl variables, that's
going to
>be at least 5 gig, even if you they are all floats and never used in
a
>stringish way.

The input data is lots more than that.  I figure I would have around
50,000 genes * 2500 results stored in my hash at the end.

>> Any ideas how I could stop running out of memory?  Declaring data
>> types ala C?
>>
>You could use "pack" to pack the data into C-type variables that are
>held (in bulk) in strings.  But that would still take at least 1 gig,
>and I assume you actually want to do something with these numbers,
which
>would be difficult if they are all packed.

Yes I do want to do something else with the numbers, but printing them
out would be fine for now.  Once I have everything sorted in a logical
way, I can easily do what I want to.

>Does your output consists of all 250 million items?  If not, then
>perhaps you don't need to store them all afterall.

Yes my output does, and I do need them all.  Is there a cleverer way I
could print them out as I was going along?  E.g. I could have each
gene name that i come across inserted at the beggining of the next
free row, and then put the associated results value in the appropriate
place in the file.

Thanks

MB



Xho


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

Date: 5 Sep 2003 08:15:03 -0700
From: eric.chin@pinnacle.co.uk (Eric)
Subject: NT: perl 5.8.0: system call - commnad split into multiple line ?
Message-Id: <d8c847cd.0309050715.35097f1@posting.google.com>

Greetings,

I am fairly new to Perl. I downloaded Perl 5.8.0 for NT/Win2000
platform.

I want to copy file from server1 to server2 using robocopy. In my perl
script:

$datenow = `date /T`;
($day,$mth,$yr) = split /\//, $datenow;

$src = "\\\\server1\\d1\\$yr\\$mth";
$dest = "\\\\server2\\d2\$yr\\$mth";
$swth = "\/r:1 \/w:5 \/MIR";

$comm = "robocopy $src\\$yr\\$mth $dest\\$yr\\$nth $swth";

print "system($comm)";

When I checks the system($comm) construct using print, it shows the
$comm string in multiple lines. For example:

system(robocopy \\server1\d1\2003
\09 \\server2\d2\2003
\09 /r:1 /w:5 /MIR)

Is there any way to get the $comm string into one line ? I believe
because it split into multiple line, robocopy gets the parameter wrong
and therefore won't work.

Did I miss something ? Can anyone help ?

Any pointer appreciated.

TIA

Eric


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

Date: Fri, 05 Sep 2003 16:04:05 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: NT: perl 5.8.0: system call - commnad split into multiple line ?
Message-Id: <Xns93ED7AC20B8C6dkwwashere@216.168.3.30>

Eric <eric.chin@pinnacle.co.uk> wrote:

> Greetings,
> 
> I am fairly new to Perl. I downloaded Perl 5.8.0 for NT/Win2000
> platform.
> 
> I want to copy file from server1 to server2 using robocopy. In my
> perl script:
> 

For your own safety and sanity, enable strict and warnings:

    use strict;
    use warnings;

Among other things, 'strict' will force you to declare your 
variables, and warnings will tell you about all sorts of real and 
potential errors.  Unless you have a good reason otherwise, these two 
statements should start all your programs.  

> $datenow = `date /T`;

$datenow has a newline on the end of it.  (Actually CR-LF since this 
is windows, but never mind.)

> ($day,$mth,$yr) = split /\//, $datenow;

Now $yr has a newline on the end of it.

Instead of calling an external program, it's usually easier to use 
Perl's localtime() function.

    my ($day, $mth, $yr) = (localtime)[3,4,5];
    $yr += 1900;  
    $mth++;

perldoc -f localtime

> $src = "\\\\server1\\d1\\$yr\\$mth";
> $dest = "\\\\server2\\d2\$yr\\$mth";
> $swth = "\/r:1 \/w:5 \/MIR";

There's no need to escape the forward-slashes here.  You're not 
inside a slash-delimited regex.

> $comm = "robocopy $src\\$yr\\$mth $dest\\$yr\\$nth $swth";

If you had enabled strict or warnings (or both), perl would have 
given you an error message when you tried to use $nth.

> print "system($comm)";
> 
> When I checks the system($comm) construct using print, it shows
> the $comm string in multiple lines. For example:
> 
> system(robocopy \\server1\d1\2003
> \09 \\server2\d2\2003
> \09 /r:1 /w:5 /MIR)

Yes, right after each place where you use $yr.

> Is there any way to get the $comm string into one line ? I believe
> because it split into multiple line, robocopy gets the parameter
> wrong and therefore won't work.

No, it's because `date /t` returns a string with a newline on the 
end.

-- 
David Wall


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

Date: Fri, 5 Sep 2003 08:47:40 -0700
From: "Trent Curry" <tcurrey@no.no.no.i.said.no>
Subject: Re: perl  -w  example.pl
Message-Id: <bjabb1$500$1@news.astound.net>

"Steve Rathkopf" <srathkopf@juno.com> wrote in message
news:ae8d5bef.0309041541.5ac01f7a@posting.google.com...
> I have 'successfully' downloaded ActiveState's Perl 5.8.0 and, per the
> instructions, opened a window and entered the text in the subject line
> above.
>
> When I press the return key, nothing happens, the cursor just sits at
> the start of the next line.
>
> The program was to print one line of text, but does nothing.
>
> The above behaviour is exhibited whether I start an MS-DOS session
> from the PROGRAMS menu, or activate one of the Perl applications in
> the Perl directory.
>
> I was studying Perl on the Unix machine where I just completed a
> contract, and may simply be confused, because this is NOT Unix.  I had
> NO problems, aside from the need to debug, on the Unix machine.  Now,
> I can't even print a one liner from the prompt.
>
> Can someone point me in the correct direction?
>
> Thanks, in advance,
> Steve Rathkopf

Note, in windows, you need to surround the code in ""s, not ''s, as in
   perl -e "print qq{Hello\n};"
or
   perl -e "print 'Hello';"

(The former being able to handle escapes like \n.)




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

Date: Fri, 05 Sep 2003 16:06:18 +0100
From: Mark <REMOVEXtwoheadsX@tiscaliX.co.uk>
Subject: Re: Perl, javascript and CGI
Message-Id: <4j9hlvc9dav766pi9ka469c5l26tejlbp5@4ax.com>

Hi Saya, 

I am not an expert at these things but you might want to try this perl
code to get hold of the parameters. It does not require you to specify
the parameters by name

######Get the data from the form 
my $query = new CGI;
my @keywords = $query->param;
my $sizeKeywords = @keywords;

#####put key value pairs returned from form into a hash
my %values;
foreach my $val(@keywords){
	$values{$val} = $query->param("$val");
}

If its the javascript that is not operating as expected, what about
using a document.write statement to write a form action url with
keyvalue pairs attached or to write hidden inputs within the form with
each value of the array in a seperate input?

Hope that helps, 

Mark



On 5 Sep 2003 06:03:52 -0700, vahu@novonordisk.com (Saya) wrote:

>Hi, 
>
>I have the following scenario in a system that we run. From a webpage
>using javascript I am able to invoke a *.ipl script on the server and
>pass parameters as well:
>
>javascript param parsing: 
>parameters = new Object();
>parameters.iw_arrArtikelIDs	= arrArtikelsToExtract;
>callServer("test.ipl", parameters, true);
>
>*.ipl param extraction:
>my${cgi} = new CGI();
>my $arrArtikelIDs = ${cgi}->param('iw_arrArtikelIDs');
>
>The issue here is that arrArtikelsToExtract is a java array containing
>ID's that I need to process in the *.ipl script. I can't seem to get
>it to work.
>I thought I was so lucky that I could get away with saying something
>like the below in the *.ipl script:
>my @arrArtikelIDs = ${cgi}->param('iw_arrArtikelIDs');
>
>Does anyone have any hints/clues/way(s) of achieving this. Parsing an
>array from javascript to an ipl script ?



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

Date: 5 Sep 2003 10:52:25 -0700
From: raven_riverwind@yahoo.com (raven)
Subject: Regexp Help
Message-Id: <7270d1f8.0309050952.3154538e@posting.google.com>

The output of lpstat -p on hpux returns this:

printer sacprn05 is idle.  enabled since Jul 30 12:23
        fence priority : 0

I am attempting to grab the printer name and whether or not it is
idle. The code to do this is:

if (/^printer (\w+).*(enabled|disabled)/)

Is there a more efficient way to obtain the desired information using
a Perl regexp?


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

Date: 5 Sep 2003 09:10:03 -0700
From: jimmy_armand@hotmail.com (Jimmy)
Subject: Repost Search
Message-Id: <72ea1877.0309050810.412f2119@posting.google.com>

while( <FILEHANDLE> or <FILEHANDLETWO>)
{
   $mesAlertes = <FILEHANDLE>;
   $mesAlertesDeux = <FILEHANDLETWO>;
   $final = ($mesAlertes, $mesAlertesDeux);
   
   print $final;
}

Want to make a search in two files, and print data on screen. But if
the files have the same data, the data will be display once. My code
don't work. why?

BTW, i'm a newbie, so thanks to be patient :)


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

Date: Fri, 05 Sep 2003 16:49:39 GMT
From: "Tom Wong" <tom.wong@verizon.net>
Subject: Re: Repost Search
Message-Id: <D836b.238$w41.163@nwrdny02.gnilink.net>

"Jimmy" <jimmy_armand@hotmail.com> wrote in message
news:72ea1877.0309050810.412f2119@posting.google.com...
> while( <FILEHANDLE> or <FILEHANDLETWO>)
> {
>    $mesAlertes = <FILEHANDLE>;
>    $mesAlertesDeux = <FILEHANDLETWO>;
>    $final = ($mesAlertes, $mesAlertesDeux);

$file = $mesAlertes;
if( $file ne $mesAlertesDeux) { $file .= $mesAleresDeux }

>
>    print $final;
> }
>
> Want to make a search in two files, and print data on screen. But if
> the files have the same data, the data will be display once. My code
> don't work. why?
>
> BTW, i'm a newbie, so thanks to be patient :)

Tom
ztml.com




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

Date: Fri, 05 Sep 2003 16:58:03 GMT
From: "Tom Wong" <tom.wong@verizon.net>
Subject: Re: Repost Search
Message-Id: <vg36b.263$w41.64@nwrdny02.gnilink.net>


"Tom Wong" <tom.wong@verizon.net> wrote in message
news:D836b.238$w41.163@nwrdny02.gnilink.net...
> "Jimmy" <jimmy_armand@hotmail.com> wrote in message
> news:72ea1877.0309050810.412f2119@posting.google.com...
> > while( <FILEHANDLE> or <FILEHANDLETWO>)
> > {
> >    $mesAlertes = <FILEHANDLE>;
> >    $mesAlertesDeux = <FILEHANDLETWO>;
> >    $final = ($mesAlertes, $mesAlertesDeux);
>
> $file = $mesAlertes;
> if( $file ne $mesAlertesDeux) { $file .= $mesAleresDeux }

oops... $file should be $final

>
> >
> >    print $final;
> > }
> >
> > Want to make a search in two files, and print data on screen. But if
> > the files have the same data, the data will be display once. My code
> > don't work. why?
> >
> > BTW, i'm a newbie, so thanks to be patient :)
>
> Tom
> ztml.com
>
>




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

Date: Fri, 05 Sep 2003 17:20:43 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Repost Search
Message-Id: <Xns93ED87BF89508dkwwashere@216.168.3.30>

Jimmy <jimmy_armand@hotmail.com> wrote:

From http://mail.augustmail.com/~tadmc/clpmisc.shtml

    Ask perl to help you

    You can ask perl itself to help you find common programming
    mistakes by doing two things: enable warnings (perldoc warnings)
    and enable ``strict''ures (perldoc strict). 

That wouldn't help you with this problem, but it will in the future 
with other problems.  

Picking a better Subject would help, too.  "Repost Search" doesn't 
actually say much about your question.


It's interesting that 'perldoc -q strict' doesn't find anything.  The 
use of strictures and warnings is such common advice here in clpm 
that you'd think it would be in the FAQ as "Why should I 'use 
strict' and 'use warnings'?"  Sure, you can look at 'perldoc strict' 
and 'perldoc warnings', but those docs are pretty heavy-duty for a 
beginner -- and a beginning Perl hacker probably needs them more than 
experienced folk.



> while( <FILEHANDLE> or <FILEHANDLETWO>)

Reads a line from FILEHANDLE, stores it in $_, then reads a line
from FILEHANDLETWO and stores it in $_, overwriting the line from
FILEHANDLE. 


> {
>    $mesAlertes = <FILEHANDLE>;
>    $mesAlertesDeux = <FILEHANDLETWO>;

If you are at the end of either file, you'll get an error from one
of these lines. 

>    $final = ($mesAlertes, $mesAlertesDeux);

I don't think that does what you seem to think it does.  You're using 
the comma operator in a scalar context, which will put the value of
$mesAlertesDeux into $final.  See 'perldoc perlop' and look for 
"Comma Operator".  (If it makes you feel better, I made the same 
mistake in one of my first posts here and was promptly corrected.)

>    
>    print $final;
>}
> 
> Want to make a search in two files, and print data on screen. But
> if the files have the same data, the data will be display once. My
> code don't work. why?
> 
> BTW, i'm a newbie, so thanks to be patient :)

If I understand you correctly, something like this may be what you 
want.  

[untested]

while(1) {
    last if eof(FILEHANDLE) or eof(FILEHANDLETWO);
    my $mesAlertes     = <FILEHANDLE>;
    my $mesAlertesDeux = <FILEHANDLETWO>;
    if ($mesAlertes eq $mesAlertesDeux) {
        print $mesAlertes;
    }
    else {
        chomp $mesAlertes;
        print "*** $mesAlertes *** $mesAlertesDeux";
    }
}

This will stop printing when it reaches the end of the file with the 
fewest lines.

-- 
David Wall


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

Date: Fri, 05 Sep 2003 18:03:43 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Repost Search
Message-Id: <3F58CFE1.BF9DD5E8@acm.org>

"David K. Wall" wrote:
> 
> Jimmy <jimmy_armand@hotmail.com> wrote:
> 
> > while( <FILEHANDLE> or <FILEHANDLETWO>)
> 
> Reads a line from FILEHANDLE, stores it in $_, then reads a line
> from FILEHANDLETWO and stores it in $_, overwriting the line from
> FILEHANDLE.

No, nothing gets stored in $_.

perldoc perlop
[snip]
    Ordinarily you must assign the returned value to a variable, but
there
    is one situation where an automatic assignment happens. If and only
if
    the input symbol is the only thing inside the conditional of a
`while'
    statement (even if disguised as a `for(;;)' loop), the value is
    automatically assigned to the global variable $_, destroying
whatever
    was there previously. (This may seem like an odd thing to you, but
    you'll use the construct in almost every Perl script you write.) The
$_
    variables is not implicitly localized. You'll have to put a `local
$_;'
    before the loop if you want that to happen.



John
-- 
use Perl;
program
fulfillment


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

Date: 5 Sep 2003 09:05:51 -0700
From: jimmy_armand@hotmail.com (Jimmy)
Subject: Search
Message-Id: <72ea1877.0309050805.6a2190dc@posting.google.com>

I have two files in a tmp directorie. each file have some data in
them. Some data are the same. I want to search in the files (with file
handles), and display the data on screen. But if they have the same
data in both files, display the data once. Here's my code but doesn't
work. Not all the data is display:

while( <FILEHANDLE> or <FILEHANDLETWO>)
{
   $mesAlertes = <FILEHANDLE>;
   $mesAlertesDeux = <FILEHANDLETWO>;
   $final = ($mesAlertes, $mesAlertesDeux); #take data in both
                                            #but display once if the
data
                                            #is the two files...
   
   print $final;
}

What's wrong???


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

Date: Fri, 05 Sep 2003 16:58:54 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: Telling perl to expect input data to be in UTF8 (no HTML this time)
Message-Id: <3F58B2BE.F937B9@oracle.com>

This is a multi-part message in MIME format.
--------------F5A98EF7A6EDA2BCE24F2FFC
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Hi all,

I've got this friend who's using perl 5.6.1 and DBI to import data that
is in UTF8 and he is unable to display the data successfully
after it imports from the database.  I read in perldoc perlunicode
shipped with 5.6.1 that you can't tell perl to expect UTF8 data
from an external file or source but that it would shortly be addressed
in a future version.  Can anyone tell me if this has happened
yet, and if so, in which version of perl it is available?

Thanks

Graham


--------------F5A98EF7A6EDA2BCE24F2FFC
Content-Type: text/x-vcard; charset=UTF-8;
 name="Graham.T.Wood.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Graham Wood
Content-Disposition: attachment;
 filename="Graham.T.Wood.vcf"

begin:vcard 
n:;Graham
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:Graham.Wood@oracle.com
fn:Graham Wood
end:vcard

--------------F5A98EF7A6EDA2BCE24F2FFC--



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

Date: Fri, 05 Sep 2003 17:12:08 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: Telling perl to expect input data to be in UTF8 (plain at last) 
Message-Id: <3F58B5D8.6F3AF51@oracle.com>

Graham Wood wrote:
> 
> Hi all,
> 
> I've got this friend who's using perl 5.6.1 and DBI to import data that
> is in UTF8 and he is unable to display the data successfully
> after it imports from the database.  I read in perldoc perlunicode
> shipped with 5.6.1 that you can't tell perl to expect UTF8 data
> from an external file or source but that it would shortly be addressed
> in a future version.  Can anyone tell me if this has happened
> yet, and if so, in which version of perl it is available?
> 
> Thanks
> 
> Graham

Humble apologies to all who have killfiled me for HTML crimes in the
plain text newsgroup.  I foolishly thought when I asked Netscape to send
in plain text only that's what it would do.  I have now scraped all
traces of html from my messages.

Graham


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

Date: Fri, 05 Sep 2003 15:36:42 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Telling perl to expect input data to be in UTF8
Message-Id: <Xns93ED761D74D99dkwwashere@216.168.3.30>

Graham Wood <Graham.T.Wood@oracle.com> wrote:

><!doctype html public "-//w3c//dtd html 4.0 transitional//en">
><html>
> Hi all,
><p>I've got this friend who's using perl 5.6.1 and DBI to import
>data that 
> is in UTF8 and he is unable to display the data successfully after
> it imports from the database.&nbsp; I read in perldoc perlunicode
> shipped with 5.6.1 that you can't tell perl to expect UTF8 data
> from an external file or source but that it would shortly be
> addressed in a future version.&nbsp; Can anyone tell me if this
> has happened yet, and if so, in which version of perl it is
> available? 
><p>Thanks
><p>Graham</html>
[snip vcard crap]

I don't know the answer to your question, but I do know that by 
posting in HTML you made your post invisible to at least some of the 
people most likely to be able to answer your question.  (They have 
their newsreaders configured to basically ignore posts that aren't 
plain text.)  The ones that did notice it probably took one look at 
the HTML and went to the next article.

Hint, hint. :-)

-- 
David Wall


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

Date: 05 Sep 2003 11:48:23 -0400
From: Ryan Shondell <shondell@cis.ohio-state.edu>
Subject: Re: View NG with Net::NNTP
Message-Id: <xcwy8x3grso.fsf@psi.cis.ohio-state.edu>

tom@ztml.com (Tom) writes:

> PERL will assume alots of stuff if you don't specify something to operate
> on. In the example, you can enter print $_ or just print, or in what
> you have discovered by leaving it out all together, and PERL will take care
> the rest.

Actually, PERL won't do any of that. Using perl will allow you to
parse Perl, but all PERL does is tell everyone you didn't read the
perlfaq. :-)

perldoc -q '"perl" and "Perl"'

<end picking of nits> :-)

Ryan
-- 
perl -e '$;=q,BllpZllla_nNanfc]^h_rpF,;@;=split//,
$;;$^R.=--$=*ord for split//,$~;sub _{for(1..4){$=
=shift;$=--if$=!=4;while($=){print chr(ord($;[$%])
+shift);$%++;$=--;}print " ";}}_(split//,$^R);q;;'


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

Date: 5 Sep 2003 08:08:56 -0700
From: plm@gmx.li (Peter Mutsaers)
Subject: Weird interaction between Net::FTP and DBI / DBD::Oracle
Message-Id: <9769adc8.0309050708.2deeaae@posting.google.com>

Using perl 5.8.0 and latest versions of libnet and DBI:

The script did 

- open DBI to oracle
- start queries and write in 2 files
- close files
- close DB
- open FTP (Net::FTP->new)

result: the open FTP fails immediately with a connection timeout, even
though the timeout is 120s (I also tried some other explicit settings
and traced into IO::Socket).

When I reverse the 2 last steps, i.e. I close the DB handle after the
Net::Ftp->new, there is no problem.

Note: the FTP->new fails only when the server takes more than about 1
second to respond. For fast local servers the problem did not occur at
all.

Someone has an idea how this can be? Could the closing of the
DBD::Oracle handle throw some signal (this is on Solaris btw) after 1
second which confuses IO::Socket?

Thanks,

Peter Mutsaers


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

Date: Fri, 5 Sep 2003 09:03:58 -0700
From: "Islaw" <islaw@adexec.com>
Subject: Re: What ever happened to comp.lang.perl ?
Message-Id: <bjac5g$guivj$1@ID-196529.news.uni-berlin.de>

"Helgi Briem" <f_baggins80@hotmail.com> wrote in message
news:3f57599a.270998745@News.CIS.DFN.DE...
>
> You really are a funny little man, Manny.  Every six
> months or so you come here with a few new names
> and fake e-mail addresses, throw a tantrum over
> something silly, then get tired and go away.

> What is your beef?  Why do you keep coming back
> for more?  You are so bad at hiding your identity
> that it is usually obvious  in your first post.

I think you both need to get a life. You folks seem to think you can just
target anyone and then tarnish their name without any discernable proof,
just insipid rants with no semblance of the truth. You ask whats Trent's
beef? well, what is YOUR beef? Do tell, what exactly, has he (or I for that
matter, since you folk have once again included me in your "grand" list)
actually done to deserve such treatment? Is this, perchance, why so many
left this group? Because of pointless bull crap and arguments being lobbed
around like grenades? I honestly cannot begin to comprehend the reason you
folk try to do this to seemingly random people.

And I thought this was a technical news group, not alt.tv.jerry-springer

-- 
Islaw




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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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


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