[25127] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7377 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 8 14:05:30 2004

Date: Mon, 8 Nov 2004 11: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)

Perl-Users Digest           Mon, 8 Nov 2004     Volume: 10 Number: 7377

Today's topics:
    Re: an original perldoc viewer <ioneabu@yahoo.com>
    Re: Binary files in PERL? <sdsommer@comcast.net>
    Re: EOF issue <onedoesnot@needto.know>
    Re: EOF issue <onedoesnot@needto.know>
    Re: Extract a number from a string. (Adam)
    Re: FAQ 2.1: What machines support Perl?  Where do I ge <comdog@panix.com>
        FAQ 8.12: How do I start a process in the background? <comdog@panix.com>
    Re: Firefox broswer staring Perl CGI <usenet_05_08_2004@stuartmoore.org.uk>
        Generalize Problem : Generate all possible combinations (rajsena)
    Re: Generalize Problem : Generate all possible combinat <1usa@llenroc.ude.invalid>
    Re: Global @INC <aw@lintrix.net>
        installing extra file through ExtUtils::MakeMaker (Abdul-Wahid Paterson)
    Re: Net::Telnet connection status <mike.ferrari@motorola.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 08 Nov 2004 11:42:27 -0500
From: wana <ioneabu@yahoo.com>
Subject: Re: an original perldoc viewer
Message-Id: <10ov556esdal6c7@news.supernews.com>

A. Sinan Unur wrote:

> wana <ioneabu@yahoo.com> wrote in news:10otm79211him89@news.supernews.com:
> 
>> Thanks for examples and advice.  I found when I was at work today when I
>> tried to access my script via the web it would not run.  It turns out it
>> was because of the -T.  When I got home and removed it, it worked fine
>> again.
> 
> If you don't mind me asking, why did you remove -T instead of fixing the
> insecure dependency?
> 

I should have done that but in this particular case, I decided I wanted the
insecure dependency because I wanted to run some more commands via the web. 
I have wrapped the script in a secure login/session-based solution so I can
run an insecure script in a secure environment.

By the way, if anyone out there needs to get in shape and has joined a gym,
perldocs are great companions on the stair machines and bicycles.  I just
print them on out and bring them with me (not on my own printer though :)). 
Perlop is over 40 pages!  One good perldoc can make a 30-60 minute aerobic
workout fly by in no time.

wana


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

Date: Mon, 08 Nov 2004 07:16:06 -0800
From: Steven Sommer <sdsommer@comcast.net>
Subject: Re: Binary files in PERL?
Message-Id: <fa3vo098p8qiu72vb5c1hmnpu8nmnlth8f@4ax.com>

On Mon, 08 Nov 2004 02:15:46 +0800, Benjamin Khoo
<benkhoo@copperblue.per.sg> wrote:

>On Sun, 07 Nov 2004 05:58:41 +0000, Jürgen Exner wrote:
>
>> Benjamin Khoo wrote:
>>> i would like to find out how to write a binary file in PERL
>>>
>>> most of the readme and tutorial online only deal with writing ASCII
>>> files.
>> 
>> Are you really on an OS that differentiates between binary and text
>> files? Then you may want to check
>>     perldoc -q binary: "How do I handle binary data correctly?" perldoc
>>     -f binmode
>> 
>> jue
>
>Hi jue
>
>thanks much for your reply..
>i took a look at the documentation,
>does it mean that all i have to do is
>
>open(FILE,">file.bin");
>binmode (FILE);
>
>?
>
>and then use a print FILE "text\n";
>to write into my file?
>
>would reading it be jsut the reverse?
>
>your advice is highly appreciated

Read about "pack" and "unpack" in the docs.  You have to pack the data
before you write it to a binary file, and unpack it after you read it.
These functions convert back and forth between textual and binary
data.




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

Date: Mon, 8 Nov 2004 14:11:03 -0000
From: "IanW" <onedoesnot@needto.know>
Subject: Re: EOF issue
Message-Id: <cmnvke$tbe$1@blackmamba.itd.rl.ac.uk>

