[22858] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5079 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 5 14:05:45 2003

Date: Thu, 5 Jun 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           Thu, 5 Jun 2003     Volume: 10 Number: 5079

Today's topics:
        and if I killed this programmer *I'd* go to jail.. (Sara)
        background process <john62@electronmail.com>
    Re: background process <nobull@mail.com>
    Re: capturing output of executed system command <nospam@raytheon.com>
    Re: Daemon Script n' system() function - for gurus: Ran <grazz@pobox.com>
    Re: Email Extraction (Avatar)
    Re: html parser questions <tequila-stuff@cox.net>
    Re: Hy guys,I need some help(opening directories) <glex_nospam@qwest.net>
    Re: Is it possible to do ? <noreply@gunnar.cc>
    Re: Is it possible to do ? <beaudet@cyber.kodak.com>
    Re: Is it possible to do ? <minceme@start.no>
        Newbie: Perl and GET / POST <jon@rogers.tv>
    Re: Newbie: Perl and GET / POST <noreply@gunnar.cc>
    Re: Parsing issue <tzz@lifelogs.com>
    Re: Posting to an asp form with hidden fields <nospam@raytheon.com>
    Re: Printing VISIO documents using PERL. (Chad Johnson)
    Re: Problems with & operator <shanem@nospam.ll.mit.edu>
        Push adding space to start of items (Mark Smith)
    Re: Push adding space to start of items <noreply@gunnar.cc>
    Re: Push adding space to start of items <mpapec@yahoo.com>
    Re: Push adding space to start of items <barryk2@SPAM-KILLER.mts.net>
    Re: Push adding space to start of items <drumspoorly@reachone.net>
    Re: Push adding space to start of items (Gary E. Ansok)
    Re: regex based on numeric value <nobull@mail.com>
    Re: Regex with numeric evaluation <nobull@mail.com>
    Re: Time limit <mbudash@sonic.net>
        UK script writer wanted <nntp@cannabiscoffeeshops.co.uk.INVALID>
    Re: Yabb woes. (Christopher Hamel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 5 Jun 2003 10:58:35 -0700
From: genericax@hotmail.com (Sara)
Subject: and if I killed this programmer *I'd* go to jail..
Message-Id: <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]";     } 

I'll be in rehab before this project is though.. ACK....

Gx


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

Date: Thu, 05 Jun 2003 13:32:33 -0400
From: j <john62@electronmail.com>
Subject: background process
Message-Id: <3EDF7EB1.104@electronmail.com>

does anyone know how to start a background process running from a perl 
cgi script?

basically, i have this server that keeps crashing, and i want a cgi 
script to check if it's up and, if not, start it.

thx.

-- 
-------------------------------------------------------------
Coldmail.us offers free web access to newsgroups.
http://www.coldmail.us/
-------------------------------------------------------------



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

Date: 05 Jun 2003 18:35:54 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: background process
Message-Id: <u9llwg8m11.fsf@wcl-l.bham.ac.uk>

j <john62@electronmail.com> writes:

> does anyone know how to start a background process running from a perl
> cgi script?

In order to help us improve the documentation, can you indicate the
ways in which you have found the answer given in the FAQ to be
defficient?

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


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

Date: Thu, 05 Jun 2003 12:31:31 -0500
From: Chris Olive <nospam@raytheon.com>
Subject: Re: capturing output of executed system command
Message-Id: <E7LDa.3469$c6.3124@bos-service2.ext.raytheon.com>

benson limketkai wrote:
> suppose i have:
> 
> system 'ps'
> 
> how can i redirect the output into an array?
> 
> thanks,
> benson
> 

I prefer writing a "shell()" wrapper to do this sort of thing:

sub Shell {
    my @output;
    foreach (@_) { push( @output, `$_` ) }
    chomp( @output );
    return wantarray ? @output : \@output;
}

Then you can:

my @rv = Shell( "Command 1", "Command 2", "Command 3" );

or run Shell() over a batch of commands rather easily:

my @rv;
foreach (@batch) { push( @rv, Shell( $_ ) } }
## @rv contains output from entire batch

