[22470] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4691 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 10 18:05:49 2003

Date: Mon, 10 Mar 2003 15:05:08 -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, 10 Mar 2003     Volume: 10 Number: 4691

Today's topics:
    Re: any simple way to detect the real end of a command  (mkkwong)
        Forking problems with CGI, Apache, Win2K (HJ)
        Merging log files using hash - good idea/possible? <singleantler-news@hotmail.com>
    Re: Merging log files using hash - good idea/possible? <me@verizon.invalid>
    Re: Merging log files using hash - good idea/possible? <mjcarman@mchsi.com>
    Re: new Perl feature request: call into shared libs <no.spam@gknw.de>
    Re: Newbie:  Extract info from MSI (Sam Holden)
    Re: PERL & ORBit (Diego Sevilla Ruiz)
    Re: Perl Mysql uploading a image in a database. <mgjv@tradingpost.com.au>
    Re: Perl Script or Bourne Shell for a Cisco router, Ple (Bill Reynolds)
    Re: Perl Script or Bourne Shell for a Cisco router, Ple <Andree@nospam-toonk.nl>
    Re: Perl Script or Bourne Shell for a Cisco router, Ple <me@privacy.net>
        perl to strip high-end ASCII <sellis@totallygeek.com>
    Re: perl to strip high-end ASCII <fxn@hashref.com>
    Re: perl to strip high-end ASCII <krahnj@acm.org>
        Perl Vs C,C++ (bab)
    Re: Perl Vs C,C++ <uri@stemsystems.com>
    Re: Perl Vs C,C++ <dthomson@NOSPAMusers.sf.net>
    Re: Perl Vs C,C++ <mgjv@tradingpost.com.au>
    Re: Re to all <me@privacy.net>
    Re: remove anything from string except two words <krahnj@acm.org>
    Re: Trying to Learn Chomp <tassilo.parseval@post.rwth-aachen.de>
    Re: Word Boundaries <tassilo.parseval@post.rwth-aachen.de>
    Re: XS code to call DLL <brian_helterline@hp.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 10 Mar 2003 13:37:56 -0800
From: mkwong@wideopenwest.com (mkkwong)
Subject: Re: any simple way to detect the real end of a command in a perl script? Thanks
Message-Id: <4977b250.0303101337.11a5f495@posting.google.com>

Thank you for all your responses.  They confirmed my original
accessment that these are not simple problems.