"Ben Morrow" <usenet@morrow.me.uk> wrote in message
news:sr9t52-utb.ln1@osiris.mauzo.dyndns.org...
>
> Quoth "IanW" <onedoesnot@needto.know>:
> > "Thomas Kratz" <ThomasKratz@REMOVEwebCAPS.de> wrote in message
> > news:418b939f$0$17108$bb690d87@news.main-rheiner.de...
> > [..]
> >
> > I don't understand the program logic here..
> >
> > >     local $/ = '=' x 15 . "\n";
> >
> > ok, so changing the input record separater to '=' x 15 . "\n" (referred
to
> > as "=15" hereafter for convenience), effectively specifying how you're
going
> > to split the file (I actually need the =15 when I output the chunks
after
> > processing them, but I can add that back in when printing out to file).
>
> ...and you can get Perl to do that for you too, with
>
> local $\ = $/;

in this case I've just done a:

print LH '=' x 15 ."\n";

before printing each chunk out, as the =15 needs to be before each chunk,
rather than after. However that's useful to know.

Thanks
IanW



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

Date: Mon, 8 Nov 2004 14:16:37 -0000
From: "IanW" <onedoesnot@needto.know>
Subject: Re: EOF issue
Message-Id: <cmnvus$tfr$1@blackmamba.itd.rl.ac.uk>

<ctcgag@hotmail.com> wrote in message
news:20041105124641.463$iG@newsreader.com...
[..]
> > >     while ( my $chunk = <FH> ) {
> >
> > that's going to slurp in all text up to and including "Line 3" in my
> > original example on the first pass of the loop.
>
> Up to and including the first Line 3, and also including the =15 after it.
>
> > >        chomp($chunk);
> >
> > removes any newline characters from the very end of $chunk
>
> It removes $/, which in this case is not just any newline, but also =15
[..]
> > >        next unless $chunk =~ /\w/;
> > >        # process chunk
> >
> > So this says that we're going to process $chunk if it has an
alphanumeric
> > character in it, which it would if the first chunk has been successfuly
> > slurped int?
>
> The normal use of $/ implies the =15 would come after each of your
records.
> What you actually have is a =15 before each record.  What's is the
> difference? Well, you have an extra =15 at the start, which results (after
> chomp) in an empty "record" the first time through the loop.  So you have
> to ignore that empty record.

OK, I see.. that's a clear explanation (well, even I understood it, first
read :)

I've used that method in the actual script and it's working nicely.

Thanks
IanW



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

Date: 8 Nov 2004 06:42:55 -0800
From: adam_cheney@hotmail.com (Adam)
Subject: Re: Extract a number from a string.
Message-Id: <214d0889.0411080642.7942a3e1@posting.google.com>

"Peter Wyzl" <wyzelli@yahoo.com> wrote in message news:<CfIjd.27076$K7.12840@news-server.bigpond.net.au>...
> "Adam" <adam_cheney@hotmail.com> wrote in message 
> news:214d0889.0411080240.23a9c5bc@posting.google.com...
> > Hi All,
> >
> > Apologies if this is laughably simple, but it's been a long time since
> > I've used Perl, and I seem to suffer from Homer Simpson's problem:
> > every time I learn something new, it pushes old stuff out.
> >
> > I'm trying to extract a number from a line of text returned by a
> > license-checking command. I open a pipe to the command, and read
> > through each line that is returned. When I find the text "Maximum..."
> > or "Current..." I want to extract and store the number in that line. I
> > tried using something like this to start with:
> >
> > $lic_usage{$lic_type}{$max} = /\d+/ if (/Maximum/);
> > $lic_usage{$lic_type}{$cur} = /\d+/ if (/Current/);
> 
> You need to capture the numbers IF there is a match...
> 
> if (/Maximum/){$lic_usage{$lic_type}{$max} =  $1 if (/(\d+)/)};
> 
> Because there are two conditionals involved (you don't want to assign from 
> $1 et al unless there was a match) I would write it like the above, or 
> perhaps less ambiguously like:
> 
> if (/Maximum/){
>     $lic_usage{$lic_type}{$max} =  $1 if (/(\d+)/);
> }
> 
> Check in perlre for info on the capturing parens.

Thank you Peter (and anyone else who answers before Google gets this
reply out)...

It was indeed because I had omitted the parentheses around '\d+' -
although I discovered it *is* possible to present it as a single line
by assigning the lic_usage hash in list context, thus:

($lic_usage{$lic_type}{$max}) = /(\d+)/ if (/Maximum/);

I was so nearly there!

Thanks again - Adam...


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

Date: Mon, 08 Nov 2004 11:49:23 -0500
From: brian d foy <comdog@panix.com>
To: ioneabu@yahoo.com
Subject: Re: FAQ 2.1: What machines support Perl?  Where do I get it?
Message-Id: <081120041149230125%comdog@panix.com>