Chris
-----
Chris Olive
Systems Consultant
Raytheon Technical Services Corporation
Indianapolis, IN

email: olivec(AT)indy(DOT)raytheon(DOT)com



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

Date: Thu, 05 Jun 2003 17:50:20 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Daemon Script n' system() function - for gurus: Randal L. Schwartz, Larry Wall, Joseph N. Hall, and others
Message-Id: <wpLDa.10841$b8.7398@nwrdny03.gnilink.net>

Euler <eulerpereira@hotmail.com> wrote:
> Steve Grazzini <grazz@pobox.com> wrote:
>> Euler <eulerpereira@hotmail.com> wrote:
>> > but when i try execute system( 'system_command' ) function from
>> > daemon, the return code ( $? ) from system() is -1. The same happens
>> > when i try use quotation `system_command` or exec( 'system_command' ).
>> > 
>> > but, the command is executed sucefully!!! What's wrong?
>> 
>> Try to come up with a short[*] script that actually demonstrates
>> the problem you're having.
> 
> thanx for responding my question Steve, my apologies here's the
> output:
> 
> Thu Jun  5 10:03:18 2003 zeus daemon [debug] Starting...
> Thu Jun  5 10:03:18 2003 zeus daemon [debug] PID: 15842
> Thu Jun  5 10:03:18 2003 zeus daemon [debug] Command Executed: -1: No
> child processes
>
> The last line point to the command executed sucefully ( this is truth,
> i try use 'touch /foo.foo' instead 'ls' and '/foo.foo' is created each
> 60 seconds, but the return code maintain -1 (Return value of -1
> indicates a failure to start the program - help manpage).

That looks like an error and return value from wait().  And you had a
looping $SIG{CHLD} handler, so it's possible that the $? and $! you see
have nothing to do with system().

In fact, if -- going above and beyond the call of duty -- I change your 
main loop to look like this:

  if ( !system("touch ~/foo.pid") ) {
      _log(_msg(Command Executed: $?: $!\n":
  }
  else {
      _log(_msg(Command Failed: $?: $!\n":
  }

I get exactly the output you describe.  But this doesn't mean that
system() failed or returned -1; it has actually returned zero, but
I printed $? in the wrong branch.

-- 
Steve


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

Date: 5 Jun 2003 09:37:02 -0700
From: ksu1wd@mit.edu (Avatar)
Subject: Re: Email Extraction
Message-Id: <415d5171.0306050837.fad2eae@posting.google.com>

> 	  print "Received:", 	$message->{ReceivedTime}, "\n";
that returns Received:Win32::OLE::Variant=SCALAR(0x1a4a9e0)
I think that is hex
But how do we go from that to decimal?


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

Date: Thu, 05 Jun 2003 00:43:48 GMT
From: "j" <tequila-stuff@cox.net>
Subject: Re: html parser questions
Message-Id: <8nwDa.1067$dZ5.707@news1.east.cox.net>

You're right, it was right in front of me.  Thanks.


"Janek Schleicher" <bigj@kamelfreund.de> wrote in message
news:pan.2003.06.05.02.58.29.86939@kamelfreund.de...
> j wrote at Wed, 04 Jun 2003 19:48:55 +0000:
>
> > In perldoc, they give the example below to parse the title from an html
> > document.  Can someone explain what shift->eof if shift eq "title";
does
> > in the line marked with ->?    What I could use is a code example of a
> > start handler that can pass the title text back in the return value.
>
> I would guess that the first argument to the handler routine contains the
> currently parsed tag.
> If you are only interested in the title tag it is logical to
> return unless it's 'title'.
>
> The line marked by you is explained in another part of the perldoc to
> HTML::Parser:
>
>            Calling $p->eof inside a handler will terminate
>            parsing at that point and cause $p->parse to return a
>            FALSE value.  This also terminates parsing by
>            $p->parse_file().
>
> Alltogether (including the line before), the result is that the text of
> the title is printed.
>
> >       use HTML::Parser ();
> >
> >       sub start_handler
> >       {
> >         return if shift ne "title";
> >         my $self = shift;
> >         $self->handler(text => sub { print shift }, "dtext");
> > ->        $self->handler(end  => sub { shift->eof if shift eq
"title"; },
> >                                "tagname,self");
> >       }
> >       }
> >       my $p = HTML::Parser->new(api_version => 3); $p->handler( start =>
> >       \&start_handler, "tagname,self"); $p->parse_file(shift || die) ||
> >       die $!; print "\n";
>
>
> Greetings,
> Janek




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

Date: Thu, 05 Jun 2003 10:43:09 -0500
From: "J. Gleixner" <glex_nospam@qwest.net>
Subject: Re: Hy guys,I need some help(opening directories)
Message-Id: <WtJDa.52$bF2.19411@news.uswest.net>

C Marshall wrote:
> tadmc@augustmail.com (Tad McClellan) wrote in message 
> 
>>>Can someone explain me what's wrong with my code?
>>
>>It is not indented so as to reveal its structure.
> 
> 
> 
> Speaking of which is there an equivalent of "cb" for tidying up perl
> code ?
> 
> I just tried running cb on a perl script - it makes a valiant attempt
> though the {}s in hashes are thrown apart.

Please, in the future, avoid posting an unrelated question within a 
discussion.  Post a new one with an appropriate subject.

perldoc -q "Is there a pretty-printer"



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

Date: Thu, 05 Jun 2003 17:58:15 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Is it possible to do ?
Message-Id: <bbnpb1$bf8c4$1@ID-184292.news.dfncis.de>

Gunnar Hjalmarsson wrote:
> Jean-Luc BEAUDET wrote:
> 
>> ($dtt = Date_to_Text($year,$month,$day)) =~ tr/ /-/s;     # 1
>> @dtt = split /-/, $dtt;                                   # 2
>>
>> $pattern = $dtt[0]." ".$dtt[2]." ".$dtt[1];
>>
>> Does some one knows about a way to write lines #1 & #2 in only one
>> line ???
> 
>     @dtt = split /[ -]/, Date_to_Text($year,$month,$day);

Or you can replace all three lines with:

     $pattern = join ' ',
       (split /[ -]/, Date_to_Text($year,$month,$day))[0,2,1];

:)

/ Gunnar

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Thu, 05 Jun 2003 18:07:42 +0200
From: Jean-Luc BEAUDET <beaudet@cyber.kodak.com>
Subject: Re: Is it possible to do ?
Message-Id: <3EDF6ACE.2060206@cyber.kodak.com>

Thanks a lot, Gunnar !

It works great.

Seems so easy, after word :-(

Jean-Luc B :-)

Gunnar Hjalmarsson wrote:

> Jean-Luc BEAUDET wrote:
>
>> ($dtt = Date_to_Text($year,$month,$day)) =~ tr/ /-/s;     # 1
>> @dtt = split /-/, $dtt;                                   # 2
>>
>> $pattern = $dtt[0]." ".$dtt[2]." ".$dtt[1];
>>
>> Does some one knows about a way to write lines #1 & #2 in only one
>> line ???
>
>
>     @dtt = split /[ -]/, Date_to_Text($year,$month,$day);
>
> / Gunnar
>



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

Date: Thu, 5 Jun 2003 16:11:26 +0000 (UTC)
From: Vlad Tepes <minceme@start.no>
Subject: Re: Is it possible to do ?
Message-Id: <bbnq3e$pg1$1@troll.powertech.no>

> Jean-Luc BEAUDET <beaudet@cyber.kodak.com> wrote:

(...)

> ($year,$month,$day) = Today();
>
> ($dtt = Date_to_Text($year,$month,$day)) =~ tr/ /-/s;     # 1
> @dtt = split /-/, $dtt;                                   # 2
>
> $pattern = $dtt[0]." ".$dtt[2]." ".$dtt[1];
>
> Does some one knows about a way to write lines #1 & #2 in only one
> line ???

You could do:

    s/\n//g;    #:-)

Or (split on space or dash):

    @dtt = split /[ -]/, Date_to_Text($year,$month,$day);
    $pattern = "$dtt[0] $dtt[2] $dtt[1]";

Or (without Date::Calc):

    $pattern = substr scalar localtime(), 0, 11;

-- 
                                                    (,_    ,_,    _,)   
                                                    /|\`\._( )_./'/|\   
                                                   · ·  \/ L /\ D  · ·  
                                                  /__|.-'`-\_/-`'-.|__\ 
                                                 `          "          `


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

Date: Thu, 05 Jun 2003 17:51:29 +0200
From: Jon Rogers <jon@rogers.tv>
Subject: Newbie: Perl and GET / POST
Message-Id: <3EDF6701.9B65B44@rogers.tv>

Hi,

I'd like to make a link from inside my Perl-CGI to a script which is
normally envoked by POST. I can see how this happens for GET:

print "<a href='www.foo.com/cgi-bin/search.cgi?value1=12&value2=13'>search!</a>";

but what would the syntax be like for POST?

Thanks, 

JR


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

Date: Thu, 05 Jun 2003 18:07:22 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Newbie: Perl and GET / POST
Message-Id: <bbnps4$bhjck$1@ID-184292.news.dfncis.de>

Jon Rogers wrote:
> I'd like to make a link from inside my Perl-CGI to a script which is
> normally envoked by POST. I can see how this happens for GET:
> 
> print "<a href='www.foo.com/cgi-bin/search.cgi?value1=12&value2=13'>search!</a>";
> 
> but what would the syntax be like for POST?

print <<SEARCH;
<form method="post" action="www.foo.com/cgi-bin/search.cgi">
<input type="hidden" name="value1" value="12" />
<input type="hidden" name="value2" value="13" />
<input type="submit" value="search!" />
</form>
SEARCH

/ Gunnar

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Thu, 05 Jun 2003 11:24:57 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Parsing issue
Message-Id: <4nd6hsr1h2.fsf@holmes.bwh.harvard.edu>

On Thu, 05 Jun 2003, kamp@inl.nl wrote:
> I'm developing an application for selecting items from a
> bibliographic database. For several reasons we do not let the user
> work directly with SQL, but via a simpler language. The queries will
> then be translated into SQL. E.g. the users enters: medium='Book' or
> medium='Paper'. This must be translated to select * from Items where
> medium = 'Book' or medium='Paper'; More complex queries are also
> possible.  I have the following questions.
> 
> I want to use Parse::RecDescent for this job. As I'm absolutely new
> to parsing and formal languages: do you need to traverse the parse
> tree to construct valid SQL? I do not quite understand the data
> structure generated by the <autotree> directive. Are there ways to
> make it more explicit?
> 
> Are there other ways to build the application or is my decision to
> use RecDescent the right one?

Your approach looks fine.  You should look at the Parse::RecDescent
mailing list, they are likely to be more helpful than c.l.p.misc in
discussing your design.  But it looks like you have the syntax right,
now you just need to interpret the parse tree.

Instead of <autotree> you may want to generate your own tree
structure, so it will be easier to traverse.  For instance, 

mediumZoekVraag: 'medium=' zoekString { $return = { medium => $item{zoekString} }; 1 }

will produce hash references with a single key "medium" in your parse
tree wherever mediumZoekVraag matches.

As for other ways to do it, sure, there's a million and one.  P:RD is
not a good choice is speed is essential, but otherwise it's quite
solid.  The Perl 6 matching rules will actually be similar to P::RD
rules, so consider it bonus training for the Perl 6 regexes :)

Ted


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

Date: Thu, 05 Jun 2003 12:17:21 -0500
From: Chris Olive <nospam@raytheon.com>
Subject: Re: Posting to an asp form with hidden fields
Message-Id: <mWKDa.3468$c6.3234@bos-service2.ext.raytheon.com>

Alan Hogue wrote:
> Hello,
> 
> I've searched all over and can't find something that quite answers my
> question. My appologies if I'm mistaken.
> 
> I'm using LWP::UserAgent and HTTP::Request::Common to post to a search
> form. The form is an asp page with three hidden fields and some
> javascript that takes the values from three of the non-hidden fields,
> processes the values, and then inserts these values into the hidden
> fields. Originally I just tried posting without using the hidden
> fields (since I didn't need to use the corresponding non-hidden fields
> anyway), but that didn't work (got a 404 error, which is what I get no
> matter what I do).
> 
> So here are the assumptions I am using: First, I assume I need to post
> to the hidden fields regardless of whether anything is in them.
> Further, my understanding is that, in this case, I need to post
> directly to the hidden fields, rather than to the corresponding
> non-hidden fields, because otherwise the JS will not pick up the
> values and process them. Therefore I need to figure out what the JS is
> doing to the original values and post values that are formatted the
> same way.
> 
> The problem is that no matter what I try, I get the same result: a 404
> (Not Found) Object Not Found error. Before I go on trying to get the
> values for the hidden fields right (and pulling my hair out), I'd
> appreciate it if someone could tell me whether I am even on the right
> track here. First of all, are my assumptions correct? Is there some
> obvious mistake in my code? Am I just not understanding the javascript
> correctly?
> 
> For instance, I notice in the javascript (below) that two of the three
> hidden fields don't appear to get anything passed to them at all as
> long as nothing was selected in the corresponding non-hidden fields.
> But wouldn't this mean, since I don't even need them, that I don't
> have to post anything to them? But if I do that, I get the same exact
> error, so that would make me wonder whether there is some other
> problem that I need to solve. Any help would be really appreciated.
> 
> The code is below.
> 
> _________
> [snipped code]

Time being what it is, I gave your threads between yourself and Purl 
Gurl only a cursory reading, and I did not read your Perl code or the JS 
supplied.  But I thought I would interject that some sites do actually 
run interception logic based on the user agent (HTTP_USER_AGENT) and the 
referer (HTTP_REFERER), so you may want to consider this possibility was 
well.  I have had this happen on occasion when trying to simulate form 
posts.

Chris
-----
Chris Olive
Systems Consultant
Raytheon Technical Services Corporation
Indianapolis, IN

email: olivec(AT)indy(DOT)raytheon(DOT)com



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

Date: 5 Jun 2003 08:29:26 -0700
From: cjohnso9@amfam.com (Chad Johnson)
Subject: Re: Printing VISIO documents using PERL.
Message-Id: <a3c05aa8.0306050729.5d48d01d@posting.google.com>

grehom@ntlworld.com (Graham Smith) wrote in message news:<98eb7f13.0306050217.43c77e02@posting.google.com>...
> I'm pretty sure you could do it using the Win32::OLE interface,
> unfortunately I don't have a copy of Visio to write a demonstration
> script for you.
> If you're using the Activestate Perl the documentation gives examples
> for M$ Excel spreadsheets and Word documents - if you go this route
> and you have a copy of Microsoft Word - try Alt+F11, in a new
> document, to start the Object browser, pull down the Tools menu and
> click References, scroll down the list of
> available references and tick the Visio entry, you should then be able
> to specify Visio as the library you are interested in.  The classes
> and members of the visio library should then be readable - this is not
> what I would call Newbie territory - but there are newbies and
> newbies!!  Try using the object browser with the Word and Excel
> libraries as you study the examples in documentation - don't be afraid
> to e-mail if you get stuck
> 
> cjohnso9@amfam.com (Chad Johnson) wrote in message news:<a3c05aa8.0306041053.6e656430@posting.google.com>...
> > I am new to PERL and I am trying to write a script to do the
> > following:
> >   1. Read in a VISIO document.
> >   2. Change the printing options to 'TRUE TYPE FONT' and 'DOWNLOAD AS
> > SOFTFONT'.
> >   3. Print the document.
> > 
> > Does anyone have any examples of scripts that can do something like
> > this. If so please send me them.
> > 
> > Thanks


Hi there,
Thanks for the info. I tried this but I still can't seem to find the
Class that I would need to use to accomplish setting the appropriate
attributes. Any clue?

Thanks again


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

Date: Thu, 05 Jun 2003 11:56:42 -0400
From: Shane McDaniel <shanem@nospam.ll.mit.edu>
Subject: Re: Problems with & operator
Message-Id: <3EDF683A.5C0AAB9C@nospam.ll.mit.edu>

hehe, thanks.  Always something new to learn, especially from the
verbose. :)