I found that in the perltidy() utility developed by Steve Hancock
(http://perltidy.sourceforge.net) contains a tokenizer.  I have been
able to use that to get some preliminary results that are useful for
my purpose.  Will continue to look into that.

"Jürgen Exner" <jurgenex@hotmail.com> wrote in message news:<hXbaa.212$Jh1.26@nwrddc03.gnilink.net>...
> mkkwong wrote:
> > I intend to write some simple tools to help myself in writing perl
> > programs. The tool will read a perl script and analyze the content and
> > perhaps generate some useful information.
> >
> > One of the first problems I encounter is to figure out whether a ;
> > found in a line in the script is really the end of a command. A
> > similar problem is how can we tell the end of those commands that may
> > not end in a ; (like the last statement in a block).
> 
> You know, there is a saying "Only perl can parse Perl".
> While you can surely write your own Perl parser I wouldn't even attempt it
> unless you have a very solid background in compiler construction.
> 
> > Obviously the perl debugger or the useful perltidy() utility has this
> > capabilty. I am way too lazy (aka don't know enough) to try to dig
> > into those to find out how they do it. I don't really need the full
> > power like those tools to parse the complete perl syntax - it is
> > enough if I can simply determine that the ; I see is not part of a
> > string value, or part of a here doc, or a regex, or a comment etc.
> 
> Or, or, or, or. You just listed 4 good reasons why you do need a
> full-featured parser or at least a full-featured tokenizer (not sure though
> if a tokenizer will be sufficient for Perl).
> 
> > Similarly, if I see an enclosing }, how do I know whether that is the
> > end of a code block and not part of a hash notation, or part of a
> > string value, or a here doc or a regex, etc.
> 
> Another 5 good reasons for a Perl parser.
> 
> > Does any one know if there is an easy way or if some modules are
> > available (without me having to chase through the entire set of perl
> > syntax rules) to do those or am I wishing too much?
> 
> Contrary to popular believe parsing a programming language is rocket
> science.
> 
> jue


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

Date: 10 Mar 2003 11:35:59 -0800
From: garbanzocolorado@yahoo.com (HJ)
Subject: Forking problems with CGI, Apache, Win2K
Message-Id: <cdb2be68.0303101135.4a16bc29@posting.google.com>

Hello all:

forktest.pl Perl 5.6.x CGI called by Apache 1.3.x server on my Win 2K
machine (SP2).

forktest.pl, when stripped of everything, is basically this:
    - write a temp file (say temp.pl) which autorefreshes itself every
5 seconds
    - fork a child process
    - parent: redirect the CGI to display temp.pl which says
"processing in progress"
    - child: in the child run a system command that takes a long time
to run
    - child: when this command is done, replace the contents of
temp.pl with a "done" message

When I run this from the command line, it works just fine. 

However, when I call this from the web server
(http://www.myserver.com/cgi-bin/forktest.pl), instead of the parent
redirecting to temp.pl right away, it will wait for the child to
complete, and then redirect. This means that "processing in progress"
is not displayed, instead I only get the "done" message.

This wouldn't be too big an issue except that the web server usually
times out...

Any ideas?

The whole code is pasted below if you want a more detailed look.

Thanks in advance!

-HJ




<code>
#!d:\perl\bin\perl.exe
#            use strict;
            $| = 1;
             
            use CGI qw/:standard/;
            use IO::File;
             
            BEGIN {
               my $header_printed = 0;
            
              sub maybe_print_header {
                print header(@_) unless $header_printed;
                $header_printed = 1;
              }
            }
            
            ## return $_[0] encoded for HTML entities
            sub ent {
              local $_ = shift;
              s/["<&>"]/"&#".ord($&).";"/ge;  # entity escape
              $_;
            }
            
            ## death handler
            $SIG{"__DIE__"} = $SIG{"__WARN__"} = sub {
              my $why = shift;
              chomp $why;
              $why = ent $why;
              maybe_print_header();
              print "ERROR: $why\n";
              exit 0;
            };
            
            my $DIR =
"e:\\apache\\apache\\cgi-bin\\docushare\\temp\\";
            my $URL =
"http:\/\/netcom.it.agilent.com:81\/cgi-bin\/docushare\/temp\/";
            
            my $searchstring = param("search"); # the search item

    $searchstring = "Searchthis";

     unless (defined $searchstring and length $searchstring) {
                   maybe_print_header();
                   print "<html><head></head><body><form
method=get><input type=text name=search size=50><unput type=submit
name=submit value=submit></form></body></html>";
            } else {
              my $session = unpack("H*", pack("Nn", time, $$)); # 12
hex chars
              my $session_html = "$session.pl";
              
              my $DIR_html = "$DIR$session_html";
              my $DIR_html_tmp = "$DIR$session_html.tmp";
              my $URL_html = $URL . $session_html;
              {
                my $out = IO::File->new($session_html,"w") or
                     die "Cannot create $DIR_html: $!";
  print $out "\#\!d:\\perl\\bin\\perl.exe\nuse CGI qw\/:standard\/;\n
BEGIN \{\nmy \$header_printed = 0; sub maybe_print_header \{print
header\(\@\_\) unless \$header_printed;\$header_printed =
1\;\}\}\n\&maybe_print_header\;\nprint \<\<EOF\;\n";

                print $out
                  start_html("-title" => "Search in progress",
                             "-head" => ["<meta http-equiv=refresh
content=5>"],
                             ),
                  h1("Search in progress"),
                  p("The search is still in progress.  Please reload
this page."),
                  end_html; 
                ## implicit close
  
    print $out "\nEOF\nexit;";
              }
              
#              print "\n\ncreated in progress file with autorefresh
every 5\n\n";
              
              defined(my $childpid = fork()) or die "Cannot fork: $!";
              if ($childpid < 0) {              # parent does:
  
#  print "\n\nparent redirects to in progress file and child
forked\n\n";
#  print "Status: 302 Moved\n";
#  print "Location: [url]$session_html\n\n[/url]";

#                maybe_print_header();
  print redirect($URL_html);
#                print "parent says hello - pid of child is
:$childpid:";
                
              } else {                      # child does:

                open STDIN, "</dev/null";
                open STDOUT, ">/dev/null";

#  print "\n\nchild is gonna sleep for 15\n\n";

                sleep 30;                   # simulate search time

#  print "\n\nchild is done sleeping for 15\n\n";

                {
#                 my $out = IO::File->new($DIR_html_tmp,"w") or
    my $out = IO::File->new("$session.html.tmp", "w") or 
                    die "Cannot create $DIR_html_tmp: $!";
  print $out "\#\!d:\\perl\\bin\\perl.exe\nuse CGI qw\/:standard\/;\n
BEGIN \{\nmy \$header_printed = 0; sub maybe_print_header \{print
header\(\@\_\) unless \$header_printed;\$header_printed =
1\;\}\}\n\&maybe_print_header\;\nprint \<\<EOF\;\n";

                  print $out
                    start_html("Search results"),
                    h1("Search results"),
                    p("I've found the item ",
                      ent($searchstring),
                      ", but I can't tell you where :-)."),
                    end_html;
                  ## implicit close
    print $out "\nEOF\nexit;";

                }
                #rename $DIR_html_tmp, $DIR_html or
                
                rename "$session.html.tmp", "$session.pl" or
                  die "Cannot rename $DIR_html_tmp to $DIR_html: $!";

#  print "\n\nchild creates found file and renames it to old in
progrss file\n\n";

              }
            }
            
            
    
</code>


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

Date: Mon, 10 Mar 2003 21:06:00 +0000
From: Paul Silver <singleantler-news@hotmail.com>
Subject: Merging log files using hash - good idea/possible?
Message-Id: <ehvp6vorcaavpc13ojnsee06lk573h2os2@4ax.com>

Hi,

Where I work we use Webtrends to analyse our web server stats. We run
a cluster so it creates two sets of logs, which Webtrends can't handle
unless we buy a very expensive upgrade, so I'd like to use Perl to
merge the files in to one so it can be read.

I've been reading various docs and some of the O'Reilly books (lying
around waiting for a bigger project I knew I wanted to use Perl for)
but I'd like to check whether what I am doing is possible, the way I'm
trying to do it.

Basically, these are IIS logs, and are set up to have the date, time,
then various other information. I'm only processing a day at a time,
but I need each line in time order, increasing down the file.

What I thought I'd do is read in file1 and read through it line by
line, putting it in a hash. As the key to each line in the hash I
would take the time, removing the ':'s so it looks like a number. I'd
read the line from the log in to the hash.

I'd then do the same thing to file2, then sort the hash so the keys
ascend, and output it to a file, nicely in time order.

Just a couple of questions:

1 - Will this work, or am I mad? (or at least deluded)

2 - How can I output the hash as I sort it? Whenever I try and output
the hash without using a known key I'm just getting a large number,
rather than the bits of log file I've fed it.

Thanks for any help. I'm using ActiveState ActivePerl 5.8, if it makes
a difference. The logs are currently about 5Mb each every day, and we
can easily see them getting up to 15Mb within the year.

Cheers

Paul.
-- 
To e-mail, please remove '-news' from address.


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

Date: Mon, 10 Mar 2003 21:23:01 GMT
From: "dw" <me@verizon.invalid>
Subject: Re: Merging log files using hash - good idea/possible?
Message-Id: <Vm7ba.18877$gi1.11271@nwrdny02.gnilink.net>

"Paul Silver" <singleantler-news@hotmail.com> wrote in message
news:ehvp6vorcaavpc13ojnsee06lk573h2os2@4ax.com...
> What I thought I'd do is read in file1 and read through it line by
> line, putting it in a hash. As the key to each line in the hash I
> would take the time, removing the ':'s so it looks like a number. I'd
> read the line from the log in to the hash.
>

Assuming it is a log file and the entries in each file are in order, why not
read one line from each file, print the line with the earlier date, read the
next line from the file you just printed, repeat until EOF.  This will
prevent you from having to read in the whole file of both logs and creating
a huge unnecessary hash in memory.

open IN1, "<firstfile.log";
open IN2, "<secondfile.log";
open OUT, ">joined.log";

$line1 = <IN1>;
$line2 = <IN2>;
$dateofline1 = dateof($line1);
$dateofline2 = dateof($line2);

$done = 0;
until ($done) {
     if ($dateofline1 < $dateofline2) {
         print OUT $line1;
         $line1 = <IN1> or $done=1;
         $dateofline1 = dateof $line1;
     } else {
         print OUT $line2;
         $line2 = <IN2> or $done=2;
         $dateofline2 = dateof $line2;
     }
}

print $line2 if $done == 1;
print $line1 if $done == 2;
while (<IN1>) { print OUT $_; }
while (<IN2>) { print OUT $_; }

close IN1;
close IN2;
close OUT;


of course, since I don't have a log file, you would need to provide the
'dateof' function to convert a line into a number that could be used for
comparison.... maybe even in the way you mentioned, joining the year, month,
day, etc. together....




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

Date: Mon, 10 Mar 2003 15:42:15 -0600
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: Merging log files using hash - good idea/possible?
Message-Id: <b4j0ro$ic14@onews.collins.rockwell.com>

On 3/10/2003 3:06 PM, Paul Silver wrote:
> 
> We run a cluster so it creates two sets of logs [...]
> I'd like to use Perl to merge the files in to one so it can be read.
> 
> Basically, these are IIS logs, and are set up to have the date, time,
> then various other information. I'm only processing a day at a time,
> but I need each line in time order, increasing down the file.
> 
> What I thought I'd do is read in file1 and read through it line by 
> line, putting it in a hash.

No, don't do this. Storing an entire logfile in memory doesn't scale well.

> As the key to each line in the hash I would take the time, removing 
> the ':'s so it looks like a number.

Better to convert it to a true time string. There are lots of modules on
CPAN to do this sort of thing. (Date::Calc, Date::Manip, etc.)

> I'd read the line from the log in to the hash. I'd then do the same
> thing to file2, then sort the hash so the keys ascend, and output it
> to a file, nicely in time order.

Since the individual logfiles will already be ordered, you don't need to
get everything in memory at once. A better way, IMO, is to

1) Open each of your logfiles (readonly).
2) Open your merged output file (writeable).
3) Read one line from each of them.
4) Convert the timestamp into a number of seconds since the epoch.
5) Find the smallest timestamp, and write the corresponding line
   to the output file.
