From gregory.machin at gmail.com Wed Jun 21 01:16:39 2006 From: gregory.machin at gmail.com (Gregory Machin) Date: Wed, 21 Jun 2006 10:16:39 +0200 Subject: [Za-pm] NewBe. Message-ID: <30200a940606210116u646877f9tec30c0380ab69566@mail.gmail.com> Hi all. I'm learning Perl because I need to migrate / extend an exisiting Perl cgi managment interface. Any advice on compiling / configuring perl to run on embedded hard ware plaforms ? Many thanks -- Gregory Machin greg at linuxpro.co.za gregory.machin at gmail.com www.linuxpro.co.za www.exponent.co.za Web Hosting Solutions Scalable Linux Solutions www.iberry.info (support and admin) +27 72 524 8096 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20060621/e1baf671/attachment.html From jonathan at hst.org.za Wed Jun 21 02:01:28 2006 From: jonathan at hst.org.za (Jonathan McKeown) Date: Wed, 21 Jun 2006 11:01:28 +0200 Subject: [Za-pm] NewBe. In-Reply-To: <30200a940606210116u646877f9tec30c0380ab69566@mail.gmail.com> References: <30200a940606210116u646877f9tec30c0380ab69566@mail.gmail.com> Message-ID: <200606211101.28660.jonathan@hst.org.za> On Wednesday 21 June 2006 10:16, Gregory Machin wrote: > Hi all. > I'm learning Perl because I need to migrate / extend an exisiting Perl cgi > managment interface. > Any advice on compiling / configuring perl to run on embedded hard ware > plaforms ? We need to know a bit more, about what you're trying to do and what the platform is, to answer this. Is the perl interpreter running on your platform, or is that what you need help with? What's the platform? What does the management interface do and where is the webserver/CGI running? Jonathan From gregory.machin at gmail.com Wed Jun 21 02:55:50 2006 From: gregory.machin at gmail.com (Gregory Machin) Date: Wed, 21 Jun 2006 11:55:50 +0200 Subject: [Za-pm] NewBe. In-Reply-To: <200606211101.28660.jonathan@hst.org.za> References: <30200a940606210116u646877f9tec30c0380ab69566@mail.gmail.com> <200606211101.28660.jonathan@hst.org.za> Message-ID: <30200a940606210255g33a574fer64dea0f6edb89440@mail.gmail.com> Sorry ... The Hardware is a Soekris NET4801, the current os is linux, what looks like a redhat derived, but this will be changed as to our os deverlopers requirements. The hardware has a i386 instruction set.. The interface is currently web cgi based.. The problem is when processing some of the pages it kills the cpu, I need to find away to optimise for this platform / cpu instuction set... I have also heard that there is an embedded version of perl, but have not found the home page for this project, even after alot google-ing.. On 6/21/06, Jonathan McKeown wrote: > > On Wednesday 21 June 2006 10:16, Gregory Machin wrote: > > Hi all. > > I'm learning Perl because I need to migrate / extend an exisiting Perl > cgi > > managment interface. > > Any advice on compiling / configuring perl to run on embedded hard ware > > plaforms ? > > We need to know a bit more, about what you're trying to do and what the > platform is, to answer this. > > Is the perl interpreter running on your platform, or is that what you need > help with? What's the platform? What does the management interface do and > where is the webserver/CGI running? > > Jonathan > _______________________________________________ > Za-pm mailing list > Za-pm at pm.org > http://mail.pm.org/mailman/listinfo/za-pm > -- Gregory Machin greg at linuxpro.co.za gregory.machin at gmail.com www.linuxpro.co.za www.exponent.co.za Web Hosting Solutions Scalable Linux Solutions www.iberry.info (support and admin) +27 72 524 8096 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20060621/f88206d7/attachment.html From jonathan at hst.org.za Wed Jun 21 07:36:26 2006 From: jonathan at hst.org.za (Jonathan McKeown) Date: Wed, 21 Jun 2006 16:36:26 +0200 Subject: [Za-pm] NewBe. In-Reply-To: <30200a940606210255g33a574fer64dea0f6edb89440@mail.gmail.com> References: <30200a940606210116u646877f9tec30c0380ab69566@mail.gmail.com> <200606211101.28660.jonathan@hst.org.za> <30200a940606210255g33a574fer64dea0f6edb89440@mail.gmail.com> Message-ID: <200606211636.26497.jonathan@hst.org.za> On Wednesday 21 June 2006 11:55, you wrote: > The Hardware is a Soekris NET4801, the current os is linux, what looks like > a redhat derived, but this will be changed as to our os deverlopers > requirements. The hardware has a i386 instruction set.. > The interface is currently web cgi based.. > The problem is when processing some of the pages it kills the cpu, I need > to find away to optimise for this platform / cpu instuction set... If it's only certain pages, it sounds more likely to be the program than perl itself. Is it always the same pages that create a problem? Do they create a problem every time they're called, or only sometimes? I'm not familiar with the NET4801 but I'm assuming you can get a shell on it - ssh or something. In that case try running top(1) (if you've got it) and then hitting the problem pages from the web interface to see which process is pegging the CPU. If it is perl or the CGI scripts, consider using Devel::DProf to profile the code and find the hotspots. If the code uses CGI.pm you can run it from the commandline for debugging. For documentation, use perldoc perldoc CGI perldoc Devel::DProf Jonathan From greg at linserv.co.za Wed Jun 21 23:49:04 2006 From: greg at linserv.co.za (Gregory Machin) Date: Thu, 22 Jun 2006 08:49:04 +0200 Subject: [Za-pm] NewBe. In-Reply-To: <200606211636.26497.jonathan@hst.org.za> References: <30200a940606210116u646877f9tec30c0380ab69566@mail.gmail.com> <200606211101.28660.jonathan@hst.org.za> <30200a940606210255g33a574fer64dea0f6edb89440@mail.gmail.com> <200606211636.26497.jonathan@hst.org.za> Message-ID: <449A3D60.6080608@gmail.com> Will look into it .. Thanks Jonathan McKeown wrote: > On Wednesday 21 June 2006 11:55, you wrote: > > >> The Hardware is a Soekris NET4801, the current os is linux, what looks like >> a redhat derived, but this will be changed as to our os deverlopers >> requirements. The hardware has a i386 instruction set.. >> The interface is currently web cgi based.. >> The problem is when processing some of the pages it kills the cpu, I need >> to find away to optimise for this platform / cpu instuction set... >> > > If it's only certain pages, it sounds more likely to be the program than perl > itself. Is it always the same pages that create a problem? Do they create a > problem every time they're called, or only sometimes? > > I'm not familiar with the NET4801 but I'm assuming you can get a shell on it - > ssh or something. In that case try running top(1) (if you've got it) and then > hitting the problem pages from the web interface to see which process is > pegging the CPU. > > If it is perl or the CGI scripts, consider using Devel::DProf to profile the > code and find the hotspots. If the code uses CGI.pm you can run it from the > commandline for debugging. For documentation, use perldoc > > perldoc CGI > perldoc Devel::DProf > > Jonathan > _______________________________________________ > Za-pm mailing list > Za-pm at pm.org > http://mail.pm.org/mailman/listinfo/za-pm > > From spikeh at mweb.co.za Mon Jun 26 00:46:37 2006 From: spikeh at mweb.co.za (Spike) Date: Mon, 26 Jun 2006 09:46:37 +0200 Subject: [Za-pm] regex ctrl char? Message-ID: <6.2.3.4.2.20060626094625.02e15268@pop3.mweb.co.za> Hi All I came across the code below while looking at a script written by someone who no longer works with us. Does anyone have any idea what the /\c@/ is meant to match? \c usually indicate a control character but I don't know what the @ is for. if($a_username=~/\c@/ || $a_authresult=~/\c@/ || $a_password_entry=~/\c@/) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20060626/8656b021/attachment.html From jonathan at hst.org.za Mon Jun 26 01:09:14 2006 From: jonathan at hst.org.za (Jonathan McKeown) Date: Mon, 26 Jun 2006 10:09:14 +0200 Subject: [Za-pm] regex ctrl char? In-Reply-To: <6.2.3.4.2.20060626094625.02e15268@pop3.mweb.co.za> References: <6.2.3.4.2.20060626094625.02e15268@pop3.mweb.co.za> Message-ID: <200606261009.14911.jonathan@hst.org.za> On Monday 26 June 2006 09:46, Spike wrote: > Hi All > I came across the code below while looking at a script written by > someone who no longer works with us. > > Does anyone have any idea what the /\c@/ is meant to match? > > \c usually indicate a control character but I don't know what the @ is for. > > > if($a_username=~/\c@/ || $a_authresult=~/\c@/ || $a_password_entry=~/\c@/) It's checking for NUL (ASCII 0), which can also be written "\0". Try print ord("\c@"); Jonathan From greg at linserv.co.za Mon Jun 26 06:02:25 2006 From: greg at linserv.co.za (Gregory Machin) Date: Mon, 26 Jun 2006 15:02:25 +0200 Subject: [Za-pm] regex ctrl char? In-Reply-To: <6.2.3.4.2.20060626094625.02e15268@pop3.mweb.co.za> References: <6.2.3.4.2.20060626094625.02e15268@pop3.mweb.co.za> Message-ID: <449FDAE1.2020501@gmail.com> I found this \cX An ASCII escape sequence - the character whose code point is X % 32 at http://www.boost.org/libs/regex/doc/syntax_perl.html Cheers Greg Spike wrote: > Hi All > I came across the code below while looking at a script written by > someone who no longer works with us. > > Does anyone have any idea what the /\c@/ is meant to match? > > \c usually indicate a control character but I don't know what the @ is > for. > > > if($a_username=~/\c@/ || $a_authresult=~/\c@/ || > $a_password_entry=~/\c@/) > > ------------------------------------------------------------------------ > > _______________________________________________ > Za-pm mailing list > Za-pm at pm.org > http://mail.pm.org/mailman/listinfo/za-pm From gregory.machin at gmail.com Wed Jun 28 22:37:33 2006 From: gregory.machin at gmail.com (Gregory Machin) Date: Thu, 29 Jun 2006 07:37:33 +0200 Subject: [Za-pm] loop adding \n to array ?? Message-ID: <30200a940606282237s3b183beejd227015615abb081@mail.gmail.com> Hi I have been writing a script to pass a directory the remove all the files starting with "+" and put them in a an array @del_files and all the remaining in an array @ctr_file The problem Im having is that where the +FILE 's used to be I get blank lines with "\n" in the @ctr_file, which I don't want . find sub { push(@tmp ,$File::Find::name, -d && '/', "\n") }, $tmp_dir; #find all files starting with a plus foreach (@tmp) { $_ =~ s/$tmp_dir\/// ; # remove the path to the input working dir so only # the files and directories in the working dir are used $_ =~ s/\/$//; #remove trailing "/" # /^\+\w+/i filter all files starting with "+" if ($_ =~ /^\+\w+/i ){ push(@del_files, $_); $_ = "0"; } # filter and pass files starting with + to @del_files for removale #print "$_"; if ($_ ne "0"){ push(@ctr_file , "$_"); print "$_"; } } Many thanks for you time Greg -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20060629/f2befec4/attachment.html From spikeh at mweb.co.za Wed Jun 28 23:12:38 2006 From: spikeh at mweb.co.za (Spike) Date: Thu, 29 Jun 2006 08:12:38 +0200 Subject: [Za-pm] loop adding \n to array ?? In-Reply-To: <30200a940606282237s3b183beejd227015615abb081@mail.gmail.co m> References: <30200a940606282237s3b183beejd227015615abb081@mail.gmail.com> Message-ID: <6.2.3.4.2.20060629074835.02dc13d0@pop3.mweb.co.za> So many ways to do the same thing in perl! I would probably have gone:- opendir (DIR, "$my_directory") or die("could not open DIR as $my_directory Error: $!"); @dir = readdir DIR; foreach (@dir) { chomp; if (m/^\+\w/) { push (@del_files, $_); } else { push (@ctr_file, $_); } } foreach (del_files) { unlink ($my_director/$_) or die("unlink failed $!); } # assuming a unix type OS; I have often found that file manipulation is one of the few places where a system call directly to the underlining OS commands is better than the PERL commands. So maybe:- foreach (del_files) { $status = system("rm -f $my_director/$_"); die unless $status == 0; } At 2006/06/29 07:37 AM, you wrote: >Hi >I have been writing a script to pass a directory the remove all the >files starting with "+" and put them in a an array @del_files and >all the remaining in an array @ctr_file >The problem Im having is that where the +FILE 's used to be I get >blank lines with "\n" in the @ctr_file, which I don't want . > >find sub { push(@tmp ,$File::Find::name, -d && '/', "\n") }, $tmp_dir; > >#find all files starting with a plus >foreach (@tmp) { > > $_ =~ s/$tmp_dir\/// ; # remove the path to the input working > dir so only > # the files and directories in the working dir are used > $_ =~ s/\/$//; #remove trailing "/" > # /^\+\w+/i filter all files starting with "+" > if ($_ =~ /^\+\w+/i ){ push(@del_files, $_); $_ = "0"; } # > filter and pass files starting with + to @del_files for removale > > #print "$_"; > if ($_ ne "0"){ > push(@ctr_file , "$_"); > print "$_"; > } >} > > >Many thanks for you time >Greg >_______________________________________________ >Za-pm mailing list >Za-pm at pm.org >http://mail.pm.org/mailman/listinfo/za-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20060629/190346fd/attachment.html From gregory.machin at gmail.com Wed Jun 28 23:56:36 2006 From: gregory.machin at gmail.com (Gregory Machin) Date: Thu, 29 Jun 2006 08:56:36 +0200 Subject: [Za-pm] loop adding \n to array ?? In-Reply-To: <6.2.3.4.2.20060629074835.02dc13d0@pop3.mweb.co.za> References: <30200a940606282237s3b183beejd227015615abb081@mail.gmail.com> <6.2.3.4.2.20060629074835.02dc13d0@pop3.mweb.co.za> Message-ID: <30200a940606282356v7d956e60o99ce4635f898425@mail.gmail.com> thanks for the alternative methode. but why does this not work ..... if ($_ =~ /^\+\w+/i ){ push(@del_files, $_); $_ = "0"; } # filter and pass files starting with + to @del_files for removale #print "$_"; if ($_ ne "0"){ <<<<<<<<<<<< why is this logic still creating "\ n" in the array .. it should only append to the array if $_ holds a valid path. push(@ctr_file , "$_"); print "$_"; } On 6/29/06, Spike wrote: > > So many ways to do the same thing in perl! > > I would probably have gone:- > > opendir (DIR, "$my_directory") > or die("could not open DIR as $my_directory Error: $!"); > > @dir = readdir DIR; > > foreach (@dir) > { > chomp; > > if (m/^\+\w/) > { > push (@del_files, $_); > } > else > { > push (@ctr_file, $_); > } > } > > foreach (del_files) > { > unlink ($my_director/$_) or die("unlink failed $!); > } > > # assuming a unix type OS; I have often found that file manipulation is > one of the few places where a system call directly to the underlining OS > commands is better than the PERL commands. So maybe:- > > foreach (del_files) > { > $status = system("rm -f $my_director/$_"); > die unless $status == 0; > } > > > > > > > At 2006/06/29 07:37 AM, you wrote: > > Hi > I have been writing a script to pass a directory the remove all the files > starting with "+" and put them in a an array @del_files and all the > remaining in an array @ctr_file > The problem Im having is that where the +FILE 's used to be I get blank > lines with "\n" in the @ctr_file, which I don't want . > > find sub { push(@tmp ,$File::Find::name, -d && '/', "\n") }, $tmp_dir; > > #find all files starting with a plus > foreach (@tmp) { > > $_ =~ s/$tmp_dir\/// ; # remove the path to the input working dir so > only > # the files and directories in the working dir are > used > $_ =~ s/\/$//; #remove trailing "/" > # /^\+\w+/i filter all files starting with "+" > if ($_ =~ /^\+\w+/i ){ push(@del_files, $_); $_ = "0"; } # filter and > pass files starting with + to @del_files for removale > > #print "$_"; > if ($_ ne "0"){ > push(@ctr_file , "$_"); > print "$_"; > } > } > > > Many thanks for you time > Greg > _______________________________________________ > Za-pm mailing list > Za-pm at pm.org > http://mail.pm.org/mailman/listinfo/za-pm > > _______________________________________________ > Za-pm mailing list > Za-pm at pm.org > http://mail.pm.org/mailman/listinfo/za-pm > > -- Gregory Machin greg at linuxpro.co.za gregory.machin at gmail.com www.linuxpro.co.za www.exponent.co.za Web Hosting Solutions Scalable Linux Solutions www.iberry.info (support and admin) +27 72 524 8096 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20060629/c254849e/attachment.html From tvilliers at lastminute.com Thu Jun 29 01:35:21 2006 From: tvilliers at lastminute.com (Tielman de Villiers) Date: Thu, 29 Jun 2006 09:35:21 +0100 Subject: [Za-pm] loop adding \n to array ?? In-Reply-To: <30200a940606282356v7d956e60o99ce4635f898425@mail.gmail.com> References: <30200a940606282237s3b183beejd227015615abb081@mail.gmail.com> <6.2.3.4.2.20060629074835.02dc13d0@pop3.mweb.co.za> <30200a940606282356v7d956e60o99ce4635f898425@mail.gmail.com> Message-ID: <1151570121.15461.2.camel@localhost.localdomain> On Thu, 2006-06-29 at 08:56 +0200, Gregory Machin wrote: > thanks for the alternative methode. > > but why does this not work ..... > if ($_ =~ /^\+\w+/i ){ push(@del_files, $_); $_ = "0"; } # filter and > pass files starting with + to @del_files for removale > > #print "$_"; > if ($_ ne "0"){ <<<<<<<<<<<< why is this logic still creating "\ try if ( $_ != 0 ) { --tielman ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com ********************************************************************** From nick at cleaton.net Thu Jun 29 01:53:07 2006 From: nick at cleaton.net (Nick Cleaton) Date: Thu, 29 Jun 2006 08:53:07 +0000 Subject: [Za-pm] loop adding \n to array ?? In-Reply-To: <30200a940606282237s3b183beejd227015615abb081@mail.gmail.com> References: <30200a940606282237s3b183beejd227015615abb081@mail.gmail.com> Message-ID: <20060629085307.GC7556@lt1.cleaton.net> On Thu, Jun 29, 2006 at 07:37:33AM +0200, Gregory Machin wrote: > Hi > I have been writing a script to pass a directory the remove all the files > starting with "+" and put them in a an array @del_files and all the > remaining in an array @ctr_file > The problem Im having is that where the +FILE 's used to be I get blank > lines with "\n" in the @ctr_file, which I don't want . > > find sub { push(@tmp ,$File::Find::name, -d && '/', "\n") }, $tmp_dir; ^^^^^^^^^^^^^^ For each file that gets found you're putting 3 elements into @tmp: 1) the name of the file 2) "/" if the file is a directory, the empty string otherwise 3) "\n" So that is where the "\n"s are coming from. Nick -- $_='7eeYiU*** http://www.exonetric.com/ Telehouse UK colo ***9l?RP**' .'#3o#kO"Ri*** GBP 34 per month +VAT for 1U + 40G BW ***J(Xg**' .'KPcK`16vsk*** ***mMk**' ;s/(.)(.*(.))/$2.chr(32+(ord($1)+ord$3)%89)/euntil/Foo/;eval#****' From jonathan at hst.org.za Thu Jun 29 08:23:53 2006 From: jonathan at hst.org.za (Jonathan McKeown) Date: Thu, 29 Jun 2006 17:23:53 +0200 Subject: [Za-pm] loop adding \n to array ?? In-Reply-To: <30200a940606282237s3b183beejd227015615abb081@mail.gmail.com> References: <30200a940606282237s3b183beejd227015615abb081@mail.gmail.com> Message-ID: <200606291723.53930.jonathan@hst.org.za> On Thursday 29 June 2006 07:37, Gregory Machin wrote: > find sub { push(@tmp ,$File::Find::name, -d && '/', "\n") }, $tmp_dir; > > #find all files starting with a plus > foreach (@tmp) { > > $_ =~ s/$tmp_dir\/// ; # remove the path to the input working dir so > only > # the files and directories in the working dir are used > $_ =~ s/\/$//; #remove trailing "/" > # /^\+\w+/i filter all files starting with "+" > if ($_ =~ /^\+\w+/i ){ push(@del_files, $_); $_ = "0"; } # filter and > pass files starting with + to @del_files for removale > > #print "$_"; > if ($_ ne "0"){ > push(@ctr_file , "$_"); > print "$_"; > } > } Nick Cleaton pointed out that in the find line, you're pushing three values onto the @tmp array for each filename, which accounts for your "\n"s. The middle value is either an empty string, for non-directories, or '/' for directories. / is not the ideal value to have occurring in a list of files and directories for deletion. Depending whether you need the @ctr_files list or not, you might try either find sub { push @tmp, $File::Find::name }, $tmp_dir; for my $file (@tmp) { # $file =~ s!^$tmp_dir/!!; if ($file =~ /^\+/) { push @del_files, $file } else { push @ctr_files, $file } } or find sub { push @tmp, $File::Find::name }, $tmp_dir; #@tmp = map { s!^$tmp_dir/!! } @tmp; @del_files = grep { /^\+/ } @tmp; The second one doesn't create @ctr_files (obviously). In both cases you can include or leave out the commented line which removes $tmp_dir/ from the start of the full pathname, depending whether you want an absolute or relative path to the file. (I've used ! as the delimiter in the s/// rather than the usual /, because it saves escaping the / on the end of the dirname. Remember you can use anything as the delimiter for quote-like operators). You've called your arrays @del_files and @ctr_files: they will also contain directories. One way to eliminate all directories from the lists is to change your find line to find sub { my $name = $File::Find::name; push @tmp, $name unless $name eq $File::Find::dir; }, $tmp_dir; Jonathan