-shane


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

Date: 5 Jun 2003 09:02:00 -0700
From: Mark.Smith@sonyericsson.com (Mark Smith)
Subject: Push adding space to start of items
Message-Id: <cf24885e.0306050802.128b93c4@posting.google.com>

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.

Regards,

Mark.


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

Date: Thu, 05 Jun 2003 18:24:56 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Push adding space to start of items
Message-Id: <bbnqt2$boeho$1@ID-184292.news.dfncis.de>

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.

Translate to Perl, please.

/ Gunnar

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Thu, 05 Jun 2003 18:31:00 +0200
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: Push adding space to start of items
Message-Id: <jvrudv8l5b7r497mha6g3qt102k4ijnokh@4ax.com>

X-Ftn-To: Mark Smith 

Mark.Smith@sonyericsson.com (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.

How about posting a relevant code and some data?



-- 
Matija


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

Date: Thu, 5 Jun 2003 11:48:16 -0500
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: Push adding space to start of items
Message-Id: <MPG.194930489d9ad58d9897f0@news.mts.net>

[This followup was posted to comp.lang.perl.misc]

In article <cf24885e.0306050802.128b93c4@posting.google.com>, Mark Smith 
(Mark.Smith@sonyericsson.com) says...
> 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.
> 
> Regards,
> 
> Mark.
> 

If you show us your Perl code, perhaps we can help you.


-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: Thu, 05 Jun 2003 10:50:38 -0700
From: Steve May <drumspoorly@reachone.net>
Subject: Re: Push adding space to start of items
Message-Id: <vdv0a0gauajddd@corp.supernews.com>

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.
> 
> Regards,
> 
> Mark.

Some code *would* be nice, but dollars to donuts you're doing something
like:

print "@array";

The interpolation separator ($") is set to single spaces by default,
hence your array has a single space plugged in between each element
when the array is converted to a string.

You might set $" to fix this problem, though you really should set it
back to default afterwords unless you like debugging code....

$" = ''; # no value
print "@array";
$" = ' ';  # single space again

There are other (better?) ways to do it. (This IS Perl, after all )

s.



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

Date: Thu, 5 Jun 2003 17:43:39 +0000 (UTC)
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: Push adding space to start of items
Message-Id: <bbnvgb$alk$1@naig.caltech.edu>

In article <cf24885e.0306050802.128b93c4@posting.google.com>,
Mark Smith <Mark.Smith@sonyericsson.com> 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.

You don't show us any real code, but I'll take a wild guess that
your problem is the one answered in perlfaq5, "Why do I get weird
spaces when I print an array of lines?".  You can view this with
perldoc perlfaq5 or perldoc -q "print an array".

Hint:  The "problem" has to do with "unnecessary" "quoting"
of "variables".

Gary
-- 
Thank you for calling... To use our automated payment information
system, say Payment now.  If you have charges you do not understand
or questions about your bill, say Pinhead.  To hear these options
again, say Attention Span of a Gnat.


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

Date: 05 Jun 2003 18:11:58 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: regex based on numeric value
Message-Id: <u9vfvk8n4x.fsf@wcl-l.bham.ac.uk>

rferrante@tnsi.com (Rick Ferrante) writes upside-down:

[ reordered ]

> tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnbdt5j1.nvd.tadmc@magna.augustmail.com>...
> > Rick Ferrante <rferrante@tnsi.com> wrote:
> > 
> > > Given a string like "Level 87.34"
> > > 
> > > Is there a regex that will match if the string is like "Level
> > > ([0-9.]+)" and \1 is > 75 ?
> > 
> > 
> > Why do you want to do mathematics with string operators?
> > 
> > Perl comes with numeric operators for working with numbers,
> > use them for your comparisons:
> > 
> >    if ($num =~ /(\d+\.\d+)/ and $1 > 75 )

>   You're right. I was looking because I have an operational NMS system
> that applies regex patterns to incoming syslog messages where the
> regex's are stored in Oracle.  Therefore, I don't know in advance what
> kind of tests users may want to apply to the match variable
> ($1,$2,...).  Therefore, I was hoping to deal with it in the regex
> itself and be done.

> I'm thinking about encoding the additional requirements in a regex
> comment, parse that out and eval it if necessary.

If you are going to have to address the security issues invloved in
eval() anyhow you may as well use eval() all the time. 

Why not just tell users to specify a Perl expression?  If users want
to express their condition as a regex they can just put slashes
arround it.

use strict;
use warnings;

my $user_condition = '/(\d+\.\d+)/ and $1 > 75';
my $log_message = "Level 87.34";

# Be aware Safe is known not to be perfect.
use Safe;
my $safe = Safe->new;
my $compiled_user_condition = $safe->reval("sub{$user_condition}") or die;

if ( grep { $compiled_user_condition->() } $log_message ) {
  print "$log_message satified '$user_condition'\n";
}


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


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

Date: 05 Jun 2003 18:14:21 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Regex with numeric evaluation
Message-Id: <u9ptls8n0y.fsf@wcl-l.bham.ac.uk>

rferrante@tnsi.com (Rick Ferrante) writes:

> Stephen, 
> 
> That works in general. But in my case, the regex are stored in an
> oracle table, and when I try to eval the expression you listed perl
> gives me an error saying that it will not do eval code (?{}) in regex
> at runtime. (a security feature I guess).

This can be switched off.

perldoc re

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


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

Date: Thu, 05 Jun 2003 17:21:08 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Time limit
Message-Id: <mbudash-DDB646.10210705062003@typhoon.sonic.net>

In article <14kudvc0gvng14ranu54jjp11ah4rkintc@4ax.com>,
 Zvezdoshka@nowhere.ru wrote:

> I don't know where to ask, so I try here :-)
> 
> In a quizz, I want setup a time limit for users to reply to each
> question. What's the best way to do this ? A cookie that expires in xx
> seconds, is that the only way ?
> 
> Thank you !
> 
> ZZ

that's not the only way. think about it in a "real world" scenario, then 
translate that to a scripting solution: you want to present a question, 
then ensure that the answer is submitted in a specified time frame. a 
cookie is certainly one way: upon presenting the question, set a cookie 
that expires in the specified time frame. then, upon receiving the 
answer, check if the cookie still exists, and if it doesn't, you know 
the user exceeded the allotted time. however...

many folks turn off cookies, and that's just one downside of cookies. i 
think i'd store the presentation timestamp server-side. then when the 
answer is received, compare current time with the timestamp to determine 
how long the user took. upside: no cookies needed, no hacking possible. 
downside: more programming necessary to link the stored timestamp with 
the user's question, probably via a unique key.

questions?

-- 
Michael Budash


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

Date: Thu, 5 Jun 2003 18:52:45 +0100
From: Cannabis Coffee Shops <nntp@cannabiscoffeeshops.co.uk.INVALID>
Subject: UK script writer wanted
Message-Id: <MPG.194993791dde396d98adf7@news.newshosting.com>

Sort of off topic as its not a perl question - but as somebody on here 
will earn money from doing it I reckon its ok .

Car website .

(a) login/logout/register

(b) enter details of car for sale or wanted

(c) user can edit or remove advert

(d) view car by manufacturer or price

(e) view the latest 10 adverts

With the exception of a few other minor bits-n-bods thats it .


The ideal candidate would be a home user - *fully* capable of writing the 
script & wants to earn a few bob from their hobby .


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

Date: 5 Jun 2003 08:34:27 -0700
From: hamelcd@hotmail.com (Christopher Hamel)
Subject: Re: Yabb woes.
Message-Id: <4f60d5b3.0306050734.226837c3@posting.google.com>

"john smith" <someone@microsoft.com> wrote in message news:<bbn24u$j2a$1@bob.news.rcn.net>...
> Nevermind. I fixed it.

Someone @ Microsoft indeed...


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

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


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