6) Read another line from the file you took a line from.

Repeat steps 4 .. 6 until you run out of data in all logfiles.

-mjc



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

Date: Mon, 10 Mar 2003 22:13:31 +0100
From: Guenter <no.spam@gknw.de>
Subject: Re: new Perl feature request: call into shared libs
Message-Id: <3E6CFFFB.90700@gknw.de>

Hi Bryan,

Bryan Castillo schrieb:
> Loading a .so is easy, as is finding a symbol within it.  You can see
> the man pages for dlopen and dlsym.  In fact the Dynaloader module has
> this basic functionality.  The asm I provided only works on Intel, you
> would have to port that to SPARC, Alpha, Motorolla whatever other
> architecture you have out there.  It is also ~ AT&T syntax.  Try
> assembling it with some other assembler.  I was going to write the XS
> to interface to it (for fun), but I wouldn't call it a new Unix::API,
> it would be much more specific than any Unix-like OS  (Unix != Linux,
> some even say Linux is not Unix).  Perhaps Linux::I386::SOCall or
> something....
good point: this probably also applies to the Win32::API module as NT 
runs also on ix86 and alpha...

> Of course you would also have to pack the Perl data somehow.  Are you
> passing pointers, chars, whatever.  (chars and shorts also seemed to
> be pushed onto the stack in 32 bit chunks for gcc).
> 
> I was thinking you would have a function that takes a string like that
> used by pack/unpack, a c-function name, a so-name or previously opened
> handle, and a perl function name to be created.  The function would
> create the perl code to pack the perl values into the appropriate
> binary formats, and call the c_function, (it should probably check
> argument counts also).
> 
> Any ideas?