[[ This message was both posted and mailed: see
   the "To," "Cc," and "Newsgroups" headers for details. ]]

In article <10okrpu6bjsp3a3@news.supernews.com>, wana
<ioneabu@yahoo.com> wrote:

> PerlFAQ Server wrote:

> > 2.1: What machines support Perl?  Where do I get it?

> >     Perl builds and runs on a bewildering number of platforms. Virtually
> >     all known and current Unix derivatives are supported (Perl's native
> >     platform), as are other systems like VMS, DOS, OS/2, Windows, QNX,
> >     BeOS, OS X, MPE/iX and the Amiga.

> What about Pocket PC (a version of win ce)?  I did find a version of Perl
> for Pocket PC by searching Google, but part of the installation involves
> editing the registry.  

I don't follow Pocket PC stuff, but if you send me a link to
whatever you found, I can add it to the list of supported
platforms.

-- 
brian d foy, comdog@panix.com
Subscribe to The Perl Review: http://www.theperlreview.com


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

Date: Mon, 8 Nov 2004 17:03:04 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 8.12: How do I start a process in the background?
Message-Id: <cmo8s8$qof$1@reader1.panix.com>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.

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

8.12: How do I start a process in the background?

    Several modules can start other processes that do not block your Perl
    program. You can use IPC::Open3, Parallel::Jobs, IPC::Run, and some of
    the POE modules. See CPAN for more details.

    You could also use

        system("cmd &")

    or you could use fork as documented in "fork" in perlfunc, with further
    examples in perlipc. Some things to be aware of, if you're on a
    Unix-like system:

    STDIN, STDOUT, and STDERR are shared
        Both the main process and the backgrounded one (the "child" process)
        share the same STDIN, STDOUT and STDERR filehandles. If both try to
        access them at once, strange things can happen. You may want to
        close or reopen these for the child. You can get around this with
        "open"ing a pipe (see "open" in perlfunc) but on some systems this
        means that the child process cannot outlive the parent.

    Signals
        You'll have to catch the SIGCHLD signal, and possibly SIGPIPE too.
        SIGCHLD is sent when the backgrounded process finishes. SIGPIPE is
        sent when you write to a filehandle whose child process has closed
        (an untrapped SIGPIPE can cause your program to silently die). This
        is not an issue with "system("cmd&")".

    Zombies
        You have to be prepared to "reap" the child process when it
        finishes.

            $SIG{CHLD} = sub { wait };

            $SIG{CHLD} = 'IGNORE';

        You can also use a double fork. You immediately wait() for your
        first child, and the init daemon will wait() for your grandchild
        once it exits.

                unless ($pid = fork) {
                        unless (fork) {
                    exec "what you really wanna do";
                    die "exec failed!";
                        }
                exit 0;
                }
            waitpid($pid,0);

        See "Signals" in perlipc for other examples of code to do this.
        Zombies are not an issue with "system("prog &")".



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

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-2002 Tom Christiansen and Nathan
    Torkington, and other contributors as noted. All rights 
    reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.


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

Date: Mon, 08 Nov 2004 16:39:25 +0000
From: Stuart Moore <usenet_05_08_2004@stuartmoore.org.uk>
Subject: Re: Firefox broswer staring Perl CGI
Message-Id: <cmo7fn$566$1@gemini.csx.cam.ac.uk>

Jerry Preston wrote:

> I just checked out some of my Perl CGI scripts that work fine using IE and
> Netscape and I find that Firefox is lost or I am.  I start my scripts with
> the following:
> 
>   print $query->header();
>   print $query->start_html( -title  => "$main_title By Jerry Preston",
>                           );
>   print $query->startform(  -name   => 'update_form',
>                             -method => 'POST',
>                          );
> 
> When I do a view page source the following starts the code:
> 
> <?xml version="1.0" encoding="iso-8859-1"?>
> <!DOCTYPE html
> 	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> 
> What am I missing?

Are you able to put a sample CGI script up somewhere so we can look at
the html it's creating? Do the smallest script that shows the behaviour 
(i.e. first look at print header(), start_html(), "Foo", end_html(); and 
then if that works keep adding other bits in)


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

Date: 8 Nov 2004 09:47:13 -0800
From: rajsena911@gmail.com (rajsena)
Subject: Generalize Problem : Generate all possible combinations
Message-Id: <b15e70aa.0411080947.66cf4073@posting.google.com>