well, I'm pretty happy with the way Win32::API handles it; and together 
with Win32::API::Prototype you can define the functions exactly as they 
appear in the headers...
and in most cases I did not pack the structs, instead I only allocated a 
unsigned char buffer great enough to hold the complete struct, and then 
only picked up my 2 or 3 values I needed with substr() and unpack()...
much less work than defining all members of a struct...

Guenter.




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

Date: 10 Mar 2003 21:09:34 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Newbie:  Extract info from MSI
Message-Id: <slrnb6pvoe.tvd.sholden@flexal.cs.usyd.edu.au>

On Mon, 10 Mar 2003 13:59:40 -0500, NCR Employee <ncremployee@ncr.com> wrote:
> Hello everyone:
> 
> I tried to extract info from MSI (Microsoft Windows Installer) file.  If you
> have any info/pointer related to this subject please show/forward it to me.

Did you just pick a random newsgroup?

I guess comp.lang.perl.MISc contains the letters, but in the wrong order.

A web search should find what you want, much much quicker than asking
in random unrelated newsgroups.

-- 
Sam Holden



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

Date: 10 Mar 2003 11:53:07 -0800
From: dsevilla@ditec.um.es (Diego Sevilla Ruiz)
Subject: Re: PERL & ORBit
Message-Id: <ee19f71b.0303101153.46fe5f6e@posting.google.com>

Hi:

Are you sure you have your IR running and with the Naming Service IDL feed in?

Best regards.
diego

"A.J" <aajii@yahoo.com> wrote in message news:<3E5CE1DF.F8376AA8@yahoo.com>...
> ORBit-0.5.8
> PERL5.00503
> CORBA-ORBit-0.4.3
> 
> I'm trying to connect to a VisiBroker5.02 corba server.
> I'm able to connect directly to service I need using it's IOR but I
> want to use NameService. I'm having some problems with it:
> 
> Should this go like this:
> 28: my $orb = CORBA::ORB_init( "orbit-local-orb" );
> 29: my $nameService = $orb->string_to_object( $nsIor );
> 30: $nameService->_narrow('IDL:omg.org/CosNaming/NamingContextExt:1.0');
> 
> 31: my $name = [{id => "TestFactory", kind => ""}];
> 32: my $object = $ns->resolve( $name );
> 33: # At this point I should have the TestFactory object which I'm able
> 34: # to connect to using direct IOR
> 
> >./test.pl
> autoloading _narrow
> Can't get interface
>  at ./test.pl line 30


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

Date: Mon, 10 Mar 2003 22:21:58 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Perl Mysql uploading a image in a database.
Message-Id: <slrnb6q406.llc.mgjv@verbruggen.comdyn.com.au>

On Mon, 10 Mar 2003 10:53:15 +0000,
	Simon Andrews <simon.andrews@bbsrc.ac.uk> wrote:
> Martien Verbruggen wrote:
>> 
>> On 7 Mar 2003 niels <niels_bond@hotmail.com> wrote:
>> > my($afbeelding);
>> > {
>> > local $/=undef;
>> 
>> You need to open the image, and use binmode.
>> 
>> > $afbeelding=<$reclame_image>;
>> 
>> This, confusingly, does not read from the file, but will treat
>> $reclame_image as a glob pattern (see the glob entry in perlfunc).
> 
> I don't think this is the case (I could be wrong!), $reclame_image comes
> from a CGI upload field, so the param call returns a filehandle, which
> can be read as set out above.  He should of course be using the CGI.pm
> upload method really, but param will still work (albeit not under
> strictures).

You're most likely right. I sort of assumed that a file name was being
passed in, but it's probably the image data itself, as a result from
some upload thingie.

Martien
-- 
                        | 
Martien Verbruggen      | 
Trading Post Australia  | Curiouser and curiouser, said Alice.
                        | 


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

Date: 10 Mar 2003 11:59:24 -0800
From: bill_reynolds@hotmail.com (Bill Reynolds)
Subject: Re: Perl Script or Bourne Shell for a Cisco router, Please Help??
Message-Id: <27439ec3.0303101159.2fb6b5b7@posting.google.com>

If you're looking into a Perl solution, the Net::Telnet module should help you out:

http://search.cpan.org/author/JROGERS/Net-Telnet-3.03/

mdargin@msn.com (eugene123) wrote in message news:<620f649f.0303100759.62cbdea3@posting.google.com>...
> I would like to send a script out on my server to make some
> configuation changes on 25 Cisco routers.
> 
> I need to enter this command on the 25 Cisco routers.
> 
> ntp server 10.2.3.1
> ip name server 10.1.5.6
> 
> So basically I need to write a script (Perl or Bourne) to telnet to
> each of the 25 routers, use the default vty and enable password and go
> into config mode to enter in the commands and then to exit out of the
> router and then telnet to the next router for the next sequence.
> 
> Command sequence for router 1 for the script ( this is what I want the
> script to do )
> 
> Command: telnet x.x.x.x
> <enter vty password> I want the script to enter this password: bankee
> Command: enable
> <enter enable password> I want the script to enter this password:
> cisco
> Command: config t
> Command: ntp server 10.2.3.1
> Command: ip name server 10.1.5.6
> Command: end
> Command: exit
> 
> I appreciate any responses.  Thank You in Advanced


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

Date: Mon, 10 Mar 2003 21:31:23 +0100
From: "Andree" <Andree@nospam-toonk.nl>
Subject: Re: Perl Script or Bourne Shell for a Cisco router, Please Help??
Message-Id: <3e6cf800$0$141$e4fe514c@dreader7.news.xs4all.nl>


"eugene123" <mdargin@msn.com> wrote in message
news:620f649f.0303100759.62cbdea3@posting.google.com...
> I would like to send a script out on my server to make some
> configuation changes on 25 Cisco routers.
>

This is a simple bash script:
In the file input you put the commandos like

password
en
password
conf t
ntp server 10.2.3.1
ip name server 10.1.5.6


<shell script>
#!/bin/bash
# 08-03-2003 Andree Toonk, AMS-IX
# telnet-router sysname
# where:
#sysname - The system to which you wish to telnet
#
# Use this with a "pipe" or "redirect" to allow sending a stream of commands
# to a remote system via telnet.
# ./telnet-router hostname < input
#
# Program
#
TFILE=/tmp/tsc.$$
echo '#!/bin/sh' > $TFILE
echo '(' >> $TFILE
sed -e 's/\(.*\)/sleep 4 \; echo "\1"/' >> $TFILE
echo 'cat - ) | telnet' $1 >> $TFILE
chmod 700 $TFILE
$TFILE
rm $TFILE
<EOF>




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

Date: Tue, 11 Mar 2003 09:13:58 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: Perl Script or Bourne Shell for a Cisco router, Please Help??
Message-Id: <b4j2n8$15caiu$1@ID-172104.news.dfncis.de>


"eugene123" <mdargin@msn.com> wrote in message
news:620f649f.0303100759.62cbdea3@posting.google.com...
> I would like to send a script out on my server to make some
> configuation changes on 25 Cisco routers.

The obvious Perl candidate are the first three matches from
http://search.cpan.org/search?query=cisco&mode=all




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

Date: Mon, 10 Mar 2003 14:31:03 -0600
From: "Sean W. Ellis" <sellis@totallygeek.com>
Subject: perl to strip high-end ASCII
Message-Id: <v6ptg7hnofi9e7@corp.supernews.com>

Was wondering if there was a quick and dirty way to strip high-end ASCII
from a text file?

I have a file when I use less it shows stuff like:

Aladdin<92>s
<92><94> <97>The Arabian

I would like to just remove that from the file.  I tried this with sed
but maybe my syntax is jacked:

cat file.txt | sed 's/\092//g;s/\094//g;s/\097//g' > dump.txt

I looked from an ord function in perl, thinking in c I would look at it
like:

// filter the next character

if ( ord(characternext)  > HIGHESTASCIIWANTED ) { 
   //don't write the character to the dump file 
}


Any help appreciated.

Thank you,

Sean
-- 
Sean W. Ellis, CNE, RHCE


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

Date: Mon, 10 Mar 2003 21:14:49 +0000 (UTC)
From: Xavier Noria <fxn@hashref.com>
Subject: Re: perl to strip high-end ASCII
Message-Id: <b4iv89$ii2$1@news.ya.com>

In article <v6ptg7hnofi9e7@corp.supernews.com>, Sean W. Ellis wrote:

: Was wondering if there was a quick and dirty way to strip high-end ASCII
: from a text file?
: 
: I have a file when I use less it shows stuff like:
: 
: Aladdin<92>s
:<92><94> <97>The Arabian
: 
: I would like to just remove that from the file.  I tried this with sed
: but maybe my syntax is jacked:
: 
: cat file.txt | sed 's/\092//g;s/\094//g;s/\097//g' > dump.txt

# assumes \177 is the highest wanted value

cat file.txt | perl -pwe 'tr,\000-\177,,cd' > dump.txt

-- fxn


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

Date: Mon, 10 Mar 2003 21:45:56 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: perl to strip high-end ASCII
Message-Id: <3E6D0792.C1C32C72@acm.org>

"Sean W. Ellis" wrote:
> 
> Was wondering if there was a quick and dirty way to strip high-end ASCII
> from a text file?

What do you mean by "high-end ASCII"?  ASCII defines the characters from
0 through 127 (7f hex).


> I have a file when I use less it shows stuff like:
> 
> Aladdin<92>s
> <92><94> <97>The Arabian
> 
> I would like to just remove that from the file.  I tried this with sed
> but maybe my syntax is jacked:
> 
> cat file.txt | sed 's/\092//g;s/\094//g;s/\097//g' > dump.txt
                          ^         ^         ^
There is no '9' digit in octal numbers.  You have to convert <92> etc.
from whichever base they are in (probably decimal or haxadecimal) to
octal for this to work.  (also - UUOC)


> I looked from an ord function in perl, thinking in c I would look at it
> like:
> 
> // filter the next character
> 
> if ( ord(characternext)  > HIGHESTASCIIWANTED ) {
>    //don't write the character to the dump file
> }
> 
> Any help appreciated.

If you just want to remove non-ASCII characters:

perl -pe'tr/\0-\177//cd' file.txt > dump.txt



P.S.  If you want help with unix shell commands like sed, tr, etc. you
should ask in comp.unix.shell


John
-- 
use Perl;
program
fulfillment


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

Date: 10 Mar 2003 13:37:21 -0800
From: baburob987@yahoo.com (bab)
Subject: Perl Vs C,C++
Message-Id: <225390b8.0303101337.3074f8bd@posting.google.com>

Hi
 Does anyone have a listing of Perl Vs C, C++ not just from Object
Oriented perspective alone. Basically that listing should give
similarties, differences between Perl Vs C, C++.


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

Date: Mon, 10 Mar 2003 21:54:17 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Perl Vs C,C++
Message-Id: <x7adg2opkp.fsf@mail.sysarch.com>

>>>>> "b" == bab  <baburob987@yahoo.com> writes:

  b>  Does anyone have a listing of Perl Vs C, C++ not just from Object
  b> Oriented perspective alone. Basically that listing should give
  b> similarties, differences between Perl Vs C, C++.

no.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class


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

Date: Tue, 11 Mar 2003 08:02:10 +1000
From: Derek Thomson <dthomson@NOSPAMusers.sf.net>
Subject: Re: Perl Vs C,C++
Message-Id: <3e6d0b66$0$11660$afc38c87@news.optusnet.com.au>

bab wrote:
> Hi
>  Does anyone have a listing of Perl Vs C, C++ not just from Object
> Oriented perspective alone. Basically that listing should give
> similarties, differences between Perl Vs C, C++.

You would be better off doing your homework yourself. That's why it was set.

--
Derek.



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

Date: Mon, 10 Mar 2003 22:32:55 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Perl Vs C,C++
Message-Id: <slrnb6q4kn.llc.mgjv@verbruggen.comdyn.com.au>

On 10 Mar 2003 13:37:21 -0800,
	bab <baburob987@yahoo.com> wrote:
> Hi
>  Does anyone have a listing of Perl Vs C, C++ not just from Object
> Oriented perspective alone. Basically that listing should give
> similarties, differences between Perl Vs C, C++.


This would be a start, although it needs a little bit of work,
especially from the Object Oriented perspective:


1) Similarities

    a) between C and C++
        
        - They both have a C in the name.
        - The GNU compiler set can compile both.

    b) between C and Perl
        
        - Both have a language keyword "if".
        - Both have 

    c) between C++ and Perl

        - Both have a language keyword "if".

    d) between all three languages

        - They are all computer programming languages.
        - They can all be compiled (and traditionally are)
        - They can all be interpreted
        - All three can be used for OO programming.