Hi,

I would really appreciate if somebody could help me with this problem 

Problem: Need to generate All possible combinations for a N-bit number
wherein each position as a finite (1-6) possibilities.

Heres a simple example

Array1 { 1 2 3 }
Array2 { 4 5 }
Array3 { 6 7 }

Generate all possible combinations such that,

Number 3 bit 

1 bit comes from array1
2 bit comes from array2
3 bit comes from array3 

possible combinations

1 4 6
1 4 7
1 5 6
1 5 7
2 4 6
2 4 7 and so on....

I need to generalize this for a N bit number (determined at runtime)
where in each position is comes from an array of {1-6} possible
combinations.

Thanks,

- raj


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

Date: 8 Nov 2004 17:57:25 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Generalize Problem : Generate all possible combinations
Message-Id: <Xns959B83CE2F29asu1cornelledu@132.236.56.8>

rajsena911@gmail.com (rajsena) wrote in news:b15e70aa.0411080947.66cf4073
@posting.google.com:

> Hi,
> 
> I would really appreciate if somebody could help me with this problem 
> 
> Problem: Need to generate All possible combinations for a N-bit number
> wherein each position as a finite (1-6) possibilities.

We are not going to solve your homework and/or job interview question.

However, you should be able to solve your problem by using the appropriate 
module from CPAN (http://search.cpan.org/). 'Permutation' might be a 
suitable keyword to use.

Once you have attempted a solution on your own and have code, please come 
back and post specific issues you are having. However, before doing that, I 
would recommend reading the posting guidelines for this group. The 
guidelines are posted here regularly.

Sinan


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

Date: Mon, 8 Nov 2004 16:04:49 +0000 (UTC)
From: Abdul-Wahid <aw@lintrix.net>
Subject: Re: Global @INC
Message-Id: <pan.2004.11.08.16.04.38.803138@lintrix.net>

What about either exporing PERL5LIB in the init script or setting library
paths by invoking perl with the -I flag?

AW




On Mon, 01 Nov 2004 18:28:08 -0800, William Ahern wrote:

> How can I globally specify additional @INC paths. Is there a module I can
> edit amongst any Perl library modules--written in perl?
> 
> I've tried setting PERL5LIB in the the global shell startup files in /etc,
> but that doesn't work for perl code started from init. Recompiling perl
> isn't an option.
> 
> TIA,
> 
> Bill



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

Date: 8 Nov 2004 06:46:50 -0800
From: aw@lintrix.net (Abdul-Wahid Paterson)
Subject: installing extra file through ExtUtils::MakeMaker
Message-Id: <72ca6ce3.0411080646.3b4d3e2f@posting.google.com>

Hi,

I have been using ExtUtils::MakeMaker in a Makefile.PL to package and
install a perl script and a few perl modules. At the moment my
Makefile.PL is very simple, I just copied it from a few examples.

I am now wanting to have a few templates and configuration files
installed by "make install" but was not sure what I should put in my
Makefile.PL to acheive this. Can anyone give me any examples of how to
install extra supporting files?

Thanks,

Abdul-Wahid


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

Date: Mon, 08 Nov 2004 09:49:43 -0600
From: Mike Ferrari <mike.ferrari@motorola.com>
Subject: Re: Net::Telnet connection status
Message-Id: <cmo4nt$h8u$1@newshost.mot.com>

I had the same issue, i was sending commands to a router and one of them 
was a reload command. It would sever the connection. I didnt really care 
about the status of the connection.
I just close the telnet session drop into a "wait" of 30 seconds or so 
(however long it takes for the router to reload) and opened a telnet 
conection to that device again.

I say this assuming you are not going through a terminal server to 
connect to the console of the router.

Mike

juky wrote:

> Hi all,
> 
> I'm using a Net::Telnet to send some commands to a router.
> What I need to check now is my connection status after I sent any
> commands. In some cases when I upload the router with particular
> command it resets the connection and I must login again.
> How can I do it? 
> 
> Here my code:
> 
> ....
> ...
> my $session = Net::Telnet->new(Host => $rt,
> 			       Timeout => 30);
> 
> {login part}
> 
> while ...... {
> 
>   $session->print($command);
>  ($output,$a)=$session->waitfor(Match => '/#/');
> }
> 
> 
> Thanks.
> 
> Juky


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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