2) Differences 

    a) between C and C++

        - One has a different number of characters from the other.

    b) between C and Perl
        
        - see 2a)
        - perl can read Perl, but not C
        - A c compiler can read C, but not Perl

    c) between C++ and Perl

        - see 2b) (substitute C++ for C)

    d) between all three languages

        - see 2a)
        - C and C++ are traditionally compiled into machine code, Perl
          into opcode trees.


If you give us the name and electronic contact details of your
instructor, we'll email a more complete list directly to their
address.

Martien
-- 
                        | 
Martien Verbruggen      | If it isn't broken, it doesn't have enough
Trading Post Australia  | features yet.
                        | 


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

Date: Tue, 11 Mar 2003 09:17:13 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: Re to all
Message-Id: <b4j2tb$1virpn$1@ID-172104.news.dfncis.de>


"Hum Rattle" <humrattle@hotmail.com> wrote in message
news:b4idbp$214bqj$1@ID-63849.news.dfncis.de...
[please leave in the attributions, otherwise we don't know who you're
following up to]

>
> > I don't believe you.
> > Are you seriously claiming that you are using WebTV or some other device
> > that doesn't have any shell as your software development platform?
>
> Eever heard of webspace with just a ftp account and no shell access?

I would find it very difficult to believe that you do all your development
via FTP.  How the hell do you manage to edit the file with FTP?  Much easier
to write and test and scripts locally.





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

Date: Mon, 10 Mar 2003 21:10:05 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: remove anything from string except two words
Message-Id: <3E6CFF2B.79824D9@acm.org>

Pynex wrote:
> 
> > $newstring = "is know" if $oldstring =~ /(?=is).*?(?=know)/;
> >
> > Or:
> >
> > ( $newstring = $oldstring ) =~ s/.*?(is).*?(know).*/$1 $2/;
> 
> Thanks for your answer, but I'm sorry. What i've written was not
> accurate.
> 
> another example:
> 
> $oldstring="XZ-6666 XXX Systems Version 5.6(17) Copyright 2002"
> 
> Now i want to cut out "XZ-6666" and "Version 5.6(17)".
> 
> The XZ- and Version Number aren't the same everytime.
> 
> It's always XZ-????  and Version ?.?(??)
> 
> What makes it a little bit difficult, the order in which this things
> occur, arent't the same evertime.
> 
> Sometimes they're like: "Version 5.6(17)   Copyright 2002  XXX Systems
> XZ-6666"

( $newstring = $oldstring ) =~ s/Version\s+\d+\.\d+\(\d+\)|XZ-\d+//g;


John
-- 
use Perl;
program
fulfillment


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

Date: 10 Mar 2003 21:03:35 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Trying to Learn Chomp
Message-Id: <b4iuj7$81d$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Buck Turgidson:

> I am learning Perl (slowly).  I have some confusion about the chomp
> function.  According to "Learning Perl", it only operates on the newline.
> 
> Below, when commented out, it prints the before and after of each line after
> the substitution.  When I uncomment it, it only prints the last line.

Sounds like a typical buffering problem. STDOUT is usually line-buffered
so you might need to force a flush after each print. Add
    
    $| = 1;

to the top of your script and the problem should go away.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: 10 Mar 2003 21:14:56 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Word Boundaries
Message-Id: <b4iv8g$8pd$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Buck Turgidson:

> I am confused as to wny $a and $c below seem inconsistent.  In other words,
> both seem to be saying match on the word boundary, but in the case of $b it
> seems to be doing the opposite.
> 
> I would have expected $a and $c to match, and not $b.  Can someone
> straighten me out?
> 
> 
> 
> $a = "x + y";   # /\b\+\b/   does not match
> $b = "x+y";     # /\b\+\b/   matches
> $c = "a b c";   # /\bb\b/    matches

The \b thingy has actually zero-width. It does not relate to any
character, it's rather the boundary between characters. What it does is
basically separating word-characters from non-word-characters. That
means:

    "word," =~ /\bword\b,/;

is a succesful match. The second \b is between the 'd' of 'word' and the
comma. But it's not a character itself.

    "x + y" !~ /\b\+\b/;

because '+' is not a word character, and the characters on the left and
right aren't word-characters either.

    "x+y" =~ /\b\+\b/;

because between 'x' and '+' is one of those invisible word-boundaries
and so is one between '+' and 'y'.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Mon, 10 Mar 2003 11:52:16 -0800
From: "Brian Helterline" <brian_helterline@hp.com>
Subject: Re: XS code to call DLL
Message-Id: <b4iqee$16s$1@hpcvsgen.cv.hp.com>

"H. Merijn Brand" <h.m.brand@hccnet.nl> wrote in message
news:Xns933A96E9A6AECMerijn@192.0.1.90...
>
> +--------------------------------------------------------------------+
> | Win32::API 0.40                                                    |
> |   posted by pudge on Sunday March 09, @13:44 (modules)             |
> |   http://use.perl.org/article.pl?sid=03/03/08/2345221              |
> +--------------------------------------------------------------------+
>
> dada (mailto:dada@perl.it) writes "I've just released version 0.40 of
> Win32::API, the popular tool to import functions from Win32 DLLs. in a
> blurb, here's what this version can do: automatically define a Perl
> sub with the name of the imported API (eg. no more $function->Call(...)
> ugliness), support function prototypes (credits to Dave Roth for this),
> support C structures 'natively', support callbacks (very experimental).
> Enjoy!"
>
> Discuss this story at:
>     http://use.perl.org/comments.pl?sid=03/03/08/2345221
>

This sounds great!  I don't see the latest version on dada's website.  It
still has
version 0.20 so I'll start with that although the automatic import stuff
sounds
much cleaner...

Thanks for the pointers!

-brian




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

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


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