From richard at rushlogistics.com Tue Mar 2 06:46:47 2010 From: richard at rushlogistics.com (Richard Reina) Date: Tue, 02 Mar 2010 09:46:47 -0500 (EST) Subject: [Chicago-talk] messy scalar into an array. Message-ID: <20100302144647.800FB38E5@courageux.xo.com> I'm sorry for asking what likely should be a simple question but after spending a fair amount of time playing with qw(), split(), join(), etc. I still have not figured it out. I have some fairly messy system output which I have managed to isolate into a scalar with use strict; my @received = `faxstat -r`; I can't figure out how to neatly get this into an array so I can get the output into a database table; I've gotten this far; my $line; my @fax; foreach $line (@received) { if (substr($line,0,5) eq "-rw---") { # make sure it's an actual fax # and not the title of the output chomp($line); } } $line is exactly what I want but it's in the form of a scalar; When I try to split it up into elements of an array with @fax=split("", $line); it does not work due to all the back to back white spaces. If anyone can help me out with a better way to do this I would really appreciate it. Thanks, Richard From amead at alanmead.org Tue Mar 2 07:24:24 2010 From: amead at alanmead.org (Alan Mead) Date: Tue, 02 Mar 2010 09:24:24 -0600 Subject: [Chicago-talk] messy scalar into an array. In-Reply-To: <20100302144647.800FB38E5@courageux.xo.com> References: <20100302144647.800FB38E5@courageux.xo.com> Message-ID: <4B8D2DA8.1000804@alanmead.org> Would this help? (I don't understand what the line format is): $line =~ s/\s+/ /g; On 3/2/2010 8:46 AM, Richard Reina wrote: > I'm sorry for asking what likely should be a simple question but after spending a fair amount of time playing with qw(), split(), join(), etc. I still have not figured it out. > > I have some fairly messy system output which I have managed to isolate into a scalar with > > use strict; > my @received = `faxstat -r`; > > I can't figure out how to neatly get this into an array so I can get the output into a database table; > > I've gotten this far; > > my $line; > my @fax; > > foreach $line (@received) { > > if (substr($line,0,5) eq "-rw---") { # make sure it's an actual fax > # and not the title of the output > chomp($line); > } > } > > $line is exactly what I want but it's in the form of a scalar; When I try to split it up into elements of an array with @fax=split("", $line); it does not work due to all the back to back white spaces. If anyone can help me out with a better way to do this I would really appreciate it. > > Thanks, > > Richard > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > > -- Alan D. Mead, Ph.D. Assistant Professor, Institute of Psychology Scientific Adviser, Center for Research and Service Illinois Institute of Technology 3101 South Dearborn, 2nd floor Chicago IL 60616 Skype: alandmead +312.567.5933 (Campus) +815.588.3846 (Home Office) +312.567.3493 (Fax) http://mypages.iit.edu/~mead http://www.center.iit.edu http://www.alanmead.org I slept and dreamt that life was joy. I awoke and saw that life was service. I acted and behold, service was joy. -- attributed to Rabindranath Tagore From pcmantz at gmail.com Tue Mar 2 07:25:01 2010 From: pcmantz at gmail.com (Paul Mantz) Date: Tue, 2 Mar 2010 09:25:01 -0600 Subject: [Chicago-talk] messy scalar into an array. In-Reply-To: <20100302144647.800FB38E5@courageux.xo.com> References: <20100302144647.800FB38E5@courageux.xo.com> Message-ID: <42f28fe1003020725n7264f5d9wa730d31bf265a923@mail.gmail.com> On Tue, Mar 2, 2010 at 8:46 AM, Richard Reina wrote: > $line is exactly what I want but it's in the form of a scalar; ?When I try to split it up into elements of an array with @fax=split("", $line); it does not work due to all the back to back white spaces. ?If anyone can help me out with a better way to do this I would really appreciate it. > I've never used faxstat before, but i would think that you might want to try: @fax = split(/\s+/, $line) ; Which will split on whitespace and give you the relevant whitespace-separated fields. If that isn't what you're looking for, could you post an example of the data you're looking at and the desired outcome? Adios, -- Paul Mantz http://www.mcpantz.org Zmanda - Open source backup and recovery http://www.zmanda.com/ From younda at gmail.com Tue Mar 2 07:33:17 2010 From: younda at gmail.com (David J. Young) Date: Tue, 2 Mar 2010 09:33:17 -0600 Subject: [Chicago-talk] messy scalar into an array. In-Reply-To: <20100302144647.800FB38E5@courageux.xo.com> References: <20100302144647.800FB38E5@courageux.xo.com> Message-ID: <7001e3dd1003020733j49d9d79axa02a905e2c424bf@mail.gmail.com> I have no idea what your faxstat -r output looks like, but why no collapse all of the white space down to single spaces, then you can split on the singles space: $line =~ s/\s+/ /g; then you can split on the single space. DB<3> $line = 'a b c d e f'; DB<4> $a=$line DB<5> $a =~ s/\s+/ /g; DB<6> p $a a b c d e f DB<7> @a=split(" ", $a); DB<8> x @a 0 'a' 1 'b' 2 'c' 3 'd' 4 'e' 5 'f' ydy On Tue, Mar 2, 2010 at 8:46 AM, Richard Reina wrote: > I'm sorry for asking what likely should be a simple question but after > spending a fair amount of time playing with qw(), split(), join(), etc. I > still have not figured it out. > > I have some fairly messy system output which I have managed to isolate into > a scalar with > > use strict; > my @received = `faxstat -r`; > > I can't figure out how to neatly get this into an array so I can get the > output into a database table; > > I've gotten this far; > > my $line; > my @fax; > > foreach $line (@received) { > > if (substr($line,0,5) eq "-rw---") { # make sure it's an actual fax > # and not the title of the output > chomp($line); > } > } > > $line is exactly what I want but it's in the form of a scalar; When I try > to split it up into elements of an array with @fax=split("", $line); it does > not work due to all the back to back white spaces. If anyone can help me > out with a better way to do this I would really appreciate it. > > Thanks, > > Richard > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > -- I take the "Shhhh" out of IT - ydy -------------- next part -------------- An HTML attachment was scrubbed... URL: From richard at rushlogistics.com Tue Mar 2 07:34:09 2010 From: richard at rushlogistics.com (Richard Reina) Date: Tue, 02 Mar 2010 10:34:09 -0500 (EST) Subject: [Chicago-talk] messy scalar into an array. In-Reply-To: <20100302144647.800FB38E5@courageux.xo.com> Message-ID: <20100302153410.0A13523C3@bellona.xo.com> Thank you very much Paul and Alan. That was exactly what I needed. Again, many thanks. ---- Chicago.pm chatter wrote: > > On Tue, Mar 2, 2010 at 8:46 AM, Richard Reina wrote: > > $line is exactly what I want but it's in the form of a scalar; ?When I try to split it up into elements of an array with @fax=split("", $line); it does not work due to all the back to back white spaces. ?If anyone can help me out with a better way to do this I would really appreciate it. > > > > I've never used faxstat before, but i would think that you might want to try: > > @fax = split(/\s+/, $line) ; > > Which will split on whitespace and give you the relevant > whitespace-separated fields. If that isn't what you're looking for, > could you post an example of the data you're looking at and the > desired outcome? > > > Adios, > > -- > Paul Mantz > http://www.mcpantz.org > Zmanda - Open source backup and recovery http://www.zmanda.com/ > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From richard at rushlogistics.com Tue Mar 2 10:42:30 2010 From: richard at rushlogistics.com (Richard Reina) Date: Tue, 02 Mar 2010 13:42:30 -0500 (EST) Subject: [Chicago-talk] messy scalar into an array. In-Reply-To: <20100302144647.800FB38E5@courageux.xo.com> Message-ID: <20100302184230.C35A46D@victory.xo.com> Actually, I believe all the suggestion would work > until I realized that every now in then there is a > column that is completely blank and then it throw > > > > > -rw---- 1? 14????????????????????????????? 15:01 > fax00002470.tif > > That occasional empty column messes it up.? Is there > a way to accommodate for that? > > Sorry, for the added wrinkle.? I had not noticed > that before. > > Richard > > Chicago.pm chatter wrote: > I have no idea what your faxstat -r output looks like, > but why no collapse all of the white space down to > > ? > $line =~ s/\s+/ /g; > ? > then you can split on the single space. > ? > ? DB<3> $line = 'a b? c?? d???? e?????? f'; > ? DB<4> $a=$line > ? DB<5> $a =~ s/\s+/ /g; > ? DB<6> p $a > ?a? b? c? d? e? f > ? DB<7> @a=split(" ", $a); > > ? DB<8> x @a > 0? 'a' > 1? 'b' > 2? 'c' > 3? 'd' > 4? 'e' > 5? 'f' > ? > ? > ydy > > On Tue, Mar 2, 2010 at 8:46 AM, Richard Reina wrote: > I'm sorry for asking what likely should be a simple > question but after spending a fair amount of time > playing with qw(), split(), join(), etc. I still have > not figured it out. > > I have some fairly messy system output which I have > managed to isolate into a scalar with > > use strict; > my @received = `faxstat -r`; > > I can't figure out how to neatly get this into an > > > I've gotten this far; > > my $line; > my @fax; > > foreach $line (@received) { > > ? ?if (substr($line,0,5) eq "-rw---") { # make sure > it's an actual fax > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # and not > the title of the output > ? ? ? ?chomp($line); > ? ?} > } > > $line is exactly what I want but it's in the form > of a scalar; ?When I try to split it up into elements > of an array with @fax=split("", $line); it does not > work due to all the back to back white spaces. ?If > anyone can help me out with a better way to do this > I would really appreciate it. > > Thanks, > > Richard > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > > > -- > I take the "Shhhh" out of IT - ydy -------------- next part -------------- An HTML attachment was scrubbed... URL: From shawn.c.carroll at gmail.com Tue Mar 2 10:49:38 2010 From: shawn.c.carroll at gmail.com (Shawn Carroll) Date: Tue, 2 Mar 2010 12:49:38 -0600 Subject: [Chicago-talk] messy scalar into an array. In-Reply-To: <20100302184230.C35A46D@victory.xo.com> References: <20100302144647.800FB38E5@courageux.xo.com> <20100302184230.C35A46D@victory.xo.com> Message-ID: The output appears to be formated. you may want to look at unpack. my @this = unpack ('a7a1a3......', $string); shawn.c.carroll at gmail.com Perl Programmer Soccer Referee On Tue, Mar 2, 2010 at 12:42, Richard Reina wrote: > Actually, I believe all the suggestion would work until I realized that > every now in then there is a column that is completely blank and then it > throw everything off. Here is an example of the output: > > -rw---- 2? 14? 14:53 fax00003459.tif > -rw---- 1? 14? 501 443 9393???????? 14:58 fax00003460.tif > -rw---- 1? 14????????????????????????????? 15:01 fax00002470.tif > > That occasional empty column messes it up.? Is there a way to accommodate > for that? > > Sorry, for the added wrinkle.? I had not noticed that before. > > Richard > > Chicago.pm chatter wrote: > > I have no idea what your faxstat -r output looks like, but why no collapse > all of the white space down to single spaces, then you can split on the > singles space: > > $line =~ s/\s+/ /g; > > then you can split on the single space. > > ? DB<3> $line = 'a b? c?? d???? e?????? f'; > ? DB<4> $a=$line > ? DB<5> $a =~ s/\s+/ /g; > ? DB<6> p $a > ?a? b? c? d? e? f > ? DB<7> @a=split(" ", $a); > ? DB<8> x @a > 0? 'a' > 1? 'b' > 2? 'c' > 3? 'd' > 4? 'e' > 5? 'f' > > > ydy > > On Tue, Mar 2, 2010 at 8:46 AM, Richard Reina > wrote: >> >> I'm sorry for asking what likely should be a simple question but after >> spending a fair amount of time playing with qw(), split(), join(), etc. I >> still have not figured it out. >> >> I have some fairly messy system output which I have managed to isolate >> into a scalar with >> >> use strict; >> my @received = `faxstat -r`; >> >> I can't figure out how to neatly get this into an array so I can get the >> output into a database table; >> >> I've gotten this far; >> >> my $line; >> my @fax; >> >> foreach $line (@received) { >> >> ? ?if (substr($line,0,5) eq "-rw---") { # make sure it's an actual fax >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # and not the title of the output >> ? ? ? ?chomp($line); >> ? ?} >> } >> >> $line is exactly what I want but it's in the form of a scalar; ?When I try >> to split it up into elements of an array with @fax=split("", $line); it does >> not work due to all the back to back white spaces. ?If anyone can help me >> out with a better way to do this I would really appreciate it. >> >> Thanks, >> >> Richard >> _______________________________________________ >> Chicago-talk mailing list >> Chicago-talk at pm.org >> http://mail.pm.org/mailman/listinfo/chicago-talk > > > > -- > I take the "Shhhh" out of IT - ydy > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From briank at kappacs.com Tue Mar 2 12:28:53 2010 From: briank at kappacs.com (Brian Katzung) Date: Tue, 02 Mar 2010 14:28:53 -0600 Subject: [Chicago-talk] messy scalar into an array. In-Reply-To: <20100302184230.C35A46D@victory.xo.com> References: <20100302184230.C35A46D@victory.xo.com> Message-ID: <4B8D7505.6000202@kappacs.com> As an alternative to fixed fields, how about: use strict; my @received = `faxstat -r`; my $line; my ($mode, $ident, $time, $file); foreach $line (@received) { if (($mode, undef, undef, $ident, $time, $file) = ($line =~ /^(\S+)\s+(\d+)\s+(\d+)\s+(\S.*\S)?\s+(..:..)\s+(.*\.tif)$/) { # do whatever } } This should also deal with skipping irrelevant (fax title?) lines. - Brian Richard Reina wrote: > Actually, I believe all the suggestion would work until I realized > that every now in then there is a column that is completely blank and > then it throw everything off. Here is an example of the output: > > -rw---- 2 14 14:53 fax00003459.tif > -rw---- 1 14 501 443 9393 14:58 fax00003460.tif > -rw---- 1 14 15:01 fax00002470.tif > > That occasional empty column messes it up. Is there a way to > accommodate for that? > > Sorry, for the added wrinkle. I had not noticed that before. > > Richard > * > * > > > On Tue, Mar 2, 2010 at 8:46 AM, Richard Reina > > wrote: > > I'm sorry for asking what likely should be a simple question > but after spending a fair amount of time playing with qw(), > split(), join(), etc. I still have not figured it out. > > I have some fairly messy system output which I have managed to > isolate into a scalar with > > use strict; > my @received = `faxstat -r`; > > I can't figure out how to neatly get this into an array so I > can get the output into a database table; > > I've gotten this far; > > my $line; > my @fax; > > foreach $line (@received) { > > if (substr($line,0,5) eq "-rw---") { # make sure it's an > actual fax > # and not the title of > the output > chomp($line); > } > } > > $line is exactly what I want but it's in the form of a scalar; > When I try to split it up into elements of an array with > @fax=split("", $line); it does not work due to all the back to > back white spaces. If anyone can help me out with a better > way to do this I would really appreciate it. > > Thanks, > > Richard > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > > -- Brian Katzung, Kappa Computer Solutions, LLC Leveraging UNIX, GNU/Linux, open source, and custom software solutions for business and beyond Phone: 877.367.8837 x1 http://www.kappacs.com From warren.lindsey at gmail.com Tue Mar 2 12:38:38 2010 From: warren.lindsey at gmail.com (Warren Lindsey) Date: Tue, 2 Mar 2010 14:38:38 -0600 Subject: [Chicago-talk] messy scalar into an array. In-Reply-To: <20100302184230.C35A46D@victory.xo.com> References: <20100302144647.800FB38E5@courageux.xo.com> <20100302184230.C35A46D@victory.xo.com> Message-ID: <841e880a1003021238l5bc3445en8f922e2c201f4bd9@mail.gmail.com> Which columns do you want? You could just work backwards from the end of the array. That would always return the fax filename, foloowed by time, then what I suspect is callerid? On Tue, Mar 2, 2010 at 12:42 PM, Richard Reina wrote: > Actually, I believe all the suggestion would work until I realized that > every now in then there is a column that is completely blank and then it > throw everything off. Here is an example of the output: > > -rw---- 2? 14? 14:53 fax00003459.tif > -rw---- 1? 14? 501 443 9393???????? 14:58 fax00003460.tif > -rw---- 1? 14????????????????????????????? 15:01 fax00002470.tif > > That occasional empty column messes it up.? Is there a way to accommodate > for that? > > Sorry, for the added wrinkle.? I had not noticed that before. > > Richard > > Chicago.pm chatter wrote: > > I have no idea what your faxstat -r output looks like, but why no collapse > all of the white space down to single spaces, then you can split on the > singles space: > > $line =~ s/\s+/ /g; > > then you can split on the single space. > > ? DB<3> $line = 'a b? c?? d???? e?????? f'; > ? DB<4> $a=$line > ? DB<5> $a =~ s/\s+/ /g; > ? DB<6> p $a > ?a? b? c? d? e? f > ? DB<7> @a=split(" ", $a); > ? DB<8> x @a > 0? 'a' > 1? 'b' > 2? 'c' > 3? 'd' > 4? 'e' > 5? 'f' > > > ydy > > On Tue, Mar 2, 2010 at 8:46 AM, Richard Reina > wrote: >> >> I'm sorry for asking what likely should be a simple question but after >> spending a fair amount of time playing with qw(), split(), join(), etc. I >> still have not figured it out. >> >> I have some fairly messy system output which I have managed to isolate >> into a scalar with >> >> use strict; >> my @received = `faxstat -r`; >> >> I can't figure out how to neatly get this into an array so I can get the >> output into a database table; >> >> I've gotten this far; >> >> my $line; >> my @fax; >> >> foreach $line (@received) { >> >> ? ?if (substr($line,0,5) eq "-rw---") { # make sure it's an actual fax >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # and not the title of the output >> ? ? ? ?chomp($line); >> ? ?} >> } >> >> $line is exactly what I want but it's in the form of a scalar; ?When I try >> to split it up into elements of an array with @fax=split("", $line); it does >> not work due to all the back to back white spaces. ?If anyone can help me >> out with a better way to do this I would really appreciate it. >> >> Thanks, >> >> Richard >> _______________________________________________ >> Chicago-talk mailing list >> Chicago-talk at pm.org >> http://mail.pm.org/mailman/listinfo/chicago-talk > > > > -- > I take the "Shhhh" out of IT - ydy > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From richard at rushlogistics.com Tue Mar 2 14:14:09 2010 From: richard at rushlogistics.com (Richard Reina) Date: Tue, 02 Mar 2010 17:14:09 -0500 (EST) Subject: [Chicago-talk] messy scalar into an array. In-Reply-To: <20100302184230.C35A46D@victory.xo.com> Message-ID: <20100302221410.18208603@swiftsure.xo.com> Hi Brian, I really appreciate the reply. It looks promising, but it does not seem to trap any data. If I put a print $mode . " " . $ident . " " . $file . "\n"; after the matching statement nothing matches. ---- Chicago.pm chatter wrote: > > As an alternative to fixed fields, how about: > > use strict; > my @received = `faxstat -r`; > my $line; > my ($mode, $ident, $time, $file); > > foreach $line (@received) { > if (($mode, undef, undef, $ident, $time, $file) = > ($line =~ > /^(\S+)\s+(\d+)\s+(\d+)\s+(\S.*\S)?\s+(..:..)\s+(.*\.tif)$/) { > # do whatever > } > } > > This should also deal with skipping irrelevant (fax title?) lines. > > - Brian > > Richard Reina wrote: > > Actually, I believe all the suggestion would work until I realized > > that every now in then there is a column that is completely blank and > > then it throw everything off. Here is an example of the output: > > > > -rw---- 2 14 14:53 fax00003459.tif > > -rw---- 1 14 501 443 9393 14:58 fax00003460.tif > > -rw---- 1 14 15:01 fax00002470.tif > > > > That occasional empty column messes it up. Is there a way to > > accommodate for that? > > > > Sorry, for the added wrinkle. I had not noticed that before. > > > > Richard > > * > > * > > > > > > On Tue, Mar 2, 2010 at 8:46 AM, Richard Reina > > > wrote: > > > > I'm sorry for asking what likely should be a simple question > > but after spending a fair amount of time playing with qw(), > > split(), join(), etc. I still have not figured it out. > > > > I have some fairly messy system output which I have managed to > > isolate into a scalar with > > > > use strict; > > my @received = `faxstat -r`; > > > > I can't figure out how to neatly get this into an array so I > > can get the output into a database table; > > > > I've gotten this far; > > > > my $line; > > my @fax; > > > > foreach $line (@received) { > > > > if (substr($line,0,5) eq "-rw---") { # make sure it's an > > actual fax > > # and not the title of > > the output > > chomp($line); > > } > > } > > > > $line is exactly what I want but it's in the form of a scalar; > > When I try to split it up into elements of an array with > > @fax=split("", $line); it does not work due to all the back to > > back white spaces. If anyone can help me out with a better > > way to do this I would really appreciate it. > > > > Thanks, > > > > Richard > > _______________________________________________ > > Chicago-talk mailing list > > Chicago-talk at pm.org > > http://mail.pm.org/mailman/listinfo/chicago-talk > > > > > > -- > Brian Katzung, Kappa Computer Solutions, LLC > Leveraging UNIX, GNU/Linux, open source, and custom > software solutions for business and beyond > Phone: 877.367.8837 x1 http://www.kappacs.com > > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From clydeforrester at gmail.com Tue Mar 2 15:50:53 2010 From: clydeforrester at gmail.com (Clyde Forrester) Date: Tue, 02 Mar 2010 17:50:53 -0600 Subject: [Chicago-talk] messy scalar into an array. In-Reply-To: <20100302221410.18208603@swiftsure.xo.com> References: <20100302221410.18208603@swiftsure.xo.com> Message-ID: <4B8DA45D.2000800@gmail.com> If your data is in fixed columns, you might just take the appropriate substrings and be done with it. Sometimes regular expressions aren't the most effective or easy to maintain solution. Clyde Forrester Richard Reina wrote: > Hi Brian, > > I really appreciate the reply. It looks promising, but it does not seem to trap any data. If I put a print $mode . " " . $ident . " " . $file . "\n"; > after the matching statement nothing matches. > > > ---- Chicago.pm chatter wrote: >> As an alternative to fixed fields, how about: >> >> use strict; >> my @received = `faxstat -r`; >> my $line; >> my ($mode, $ident, $time, $file); >> >> foreach $line (@received) { >> if (($mode, undef, undef, $ident, $time, $file) = >> ($line =~ >> /^(\S+)\s+(\d+)\s+(\d+)\s+(\S.*\S)?\s+(..:..)\s+(.*\.tif)$/) { >> # do whatever >> } >> } >> >> This should also deal with skipping irrelevant (fax title?) lines. >> >> - Brian >> >> Richard Reina wrote: >>> Actually, I believe all the suggestion would work until I realized >>> that every now in then there is a column that is completely blank and >>> then it throw everything off. Here is an example of the output: >>> >>> -rw---- 2 14 14:53 fax00003459.tif >>> -rw---- 1 14 501 443 9393 14:58 fax00003460.tif >>> -rw---- 1 14 15:01 fax00002470.tif >>> >>> That occasional empty column messes it up. Is there a way to >>> accommodate for that? >>> >>> Sorry, for the added wrinkle. I had not noticed that before. >>> >>> Richard >>> * >>> * >>> >>> >>> On Tue, Mar 2, 2010 at 8:46 AM, Richard Reina >>> > wrote: >>> >>> I'm sorry for asking what likely should be a simple question >>> but after spending a fair amount of time playing with qw(), >>> split(), join(), etc. I still have not figured it out. >>> >>> I have some fairly messy system output which I have managed to >>> isolate into a scalar with >>> >>> use strict; >>> my @received = `faxstat -r`; >>> >>> I can't figure out how to neatly get this into an array so I >>> can get the output into a database table; >>> >>> I've gotten this far; >>> >>> my $line; >>> my @fax; >>> >>> foreach $line (@received) { >>> >>> if (substr($line,0,5) eq "-rw---") { # make sure it's an >>> actual fax >>> # and not the title of >>> the output >>> chomp($line); >>> } >>> } >>> >>> $line is exactly what I want but it's in the form of a scalar; >>> When I try to split it up into elements of an array with >>> @fax=split("", $line); it does not work due to all the back to >>> back white spaces. If anyone can help me out with a better >>> way to do this I would really appreciate it. >>> >>> Thanks, >>> >>> Richard From briank at kappacs.com Tue Mar 2 15:34:23 2010 From: briank at kappacs.com (Brian Katzung) Date: Tue, 02 Mar 2010 17:34:23 -0600 Subject: [Chicago-talk] messy scalar into an array. In-Reply-To: <20100302221410.18208603@swiftsure.xo.com> References: <20100302221410.18208603@swiftsure.xo.com> Message-ID: Without the actual data in hand, I'm guessing there's extra white space at the beginning or end of line not being matched. You might try the regex unanchored and see if it makes a difference. - Brian "Richard Reina" wrote: >Hi Brian, > >I really appreciate the reply. It looks promising, but it does not seem to trap any data. If I put a print $mode . " " . $ident . " " . $file . "\n"; >after the matching statement nothing matches. > > >---- Chicago.pm chatter wrote: >> >> As an alternative to fixed fields, how about: >> >> use strict; >> my @received = `faxstat -r`; >> my $line; >> my ($mode, $ident, $time, $file); >> >> foreach $line (@received) { >> if (($mode, undef, undef, $ident, $time, $file) = >> ($line =~ >> /^(\S+)\s+(\d+)\s+(\d+)\s+(\S.*\S)?\s+(..:..)\s+(.*\.tif)$/) { >> # do whatever >> } >> } >> >> This should also deal with skipping irrelevant (fax title?) lines. >> >> - Brian >> >> Richard Reina wrote: >> > Actually, I believe all the suggestion would work until I realized >> > that every now in then there is a column that is completely blank and >> > then it throw everything off. Here is an example of the output: >> > >> > -rw---- 2 14 14:53 fax00003459.tif >> > -rw---- 1 14 501 443 9393 14:58 fax00003460.tif >> > -rw---- 1 14 15:01 fax00002470.tif >> > >> > That occasional empty column messes it up. Is there a way to >> > accommodate for that? >> > >> > Sorry, for the added wrinkle. I had not noticed that before. >> > >> > Richard >> > * >> > * >> > >> > >> > On Tue, Mar 2, 2010 at 8:46 AM, Richard Reina >> > > wrote: >> > >> > I'm sorry for asking what likely should be a simple question >> > but after spending a fair amount of time playing with qw(), >> > split(), join(), etc. I still have not figured it out. >> > >> > I have some fairly messy system output which I have managed to >> > isolate into a scalar with >> > >> > use strict; >> > my @received = `faxstat -r`; >> > >> > I can't figure out how to neatly get this into an array so I >> > can get the output into a database table; >> > >> > I've gotten this far; >> > >> > my $line; >> > my @fax; >> > >> > foreach $line (@received) { >> > >> > if (substr($line,0,5) eq "-rw---") { # make sure it's an >> > actual fax >> > # and not the title of >> > the output >> > chomp($line); >> > } >> > } >> > >> > $line is exactly what I want but it's in the form of a scalar; >> > When I try to split it up into elements of an array with >> > @fax=split("", $line); it does not work due to all the back to >> > back white spaces. If anyone can help me out with a better >> > way to do this I would really appreciate it. >> > >> > Thanks, >> > >> > Richard >> > _______________________________________________ >> > Chicago-talk mailing list >> > Chicago-talk at pm.org >> > http://mail.pm.org/mailman/listinfo/chicago-talk >> > >> > >> >> -- >> Brian Katzung, Kappa Computer Solutions, LLC >> Leveraging UNIX, GNU/Linux, open source, and custom >> software solutions for business and beyond >> Phone: 877.367.8837 x1 http://www.kappacs.com >> >> >> _______________________________________________ >> Chicago-talk mailing list >> Chicago-talk at pm.org >> http://mail.pm.org/mailman/listinfo/chicago-talk >> >_______________________________________________ >Chicago-talk mailing list >Chicago-talk at pm.org >http://mail.pm.org/mailman/listinfo/chicago-talk > > -- Brian Katzung, Kappa Computer Solutions, LLC Leveraging UNIX, GNU/Linux, open source, and custom software solutions for business and beyond Phone: 877.367.8837 x1 http://www.kappacs.com Sent from my phone. Please excuse my brevity. From danel at speakeasy.net Tue Mar 2 20:45:26 2010 From: danel at speakeasy.net (Alexander Danel) Date: Tue, 2 Mar 2010 22:45:26 -0600 Subject: [Chicago-talk] messy scalar into an array. In-Reply-To: Message-ID: <042001caba8c$588ffe60$0800a8c0@dsmsik7n2d2> It looks to me like "unpack" is the correct solution. Are there characters in this output? That would change things. -----Original Message----- From: chicago-talk-bounces+danel=speakeasy.net at pm.org [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of Shawn Carroll Sent: Tuesday, March 02, 2010 12:50 PM To: Chicago.pm chatter Subject: Re: [Chicago-talk] messy scalar into an array. The output appears to be formated. you may want to look at unpack. my @this = unpack ('a7a1a3......', $string); shawn.c.carroll at gmail.com Perl Programmer Soccer Referee On Tue, Mar 2, 2010 at 12:42, Richard Reina wrote: > Actually, I believe all the suggestion would work until I realized that > every now in then there is a column that is completely blank and then it > throw everything off. Here is an example of the output: > > -rw---- 2? 14? 14:53 fax00003459.tif > -rw---- 1? 14? 501 443 9393???????? 14:58 fax00003460.tif > -rw---- 1? 14????????????????????????????? 15:01 fax00002470.tif > > That occasional empty column messes it up.? Is there a way to accommodate > for that? > > Sorry, for the added wrinkle.? I had not noticed that before. > > Richard > > Chicago.pm chatter wrote: > > I have no idea what your faxstat -r output looks like, but why no collapse > all of the white space down to single spaces, then you can split on the > singles space: > > $line =~ s/\s+/ /g; > > then you can split on the single space. > > ? DB<3> $line = 'a b? c?? d???? e?????? f'; > ? DB<4> $a=$line > ? DB<5> $a =~ s/\s+/ /g; > ? DB<6> p $a > ?a? b? c? d? e? f > ? DB<7> @a=split(" ", $a); > ? DB<8> x @a > 0? 'a' > 1? 'b' > 2? 'c' > 3? 'd' > 4? 'e' > 5? 'f' > > > ydy > > On Tue, Mar 2, 2010 at 8:46 AM, Richard Reina > wrote: >> >> I'm sorry for asking what likely should be a simple question but after >> spending a fair amount of time playing with qw(), split(), join(), etc. I >> still have not figured it out. >> >> I have some fairly messy system output which I have managed to isolate >> into a scalar with >> >> use strict; >> my @received = `faxstat -r`; >> >> I can't figure out how to neatly get this into an array so I can get the >> output into a database table; >> >> I've gotten this far; >> >> my $line; >> my @fax; >> >> foreach $line (@received) { >> >> ? ?if (substr($line,0,5) eq "-rw---") { # make sure it's an actual fax >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # and not the title of the output >> ? ? ? ?chomp($line); >> ? ?} >> } >> >> $line is exactly what I want but it's in the form of a scalar; ?When I try >> to split it up into elements of an array with @fax=split("", $line); it does >> not work due to all the back to back white spaces. ?If anyone can help me >> out with a better way to do this I would really appreciate it. >> >> Thanks, >> >> Richard >> _______________________________________________ >> Chicago-talk mailing list >> Chicago-talk at pm.org >> http://mail.pm.org/mailman/listinfo/chicago-talk > > > > -- > I take the "Shhhh" out of IT - ydy > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > _______________________________________________ Chicago-talk mailing list Chicago-talk at pm.org http://mail.pm.org/mailman/listinfo/chicago-talk From richard at rushlogistics.com Wed Mar 3 07:37:40 2010 From: richard at rushlogistics.com (Richard Reina) Date: Wed, 03 Mar 2010 10:37:40 -0500 (EST) Subject: [Chicago-talk] messy scalar into an array. In-Reply-To: <042001caba8c$588ffe60$0800a8c0@dsmsik7n2d2> Message-ID: <20100303153740.430572505@alexander.xo.com> I really appreciate everyone's response. One of the beauties of perl -- aside from the outstanding user community -- is that there's more than one way to do things. For now I'm going with substring, but I will keep an eye on how it's working and likely refer back to some of the other suggestions to make changes. Thanks again, for all the ideas. Richard ---- Alexander Danel wrote: > > It looks to me like "unpack" is the correct solution. > > Are there characters in this output? That would change things. > > -----Original Message----- > From: chicago-talk-bounces+danel=speakeasy.net at pm.org > [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of Shawn > Carroll > Sent: Tuesday, March 02, 2010 12:50 PM > To: Chicago.pm chatter > Subject: Re: [Chicago-talk] messy scalar into an array. > > The output appears to be formated. you may want to look at unpack. > > my @this = unpack ('a7a1a3......', $string); > > > shawn.c.carroll at gmail.com > Perl Programmer > Soccer Referee > > > > On Tue, Mar 2, 2010 at 12:42, Richard Reina > wrote: > > Actually, I believe all the suggestion would work until I realized that > > every now in then there is a column that is completely blank and then it > > throw everything off. Here is an example of the output: > > > > -rw---- 2? 14? 14:53 fax00003459.tif > > -rw---- 1? 14? 501 443 9393???????? 14:58 fax00003460.tif > > -rw---- 1? 14????????????????????????????? 15:01 fax00002470.tif > > > > That occasional empty column messes it up.? Is there a way to accommodate > > for that? > > > > Sorry, for the added wrinkle.? I had not noticed that before. > > > > Richard > > > > Chicago.pm chatter wrote: > > > > I have no idea what your faxstat -r output looks like, but why no collapse > > all of the white space down to single spaces, then you can split on the > > singles space: > > > > $line =~ s/\s+/ /g; > > > > then you can split on the single space. > > > > ? DB<3> $line = 'a b? c?? d???? e?????? f'; > > ? DB<4> $a=$line > > ? DB<5> $a =~ s/\s+/ /g; > > ? DB<6> p $a > > ?a? b? c? d? e? f > > ? DB<7> @a=split(" ", $a); > > ? DB<8> x @a > > 0? 'a' > > 1? 'b' > > 2? 'c' > > 3? 'd' > > 4? 'e' > > 5? 'f' > > > > > > ydy > > > > On Tue, Mar 2, 2010 at 8:46 AM, Richard Reina > > wrote: > >> > >> I'm sorry for asking what likely should be a simple question but after > >> spending a fair amount of time playing with qw(), split(), join(), etc. I > >> still have not figured it out. > >> > >> I have some fairly messy system output which I have managed to isolate > >> into a scalar with > >> > >> use strict; > >> my @received = `faxstat -r`; > >> > >> I can't figure out how to neatly get this into an array so I can get the > >> output into a database table; > >> > >> I've gotten this far; > >> > >> my $line; > >> my @fax; > >> > >> foreach $line (@received) { > >> > >> ? ?if (substr($line,0,5) eq "-rw---") { # make sure it's an actual fax > >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # and not the title of the output > >> ? ? ? ?chomp($line); > >> ? ?} > >> } > >> > >> $line is exactly what I want but it's in the form of a scalar; ?When I > try > >> to split it up into elements of an array with @fax=split("", $line); it > does > >> not work due to all the back to back white spaces. ?If anyone can help me > >> out with a better way to do this I would really appreciate it. > >> > >> Thanks, > >> > >> Richard > >> _______________________________________________ > >> Chicago-talk mailing list > >> Chicago-talk at pm.org > >> http://mail.pm.org/mailman/listinfo/chicago-talk > > > > > > > > -- > > I take the "Shhhh" out of IT - ydy > > > > _______________________________________________ > > Chicago-talk mailing list > > Chicago-talk at pm.org > > http://mail.pm.org/mailman/listinfo/chicago-talk > > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From inzoik at yahoo.com Wed Mar 3 18:20:26 2010 From: inzoik at yahoo.com (Mithun Bhattacharya) Date: Wed, 3 Mar 2010 18:20:26 -0800 (PST) Subject: [Chicago-talk] Global variable behavior Message-ID: <926088.80852.qm@web53407.mail.re2.yahoo.com> Hi Everyone, A piece of my code is behaving in a way I didn't expect and I was hoping someone could enlighten me as to why.. ------------------------------------- $ cat a.pl push @INC, '.'; our $c = 15; require newbie; ------------------------------------- $ cat newbie.pm package newbie; print "first attempt: " . $c . "\n"; print "second attempt: " . $::c . "\n"; 1; ------------------------------------- $ perl a.pl first attempt: second attempt: 15 ------------------------------------- The way I see it the our in a.pl should make it global across all namespaces. The second attempt does seem to say that did take place. What I am not sure is why the $c variable has become local in scope even though I haven't re-declared or redefined it in any way inside newbie.pm. - Mithun -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrew at cleverdomain.org Wed Mar 3 18:54:18 2010 From: andrew at cleverdomain.org (Andrew Rodland) Date: Wed, 3 Mar 2010 20:54:18 -0600 Subject: [Chicago-talk] Global variable behavior In-Reply-To: <926088.80852.qm@web53407.mail.re2.yahoo.com> References: <926088.80852.qm@web53407.mail.re2.yahoo.com> Message-ID: <201003032054.19097.andrew@cleverdomain.org> On Wednesday 03 March 2010 08:20:26 pm Mithun Bhattacharya wrote: > Hi Everyone, > > A piece of my code is behaving in a way I didn't expect and I was hoping > someone could enlighten me as to why.. > > ------------------------------------- > $ cat a.pl > push @INC, '.'; > > our $c = 15; > > require newbie; > ------------------------------------- > $ cat newbie.pm > package newbie; > > print "first attempt: " . $c . "\n"; > print "second attempt: " . $::c . "\n"; > > 1; > ------------------------------------- > $ perl a.pl > first attempt: > second attempt: 15 > ------------------------------------- > > The way I see it the our in a.pl should make it global across all > namespaces. The second attempt does seem to say that did take place. What > I am not sure is why the $c variable has become local in scope even though > I haven't re-declared or redefined it in any way inside newbie.pm. Because it's not declared in any way in newbie.pm. What "our $foo" does is *lexically* create a binding between the name $foo and the variable $foo in the current package. It doesn't make package variables any "more global" than they already are, and (silly tricks involving multiple packages in a file excluded) it doesn't let you refer to a variable in a different package without naming that package. If you want $::c, write $::c. And use strict so that your first example throws a compile-time error instead of silently breaking. :) Andrew From danel at speakeasy.net Wed Mar 3 19:00:08 2010 From: danel at speakeasy.net (Alexander Danel) Date: Wed, 3 Mar 2010 21:00:08 -0600 Subject: [Chicago-talk] Global variable behavior In-Reply-To: <926088.80852.qm@web53407.mail.re2.yahoo.com> Message-ID: <04f901cabb46$cce49e00$0800a8c0@dsmsik7n2d2> Get in the habit of putting the following at the top of every file: use strict; Try it. It will inform you that you are implicitly doing just what you claim you are not doing: you have declared (or, as you put it "redeclared") the variable. "Use strict" will protest because implicit declarations are often an accident; which is clearly appropriate for your case. By the way, I take exception to your statement ". . . should make it global across all name spaces." No such concept exists in Perl. You declared the variable to be in the "main" namespace; which you seemingly understood when you used "$::c", the naked double-colon being an alias for "main::". The package "main" is in force until you declare otherwise. Alexander Danel _____ From: chicago-talk-bounces+danel=speakeasy.net at pm.org [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of Mithun Bhattacharya Sent: Wednesday, March 03, 2010 8:20 PM To: chicago-talk at pm.org Subject: [Chicago-talk] Global variable behavior Hi Everyone, A piece of my code is behaving in a way I didn't expect and I was hoping someone could enlighten me as to why.. ------------------------------------- $ cat a.pl push @INC, '.'; our $c = 15; require newbie; ------------------------------------- $ cat newbie.pm package newbie; print "first attempt: " . $c . "\n"; print "second attempt: " . $::c . "\n"; 1; ------------------------------------- $ perl a.pl first attempt: second attempt: 15 ------------------------------------- The way I see it the our in a.pl should make it global across all namespaces. The second attempt does seem to say that did take place. What I am not sure is why the $c variable has become local in scope even though I haven't re-declared or redefined it in any way inside newbie.pm. - Mithun -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at petdance.com Thu Mar 4 17:45:18 2010 From: andy at petdance.com (Andy Lester) Date: Thu, 4 Mar 2010 19:45:18 -0600 Subject: [Chicago-talk] ack in the Chicago Sun-Times Message-ID: Andy Ihnatko mentions my Perl program ack in his latest column for the Sun-Times. http://www.suntimes.com/technology/ihnatko/2083771,ihnatko-apple-ipad-anaysis-030410.article Next it'll be the cover of the Rolling Stone. xoxo, Andy -- Andy Lester => andy at petdance.com => www.theworkinggeek.com => AIM:petdance From zrusilla at mac.com Thu Mar 4 18:27:57 2010 From: zrusilla at mac.com (Elizabeth Cortell) Date: Thu, 04 Mar 2010 18:27:57 -0800 Subject: [Chicago-talk] ack in the Chicago Sun-Times In-Reply-To: References: Message-ID: Can the paparazzi be far behind? On Mar 4, 2010, at 5:45 PM, Andy Lester wrote: > > Next it'll be the cover of the Rolling Stone. > From richard at rushlogistics.com Fri Mar 5 04:52:39 2010 From: richard at rushlogistics.com (Richard Reina) Date: Fri, 05 Mar 2010 07:52:39 -0500 (EST) Subject: [Chicago-talk] No Subject Message-ID: <20100305125239.E7D0B3E73@courageux.xo.com> From richard at rushlogistics.com Fri Mar 5 05:08:50 2010 From: richard at rushlogistics.com (Richard Reina) Date: Fri, 05 Mar 2010 08:08:50 -0500 (EST) Subject: [Chicago-talk] =?utf-8?q?launching_a_terminal=3F?= Message-ID: <20100305130850.300DB3F82@theseus.xo.com> I trying to figure out a way that a for a for a program to launch a terminal with system("gnome-terminal") and have that terminal intern launch another program as soon as it's launched. I've tried perl -e 'system(gnome-terminal; perl print_list.pl");' but the program is not running when the terminal opens. Any help would be very much appreciated. Thanks, Richard From MikeRaffety at earthlink.net Fri Mar 5 05:16:20 2010 From: MikeRaffety at earthlink.net (Mike Raffety) Date: Fri, 05 Mar 2010 07:16:20 -0600 Subject: [Chicago-talk] launching a terminal? In-Reply-To: <20100305130850.300DB3F82@theseus.xo.com> References: <20100305130850.300DB3F82@theseus.xo.com> Message-ID: <4B910424.7020507@earthlink.net> Try this instead: system("gnome-terminal -x 'perl print_list.pl'") http://www.fifi.org/doc/gnome-terminal/html/gnome-terminal/C/options.html Richard Reina wrote, On 3/5/2010 7:08 AM: > I trying to figure out a way that a for a for a program to launch a terminal with system("gnome-terminal") and have that terminal intern launch another program as soon as it's launched. I've tried perl -e 'system(gnome-terminal; perl print_list.pl");' but the program is not running when the terminal opens. > > Any help would be very much appreciated. > > Thanks, > > Richard > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > > From richard at rushlogistics.com Fri Mar 5 05:28:05 2010 From: richard at rushlogistics.com (Richard Reina) Date: Fri, 05 Mar 2010 08:28:05 -0500 (EST) Subject: [Chicago-talk] =?utf-8?q?launching_a_terminal=3F?= In-Reply-To: <20100305130850.300DB3F82@theseus.xo.com> Message-ID: <20100305132805.8BEB327A7@alexander.xo.com> Perfect. Thank you very much the help. ---- Chicago.pm chatter wrote: > > Try this instead: > > system("gnome-terminal -x 'perl print_list.pl'") > > http://www.fifi.org/doc/gnome-terminal/html/gnome-terminal/C/options.html > > Richard Reina wrote, On 3/5/2010 7:08 AM: > > I trying to figure out a way that a for a for a program to launch a terminal with system("gnome-terminal") and have that terminal intern launch another program as soon as it's launched. I've tried perl -e 'system(gnome-terminal; perl print_list.pl");' but the program is not running when the terminal opens. > > > > Any help would be very much appreciated. > > > > Thanks, > > > > Richard > > _______________________________________________ > > Chicago-talk mailing list > > Chicago-talk at pm.org > > http://mail.pm.org/mailman/listinfo/chicago-talk > > > > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From inzoik at yahoo.com Fri Mar 5 20:33:06 2010 From: inzoik at yahoo.com (Mithun Bhattacharya) Date: Fri, 5 Mar 2010 20:33:06 -0800 (PST) Subject: [Chicago-talk] Global variable behavior In-Reply-To: <04f901cabb46$cce49e00$0800a8c0@dsmsik7n2d2> References: <04f901cabb46$cce49e00$0800a8c0@dsmsik7n2d2> Message-ID: <174556.70800.qm@web53404.mail.re2.yahoo.com> Thanks for the input. I guess I took somethings for granted and didn't read up the relevant sections carefully :) I am not nitpicking here but I would like to share a few more things which became more obvious to me - hopefully it will help others too. New code follows ====================================================================== $ cat a.pl use strict; push @INC, '.'; our $c = 15; require newbie; ====================================================================== $ cat newbie.pm package newbie; print "first attempt: " . $c . "\n"; print "second attempt: " . $::c . "\n"; 1; ====================================================================== $ perl a.pl first attempt: second attempt: 15 ====================================================================== $ perl -w a.pl Use of uninitialized value $newbie::c in concatenation (.) or string at newbie.pm line 3. first attempt: second attempt: 15 ====================================================================== $ perl -v This is perl, v5.10.0 built for x86_64-linux-thread-multi ====================================================================== I am just demonstrating that it is use warnings which would help more in this scenario rather than use strict. Something else which confused me after I started understanding our better was the following - maybe someone can point out if I have miss-understood anything. As per perldoc for our "our" associates a simple name with a package variable in the current package for use within the current scope. When "use strict 'vars'" is in effect, "our" lets you use declared global variables without qualifying them with package names, within the lexical scope of the "our" declaration. In this way "our" differs from "use vars", which is package scoped. Unlike "my", which both allocates storage for a variable and associates a simple name with that storage for use within the current scope, "our" associates a simple name with a package variable in the current package, for use within the current scope. In other words, "our" has the same scoping rules as "my", but does not necessarily create a variable. The first paragraph seems to imply to me that our is for declaring a global variable as most C developers tend to think of them. If I understand it correctly our is always associated with a package - if we call our outside a defined package as is the case in my sample it goes to the package main. The second paragraph doesnt help me understand things any better other than to say that my and our are similar in scope. I would like to quote from http://stackoverflow.com/questions/845060/what-is-the-difference-between-my-and-our-in-perl which says Available since Perl 5, my is a way to declare: * non-package variables, that are * private, * new, * non-global variables, * separate from any package. So that the variable cannot be accessed in the form of $package_name::variable. On the other hand, our variables are: * package variables, and thus automatically * global variables, * definitely not private, * nor are they necessarily new; and they * can be accessed outside the package (or lexical scope) with the qualified namespace, as $package_name::variable. Personally the second explanation is much more easier for me to comprehend than the perldoc but I suppose someone could elaborate what I might be missing out on if I follow that explanation. In any case thanks for listening to me and hopefully I am not making a fool of myself here with perl basics. - Mithun ________________________________ From: Alexander Danel To: Chicago.pm chatter Sent: Wed, March 3, 2010 9:00:08 PM Subject: Re: [Chicago-talk] Global variable behavior Get in the habit of putting the following at the top of every file: use strict; Try it. It will inform you that you are implicitly doing just what you claim you are not doing: you have declared (or, as you put it ?redeclared?) the variable. ?Use strict? will protest because implicit declarations are often an accident; which is clearly appropriate for your case. By the way, I take exception to your statement ?. . . should make it global across all name spaces.? No such concept exists in Perl. You declared the variable to be in the ?main? namespace; which you seemingly understood when you used ?$::c?, the naked double-colon being an alias for ?main::?. The package ?main? is in force until you declare otherwise. Alexander Danel ________________________________ From:chicago-talk-bounces+danel=speakeasy.net at pm.org [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of Mithun Bhattacharya Sent: Wednesday, March 03, 2010 8:20 PM To: chicago-talk at pm.org Subject: [Chicago-talk] Global variable behavior Hi Everyone, A piece of my code is behaving in a way I didn't expect and I was hoping someone could enlighten me as to why.. ------------------------------------- $ cat a.pl push @INC, '.'; our $c = 15; require newbie; ------------------------------------- $ cat newbie.pm package newbie; print "first attempt: " . $c . "\n"; print "second attempt: " . $::c . "\n"; 1; ------------------------------------- $ perl a.pl first attempt: second attempt: 15 ------------------------------------- The way I see it the ourin a.plshould make it global across all namespaces. The second attempt does seem to say that did take place. What I am not sure is why the $cvariable has become local in scope even though I haven't re-declared or redefined it in any way inside newbie.pm. - Mithun -------------- next part -------------- An HTML attachment was scrubbed... URL: From richard at rushlogistics.com Sun Mar 7 07:17:43 2010 From: richard at rushlogistics.com (Richard Reina) Date: Sun, 07 Mar 2010 10:17:43 -0500 (EST) Subject: [Chicago-talk] =?utf-8?q?system_command_to_kill_Xwindows_session?= =?utf-8?q?=3F?= Message-ID: <20100307151743.D46F63E7A@courageux.xo.com> Does anyone know if there is a perl fucntion or a command that can be put into system("") that will kill Xwindow and return a script/user to the console? Thanks, Richard From danel at speakeasy.net Sun Mar 7 07:54:07 2010 From: danel at speakeasy.net (Alexander Danel) Date: Sun, 7 Mar 2010 09:54:07 -0600 Subject: [Chicago-talk] system command to kill Xwindows session? In-Reply-To: <20100307151743.D46F63E7A@courageux.xo.com> Message-ID: <013101cabe0e$6c25b2f0$0500a8c0@dsmsik7n2d2> Your question is incoherent; obviously if you are looking for a system command, then its not a Perl function. How did you start the process that opened the window, and are you willing to kill the entire process? On Unix, if you know the process-id, then try: system("kill TERM $thePid"); Alexander -----Original Message----- From: chicago-talk-bounces+danel=speakeasy.net at pm.org [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of Richard Reina Sent: Sunday, March 07, 2010 9:18 AM To: chicago-talk at pm.org Subject: [Chicago-talk] system command to kill Xwindows session? Does anyone know if there is a perl fucntion or a command that can be put into system("") that will kill Xwindow and return a script/user to the console? Thanks, Richard _______________________________________________ Chicago-talk mailing list Chicago-talk at pm.org http://mail.pm.org/mailman/listinfo/chicago-talk From richard at rushlogistics.com Sun Mar 7 08:06:16 2010 From: richard at rushlogistics.com (Richard Reina) Date: Sun, 07 Mar 2010 11:06:16 -0500 (EST) Subject: [Chicago-talk] =?utf-8?q?system_command_to_kill_Xwindows_session?= =?utf-8?q?=3F?= In-Reply-To: <013101cabe0e$6c25b2f0$0500a8c0@dsmsik7n2d2> Message-ID: <20100307160616.6FCD33E7B@courageux.xo.com> I have script that starts an xwindows session with system("startx") I want it to end as soon as a specific tast is done? ---- Chicago.pm chatter wrote: > > Your question is incoherent; obviously if you are looking for a system > command, then its not a Perl function. > > How did you start the process that opened the window, and are you willing to > kill the entire process? > > On Unix, if you know the process-id, then try: > > system("kill TERM $thePid"); > > Alexander > > -----Original Message----- > From: chicago-talk-bounces+danel=speakeasy.net at pm.org > [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of > Richard Reina > Sent: Sunday, March 07, 2010 9:18 AM > To: chicago-talk at pm.org > Subject: [Chicago-talk] system command to kill Xwindows session? > > Does anyone know if there is a perl fucntion or a command that can be put > into system("") that will kill Xwindow and return a script/user to the > console? > > Thanks, > > Richard > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From danel at speakeasy.net Sun Mar 7 08:29:57 2010 From: danel at speakeasy.net (Alexander Danel) Date: Sun, 7 Mar 2010 10:29:57 -0600 Subject: [Chicago-talk] system command to kill Xwindows session? In-Reply-To: <20100307160616.6FCD33E7B@courageux.xo.com> Message-ID: <013201cabe13$6d3a6500$0500a8c0@dsmsik7n2d2> You didn't telll me if you are on UNIX. The "startx" script has to give you the PID, which it currently isn't doing, and then you have to gather the PID. In "startx", assuming Unix $!/bin/ksh Foobar & echo $! I assume you are using the '&' to background "Foobar". The '$!' gives you pid of background job, but must be immediately following "Foobar &" command. In Perl, you gather the echoed PID by using "qx" instead of system() my $thePid = qx/startx/; Now you can kill $thePid. Got to go. Goodluck, bye. Alexander -----Original Message----- From: chicago-talk-bounces+danel=speakeasy.net at pm.org [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of Richard Reina Sent: Sunday, March 07, 2010 10:06 AM To: Chicago.pm chatter Subject: Re: [Chicago-talk]system command to kill Xwindows session? I have script that starts an xwindows session with system("startx") I want it to end as soon as a specific tast is done? ---- Chicago.pm chatter wrote: > > Your question is incoherent; obviously if you are looking for a system > command, then its not a Perl function. > > How did you start the process that opened the window, and are you willing to > kill the entire process? > > On Unix, if you know the process-id, then try: > > system("kill TERM $thePid"); > > Alexander > > -----Original Message----- > From: chicago-talk-bounces+danel=speakeasy.net at pm.org > [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of > Richard Reina > Sent: Sunday, March 07, 2010 9:18 AM > To: chicago-talk at pm.org > Subject: [Chicago-talk] system command to kill Xwindows session? > > Does anyone know if there is a perl fucntion or a command that can be put > into system("") that will kill Xwindow and return a script/user to the > console? > > Thanks, > > Richard > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > _______________________________________________ Chicago-talk mailing list Chicago-talk at pm.org http://mail.pm.org/mailman/listinfo/chicago-talk From richard at rushlogistics.com Sun Mar 7 08:33:34 2010 From: richard at rushlogistics.com (Richard Reina) Date: Sun, 07 Mar 2010 11:33:34 -0500 (EST) Subject: [Chicago-talk] =?utf-8?q?system_command_to_kill_Xwindows_session?= =?utf-8?q?=3F?= In-Reply-To: <013201cabe13$6d3a6500$0500a8c0@dsmsik7n2d2> Message-ID: <20100307163334.32983328@victory.xo.com> Linux. Sorry. ---- Chicago.pm chatter wrote: > > You didn't telll me if you are on UNIX. > > The "startx" script has to give you the PID, which it currently isn't doing, > and then you have to gather the PID. > > In "startx", assuming Unix > > $!/bin/ksh > Foobar & > echo $! > > I assume you are using the '&' to background "Foobar". The '$!' gives you > pid of background job, but must be immediately following "Foobar &" command. > > In Perl, you gather the echoed PID by using "qx" instead of system() > > my $thePid = qx/startx/; > > Now you can kill $thePid. > > Got to go. Goodluck, bye. > > Alexander > > -----Original Message----- > From: chicago-talk-bounces+danel=speakeasy.net at pm.org > [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of > Richard Reina > Sent: Sunday, March 07, 2010 10:06 AM > To: Chicago.pm chatter > Subject: Re: [Chicago-talk]system command to kill Xwindows session? > > I have script that starts an xwindows session with system("startx") I want > it to end as soon as a specific tast is done? > > > ---- Chicago.pm chatter wrote: > > > > Your question is incoherent; obviously if you are looking for a system > > command, then its not a Perl function. > > > > How did you start the process that opened the window, and are you willing > to > > kill the entire process? > > > > On Unix, if you know the process-id, then try: > > > > system("kill TERM $thePid"); > > > > Alexander > > > > -----Original Message----- > > From: chicago-talk-bounces+danel=speakeasy.net at pm.org > > [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of > > Richard Reina > > Sent: Sunday, March 07, 2010 9:18 AM > > To: chicago-talk at pm.org > > Subject: [Chicago-talk] system command to kill Xwindows session? > > > > Does anyone know if there is a perl fucntion or a command that can be put > > into system("") that will kill Xwindow and return a script/user to the > > console? > > > > Thanks, > > > > Richard > > _______________________________________________ > > Chicago-talk mailing list > > Chicago-talk at pm.org > > http://mail.pm.org/mailman/listinfo/chicago-talk > > > > _______________________________________________ > > Chicago-talk mailing list > > Chicago-talk at pm.org > > http://mail.pm.org/mailman/listinfo/chicago-talk > > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From danel at speakeasy.net Sun Mar 7 17:12:43 2010 From: danel at speakeasy.net (Alexander Danel) Date: Sun, 7 Mar 2010 19:12:43 -0600 Subject: [Chicago-talk] Global variable behavior In-Reply-To: <174556.70800.qm@web53404.mail.re2.yahoo.com> Message-ID: <014d01cabe5c$75470de0$0500a8c0@dsmsik7n2d2> Mithum, You say: * . . . demonstrating that it is use warnings which would help more in this scenario rather than use strict. No, you haven't demonstrated that at all. On the one hand, you are assuming that "require" is just like 'C' language "#include" (a pre-processor directive,) but on the other hand you have ended the module with "1;" which indicates you know that "require" is not just like "#include". The instruction "require" is not a pre-processing directive, but rather, the required file is compiled and executed at the time of inclusion, and the whole process retains the integrity of the file as a unit of scope. So . . . >From my e-mail: > Get in the habit of putting the following at the top of every file: > > use strict; If you actually do that, i.e. if you put it at the head of the file "newbie.pm", you will get this message: Global symbol "$c" requires explicit package name at newbie.pm line 5. Compilation failed in require at a.pl line 7. That is a compile time message dealing with declaration. By contrast, "use warnings" is a run time check and has nothing to do with the declaration, except that it calls attention to your mistaken belief that you initialized something that you haven't. By the way, I also put "use warnings" at the top of all my files during development, and usually I leave it there. For performance reasons some people take it out aftter development is done if they have a performance critical app - like I said, it is a run-time check. Alexander Danel _____ From: chicago-talk-bounces+danel=speakeasy.net at pm.org [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of Mithun Bhattacharya Sent: Friday, March 05, 2010 10:33 PM To: Chicago.pm chatter Subject: Re: [Chicago-talk] Global variable behavior Thanks for the input. I guess I took somethings for granted and didn't read up the relevant sections carefully :) I am not nitpicking here but I would like to share a few more things which became more obvious to me - hopefully it will help others too. New code follows ====================================================================== $ cat a.pl use strict; push @INC, '.'; our $c = 15; require newbie; ====================================================================== $ cat newbie.pm package newbie; print "first attempt: " . $c . "\n"; print "second attempt: " . $::c . "\n"; 1; ====================================================================== $ perl a.pl first attempt: second attempt: 15 ====================================================================== $ perl -w a.pl Use of uninitialized value $newbie::c in concatenation (.) or string at newbie.pm line 3. first attempt: second attempt: 15 ====================================================================== $ perl -v This is perl, v5.10.0 built for x86_64-linux-thread-multi ====================================================================== I am just demonstrating that it is use warnings which would help more in this scenario rather than use strict. Something else which confused me after I started understanding our better was the following - maybe someone can point out if I have miss-understood anything. As per perldoc for our "our" associates a simple name with a package variable in the current package for use within the current scope. When "use strict 'vars'" is in effect, "our" lets you use declared global variables without qualifying them with package names, within the lexical scope of the "our" declaration. In this way "our" differs from "use vars", which is package scoped. Unlike "my", which both allocates storage for a variable and associates a simple name with that storage for use within the current scope, "our" associates a simple name with a package variable in the current package, for use within the current scope. In other words, "our" has the same scoping rules as "my", but does not necessarily create a variable. The first paragraph seems to imply to me that our is for declaring a global variable as most C developers tend to think of them. If I understand it correctly our is always associated with a package - if we call our outside a defined package as is the case in my sample it goes to the package main. The second paragraph doesnt help me understand things any better other than to say that my and our are similar in scope. I would like to quote from http://stackoverflow.com/questions/845060/what-is-the-difference-between-my- and-our-in-perl which says Available since Perl 5, my is a way to declare: * non-package variables, that are * private, * new, * non-global variables, * separate from any package. So that the variable cannot be accessed in the form of $package_name::variable. On the other hand, our variables are: * package variables, and thus automatically * global variables, * definitely not private, * nor are they necessarily new; and they * can be accessed outside the package (or lexical scope) with the qualified namespace, as $package_name::variable. Personally the second explanation is much more easier for me to comprehend than the perldoc but I suppose someone could elaborate what I might be missing out on if I follow that explanation. In any case thanks for listening to me and hopefully I am not making a fool of myself here with perl basics. - Mithun _____ From: Alexander Danel To: Chicago.pm chatter Sent: Wed, March 3, 2010 9:00:08 PM Subject: Re: [Chicago-talk] Global variable behavior Get in the habit of putting the following at the top of every file: use strict; Try it. It will inform you that you are implicitly doing just what you claim you are not doing: you have declared (or, as you put it "redeclared") the variable. "Use strict" will protest because implicit declarations are often an accident; which is clearly appropriate for your case. By the way, I take exception to your statement ". . . should make it global across all name spaces." No such concept exists in Perl. You declared the variable to be in the "main" namespace; which you seemingly understood when you used "$::c", the naked double-colon being an alias for "main::". The package "main" is in force until you declare otherwise. Alexander Danel _____ From: chicago-talk-bounces+danel=speakeasy.net at pm.org [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of Mithun Bhattacharya Sent: Wednesday, March 03, 2010 8:20 PM To: chicago-talk at pm.org Subject: [Chicago-talk] Global variable behavior Hi Everyone, A piece of my code is behaving in a way I didn't expect and I was hoping someone could enlighten me as to why.. ------------------------------------- $ cat a.pl push @INC, '.'; our $c = 15; require newbie; ------------------------------------- $ cat newbie.pm package newbie; print "first attempt: " . $c . "\n"; print "second attempt: " . $::c . "\n"; 1; ------------------------------------- $ perl a.pl first attempt: second attempt: 15 ------------------------------------- The way I see it the our in a.pl should make it global across all namespaces. The second attempt does seem to say that did take place. What I am not sure is why the $c variable has become local in scope even though I haven't re-declared or redefined it in any way inside newbie.pm. - Mithun -------------- next part -------------- An HTML attachment was scrubbed... URL: From richard at rushlogistics.com Mon Mar 8 05:27:50 2010 From: richard at rushlogistics.com (Richard Reina) Date: Mon, 08 Mar 2010 08:27:50 -0500 (EST) Subject: [Chicago-talk] Bareword found where operator expected Message-ID: <20100308132750.9D38B3E96@courageux.xo.com> I was hoping someone might help me figure out why this simple three line program won't work. If I do: #!/usr/bin/perl -w use strict; system("gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4;'"); I get: Bareword found where operator expected at test.pl line 5, near ""gnome-terminal -x perl -e 'print "Hello" (Missing operator before Hello?) String found where operator expected at test.pl line 5, near "n"; sleep 4;'"" syntax error at test.pl line 5, near ""gnome-terminal -x perl -e 'print "Hello World" Execution of test.pl aborted due to compilation errors. What is especially confusing to me is that if I type in: gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4; at the command line, it works. I am running linux. Any help would be greatly appreciated. Richard From andy at petdance.com Mon Mar 8 05:35:04 2010 From: andy at petdance.com (Andy Lester) Date: Mon, 8 Mar 2010 07:35:04 -0600 Subject: [Chicago-talk] Bareword found where operator expected In-Reply-To: <20100308132750.9D38B3E96@courageux.xo.com> References: <20100308132750.9D38B3E96@courageux.xo.com> Message-ID: <02BB2FAA-45A2-4F32-92E9-3A93663FDF80@petdance.com> On Mar 8, 2010, at 7:27 AM, Richard Reina wrote: > system("gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4;'"); You have double quotes inside of that string. You need to do either: system("gnome-terminal -x perl -e 'print \"Hello World\n\"; sleep 4;'"); or system(q{gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4;'}); -- Andy Lester => andy at petdance.com => www.theworkinggeek.com => AIM:petdance From danel at speakeasy.net Mon Mar 8 05:44:08 2010 From: danel at speakeasy.net (Alexander Danel) Date: Mon, 8 Mar 2010 07:44:08 -0600 Subject: [Chicago-talk] Bareword found where operator expected In-Reply-To: <20100308132750.9D38B3E96@courageux.xo.com> Message-ID: <018501cabec5$6dc08a10$0500a8c0@dsmsik7n2d2> Your quoting is not working as you expect. Don't feel bad -- everybody goes through this at some point. You are going through several levels of interpretation. At the first level, the single quotes are within double quotes, and therefore the single quotes have no special meaning. Since the single quotes are not giving you any protection, the next double quote DOES have special meaning -- it is the end of the quoted string. Therefore, the word "Hello" is not within a quoted string; so the compiler is trying to interpret it as something that could possibly stand alone, i.e. a "bareword". Shield the internal quotation marks with backslashes. Furthermore, although "\n" will work as it stands, it does so for the wrong reason; I recommend you escape the backslash by using double backslash, like this: "\\n". Alexander Danel -----Original Message----- From: chicago-talk-bounces+danel=speakeasy.net at pm.org [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of Richard Reina Sent: Monday, March 08, 2010 7:28 AM To: chicago-talk at pm.org Subject: [Chicago-talk] Bareword found where operator expected I was hoping someone might help me figure out why this simple three line program won't work. If I do: #!/usr/bin/perl -w use strict; system("gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4;'"); I get: Bareword found where operator expected at test.pl line 5, near ""gnome-terminal -x perl -e 'print "Hello" (Missing operator before Hello?) String found where operator expected at test.pl line 5, near "n"; sleep 4;'"" syntax error at test.pl line 5, near ""gnome-terminal -x perl -e 'print "Hello World" Execution of test.pl aborted due to compilation errors. What is especially confusing to me is that if I type in: gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4; at the command line, it works. I am running linux. Any help would be greatly appreciated. Richard _______________________________________________ Chicago-talk mailing list Chicago-talk at pm.org http://mail.pm.org/mailman/listinfo/chicago-talk From richard at rushlogistics.com Mon Mar 8 06:09:57 2010 From: richard at rushlogistics.com (Richard Reina) Date: Mon, 08 Mar 2010 09:09:57 -0500 (EST) Subject: [Chicago-talk] Bareword found where operator expected In-Reply-To: <20100308132750.9D38B3E96@courageux.xo.com> Message-ID: <20100308140957.7FE3A1ADC@bellona.xo.com> Thank you Andy. That worked perfectly. I really appreciate the reply. ---- Chicago.pm chatter wrote: > > > On Mar 8, 2010, at 7:27 AM, Richard Reina wrote: > > > system("gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4;'"); > > You have double quotes inside of that string. You need to do either: > > system("gnome-terminal -x perl -e 'print \"Hello World\n\"; sleep 4;'"); > > or > > system(q{gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4;'}); > > -- > Andy Lester => andy at petdance.com => www.theworkinggeek.com => AIM:petdance > > > > > > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From richard at rushlogistics.com Mon Mar 8 06:12:41 2010 From: richard at rushlogistics.com (Richard Reina) Date: Mon, 08 Mar 2010 09:12:41 -0500 (EST) Subject: [Chicago-talk] Bareword found where operator expected In-Reply-To: <018501cabec5$6dc08a10$0500a8c0@dsmsik7n2d2> Message-ID: <20100308141241.E8A4A1ADF@bellona.xo.com> Alexander, Thank you very much for your reply. Your explanation was helpful and necessary as I have a lot to learn as a perl programmer. Thanks again. ---- Chicago.pm chatter wrote: > > Your quoting is not working as you expect. Don't feel bad -- everybody goes > through this at some point. You are going through several levels of > interpretation. At the first level, the single quotes are within double > quotes, and therefore the single quotes have no special meaning. Since the > single quotes are not giving you any protection, the next double quote DOES > have special meaning -- it is the end of the quoted string. Therefore, the > word "Hello" is not within a quoted string; so the compiler is trying to > interpret it as something that could possibly stand alone, i.e. a > "bareword". > > Shield the internal quotation marks with backslashes. Furthermore, although > "\n" will work as it stands, it does so for the wrong reason; I recommend > you escape the backslash by using double backslash, like this: "\\n". > > Alexander Danel > > -----Original Message----- > From: chicago-talk-bounces+danel=speakeasy.net at pm.org > [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of > Richard Reina > Sent: Monday, March 08, 2010 7:28 AM > To: chicago-talk at pm.org > Subject: [Chicago-talk] Bareword found where operator expected > > I was hoping someone might help me figure out why this simple three line > program won't work. > > If I do: > > #!/usr/bin/perl -w > > use strict; > system("gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4;'"); > > I get: > > Bareword found where operator expected at test.pl line 5, near > ""gnome-terminal -x perl -e 'print "Hello" > (Missing operator before Hello?) > String found where operator expected at test.pl line 5, near "n"; sleep > 4;'"" > syntax error at test.pl line 5, near ""gnome-terminal -x perl -e 'print > "Hello World" > Execution of test.pl aborted due to compilation errors. > > > What is especially confusing to me is that if I type in: > > gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4; > > at the command line, it works. I am running linux. > > Any help would be greatly appreciated. > > Richard > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From jon-chicagotalk at jrock.us Mon Mar 8 23:00:05 2010 From: jon-chicagotalk at jrock.us (Jonathan Rockway) Date: Tue, 09 Mar 2010 01:00:05 -0600 Subject: [Chicago-talk] system command to kill Xwindows session? In-Reply-To: <20100307163334.32983328@victory.xo.com> (Richard Reina's message of "Sun, 07 Mar 2010 11:33:34 -0500 (EST)") References: <20100307163334.32983328@victory.xo.com> Message-ID: <87aauihte2.fsf@snowball2.jrock.us> OK, so here are my thoughts on this issue. "startx" has way too much baggage for an automated process. Do you really want the X server to load, take over the screen and keyboard, and wait for default system window manager (like a full GNOME session) to load... or do you just want to run some script that requires an X server? In the first case, sure, use startx. But isn't the user going to be confused when the X server randomly dies without saving his session? If you just want an interactive Xserver, though, just run "X :1" or whatever, and then set DISPLAY to ":1". When you don't want X anymore, just send it SIGTERM or whatever. But in most cases, you don't actually need a real Xserver that touches the hardware; you can just use Xvfb and connect your clients to that. Then there is no interference with the host machine. http://en.wikipedia.org/wiki/Xvfb Any time I have ever needed an X server for an automated process, Xvfb has been what I've needed. It works like a real X server, except it doesn't touch the real hardware. Finally, stop fighting with hacks around system and qx. If you need to start a real background process, use a module like AnyEvent::Subprocess: my $done = AnyEvent->condvar; my $job = AnyEvent::Subprocess->new( code => [qw/Xvfb :1234/], on_completion => sub { say 'X server exited with status '. $_[0]->exit_status }, ); my $proc = $job->run; $ENV{DISPLAY} = ':1234'; ; $proc->kill('TERM'); Much cleaner. Regards, Jonathan Rockway * On Sun, Mar 07 2010, Richard Reina wrote: > Linux. Sorry. > ---- Chicago.pm chatter wrote: >> >> You didn't telll me if you are on UNIX. >> >> The "startx" script has to give you the PID, which it currently isn't doing, >> and then you have to gather the PID. >> >> In "startx", assuming Unix >> >> $!/bin/ksh >> Foobar & >> echo $! >> >> I assume you are using the '&' to background "Foobar". The '$!' gives you >> pid of background job, but must be immediately following "Foobar &" command. >> >> In Perl, you gather the echoed PID by using "qx" instead of system() >> >> my $thePid = qx/startx/; >> >> Now you can kill $thePid. >> >> Got to go. Goodluck, bye. >> >> Alexander >> >> -----Original Message----- >> From: chicago-talk-bounces+danel=speakeasy.net at pm.org >> [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of >> Richard Reina >> Sent: Sunday, March 07, 2010 10:06 AM >> To: Chicago.pm chatter >> Subject: Re: [Chicago-talk]system command to kill Xwindows session? >> >> I have script that starts an xwindows session with system("startx") I want >> it to end as soon as a specific tast is done? >> >> >> ---- Chicago.pm chatter wrote: >> > >> > Your question is incoherent; obviously if you are looking for a system >> > command, then its not a Perl function. >> > >> > How did you start the process that opened the window, and are you willing >> to >> > kill the entire process? >> > >> > On Unix, if you know the process-id, then try: >> > >> > system("kill TERM $thePid"); >> > >> > Alexander >> > >> > -----Original Message----- >> > From: chicago-talk-bounces+danel=speakeasy.net at pm.org >> > [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of >> > Richard Reina >> > Sent: Sunday, March 07, 2010 9:18 AM >> > To: chicago-talk at pm.org >> > Subject: [Chicago-talk] system command to kill Xwindows session? >> > >> > Does anyone know if there is a perl fucntion or a command that can be put >> > into system("") that will kill Xwindow and return a script/user to the >> > console? >> > >> > Thanks, >> > >> > Richard >> > _______________________________________________ >> > Chicago-talk mailing list >> > Chicago-talk at pm.org >> > http://mail.pm.org/mailman/listinfo/chicago-talk >> > >> > _______________________________________________ >> > Chicago-talk mailing list >> > Chicago-talk at pm.org >> > http://mail.pm.org/mailman/listinfo/chicago-talk >> > >> _______________________________________________ >> Chicago-talk mailing list >> Chicago-talk at pm.org >> http://mail.pm.org/mailman/listinfo/chicago-talk >> >> _______________________________________________ >> Chicago-talk mailing list >> Chicago-talk at pm.org >> http://mail.pm.org/mailman/listinfo/chicago-talk >> > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk -- print just => another => perl => hacker => if $,=$" From richard at rushlogistics.com Tue Mar 9 09:49:53 2010 From: richard at rushlogistics.com (Richard Reina) Date: Tue, 09 Mar 2010 12:49:53 -0500 (EST) Subject: [Chicago-talk] =?utf-8?q?system_command_to_kill_Xwindows_session?= =?utf-8?q?=3F?= In-Reply-To: <20100307163334.32983328@victory.xo.com> Message-ID: <20100309174953.518E65FB@swiftsure.xo.com> Hi Jonathon, Thanks very much for the reply I will look into xvfb. ---- Chicago.pm chatter wrote: > > OK, so here are my thoughts on this issue. > > "startx" has way too much baggage for an automated process. Do you > really want the X server to load, take over the screen and keyboard, and > wait for default system window manager (like a full GNOME session) to > load... or do you just want to run some script that requires an X > server? > > In the first case, sure, use startx. But isn't the user going to be > confused when the X server randomly dies without saving his session? > > If you just want an interactive Xserver, though, just run "X :1" or > whatever, and then set DISPLAY to ":1". When you don't want X anymore, > just send it SIGTERM or whatever. > > But in most cases, you don't actually need a real Xserver that touches > the hardware; you can just use Xvfb and connect your clients to that. > Then there is no interference with the host machine. > > http://en.wikipedia.org/wiki/Xvfb > > Any time I have ever needed an X server for an automated process, Xvfb > has been what I've needed. It works like a real X server, except it > doesn't touch the real hardware. > > Finally, stop fighting with hacks around system and qx. If you need to > start a real background process, use a module like AnyEvent::Subprocess: > > my $done = AnyEvent->condvar; > my $job = AnyEvent::Subprocess->new( > code => [qw/Xvfb :1234/], > on_completion => sub { say 'X server exited with status '. $_[0]->exit_status }, > ); > > my $proc = $job->run; > $ENV{DISPLAY} = ':1234'; > ; > $proc->kill('TERM'); > > Much cleaner. > > Regards, > Jonathan Rockway > > * On Sun, Mar 07 2010, Richard Reina wrote: > > Linux. Sorry. > > ---- Chicago.pm chatter wrote: > >> > >> You didn't telll me if you are on UNIX. > >> > >> The "startx" script has to give you the PID, which it currently isn't doing, > >> and then you have to gather the PID. > >> > >> In "startx", assuming Unix > >> > >> $!/bin/ksh > >> Foobar & > >> echo $! > >> > >> I assume you are using the '&' to background "Foobar". The '$!' gives you > >> pid of background job, but must be immediately following "Foobar &" command. > >> > >> In Perl, you gather the echoed PID by using "qx" instead of system() > >> > >> my $thePid = qx/startx/; > >> > >> Now you can kill $thePid. > >> > >> Got to go. Goodluck, bye. > >> > >> Alexander > >> > >> -----Original Message----- > >> From: chicago-talk-bounces+danel=speakeasy.net at pm.org > >> [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of > >> Richard Reina > >> Sent: Sunday, March 07, 2010 10:06 AM > >> To: Chicago.pm chatter > >> Subject: Re: [Chicago-talk]system command to kill Xwindows session? > >> > >> I have script that starts an xwindows session with system("startx") I want > >> it to end as soon as a specific tast is done? > >> > >> > >> ---- Chicago.pm chatter wrote: > >> > > >> > Your question is incoherent; obviously if you are looking for a system > >> > command, then its not a Perl function. > >> > > >> > How did you start the process that opened the window, and are you willing > >> to > >> > kill the entire process? > >> > > >> > On Unix, if you know the process-id, then try: > >> > > >> > system("kill TERM $thePid"); > >> > > >> > Alexander > >> > > >> > -----Original Message----- > >> > From: chicago-talk-bounces+danel=speakeasy.net at pm.org > >> > [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of > >> > Richard Reina > >> > Sent: Sunday, March 07, 2010 9:18 AM > >> > To: chicago-talk at pm.org > >> > Subject: [Chicago-talk] system command to kill Xwindows session? > >> > > >> > Does anyone know if there is a perl fucntion or a command that can be put > >> > into system("") that will kill Xwindow and return a script/user to the > >> > console? > >> > > >> > Thanks, > >> > > >> > Richard > >> > _______________________________________________ > >> > Chicago-talk mailing list > >> > Chicago-talk at pm.org > >> > http://mail.pm.org/mailman/listinfo/chicago-talk > >> > > >> > _______________________________________________ > >> > Chicago-talk mailing list > >> > Chicago-talk at pm.org > >> > http://mail.pm.org/mailman/listinfo/chicago-talk > >> > > >> _______________________________________________ > >> Chicago-talk mailing list > >> Chicago-talk at pm.org > >> http://mail.pm.org/mailman/listinfo/chicago-talk > >> > >> _______________________________________________ > >> Chicago-talk mailing list > >> Chicago-talk at pm.org > >> http://mail.pm.org/mailman/listinfo/chicago-talk > >> > > _______________________________________________ > > Chicago-talk mailing list > > Chicago-talk at pm.org > > http://mail.pm.org/mailman/listinfo/chicago-talk > > -- > print just => another => perl => hacker => if $,=$" > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From richard at rushlogistics.com Tue Mar 9 10:14:30 2010 From: richard at rushlogistics.com (Richard Reina) Date: Tue, 09 Mar 2010 13:14:30 -0500 (EST) Subject: [Chicago-talk] =?utf-8?q?concurrent_processes=3F?= In-Reply-To: <20100308132750.9D38B3E96@courageux.xo.com> Message-ID: <20100309181430.5EC498998@arkroyal.xo.com> I have a program that opens a terminal so that the user can enter some info. Like this: system(q{gnome-terminal --geometry=80x12+0-30 -x perl -e 'require "./data_entry1.pl"; my $co=get_input();'}); # do something with $co The code works in that it opens a small terminal at the bottom of the screen where the user can enter info. However, the program continues to execute without waiting for the value of $co. Is there a way to make the program wait until the terminal session has been terminated so that the value of $co can be obtained? Been banging my head on this one since 6:30am so any help would be greatly appreciated. Thanks Richard ---- Chicago.pm chatter wrote: > > > On Mar 8, 2010, at 7:27 AM, Richard Reina wrote: > > > system("gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4;'"); > > You have double quotes inside of that string. You need to do either: > > system("gnome-terminal -x perl -e 'print \"Hello World\n\"; sleep 4;'"); > > or > > system(q{gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4;'}); > > -- > Andy Lester => andy at petdance.com => www.theworkinggeek.com => AIM:petdance > > > > > > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From shawn.c.carroll at gmail.com Tue Mar 9 10:18:01 2010 From: shawn.c.carroll at gmail.com (Shawn Carroll) Date: Tue, 9 Mar 2010 12:18:01 -0600 Subject: [Chicago-talk] concurrent processes? In-Reply-To: <20100309181430.5EC498998@arkroyal.xo.com> References: <20100308132750.9D38B3E96@courageux.xo.com> <20100309181430.5EC498998@arkroyal.xo.com> Message-ID: Replace system w/ exec. system() forks, exec does not. shawn.c.carroll at gmail.com Perl Programmer Soccer Referee On Tue, Mar 9, 2010 at 12:14, Richard Reina wrote: > I have a program that opens a terminal so that the user can enter some info. ?Like this: > > > system(q{gnome-terminal --geometry=80x12+0-30 -x perl -e 'require "./data_entry1.pl"; my $co=get_input();'}); > > # do something with $co > > The code works in that it opens a small terminal at the bottom of the screen where the user can enter info. ?However, the program continues to execute without waiting for the value of $co. Is there a way to make the program wait until the terminal session has been terminated so that the value of $co can be obtained? > > Been banging my head on this one since 6:30am so any help would be greatly appreciated. > > Thanks > Richard > > > > ---- Chicago.pm chatter wrote: >> >> >> On Mar 8, 2010, at 7:27 AM, Richard Reina wrote: >> >> > system("gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4;'"); >> >> You have double quotes inside of that string. ?You need to do either: >> >> system("gnome-terminal -x perl -e 'print \"Hello World\n\"; sleep 4;'"); >> >> or >> >> system(q{gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4;'}); >> >> -- >> Andy Lester => andy at petdance.com => www.theworkinggeek.com => AIM:petdance >> >> >> >> >> >> >> _______________________________________________ >> Chicago-talk mailing list >> Chicago-talk at pm.org >> http://mail.pm.org/mailman/listinfo/chicago-talk >> > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From richard at rushlogistics.com Tue Mar 9 10:37:48 2010 From: richard at rushlogistics.com (Richard Reina) Date: Tue, 09 Mar 2010 13:37:48 -0500 (EST) Subject: [Chicago-talk] =?utf-8?q?concurrent_processes=3F?= In-Reply-To: <20100308132750.9D38B3E96@courageux.xo.com> <20100309181430.5EC498998@arkroyal.xo.com> Message-ID: <20100309183748.9FE8E5FB@swiftsure.xo.com> Shawn thanks for your reply. It looks promising but the program crashes with: Statement unlikely to be reached at test_exec.pl line 5. (Maybe you meant system() when you said exec()?) Do I need some added syntax to use exec? ---- Chicago.pm chatter wrote: > > Replace system w/ exec. system() forks, exec does not. > shawn.c.carroll at gmail.com > Perl Programmer > Soccer Referee > > > > On Tue, Mar 9, 2010 at 12:14, Richard Reina wrote: > > I have a program that opens a terminal so that the user can enter some info. ?Like this: > > > > > > system(q{gnome-terminal --geometry=80x12+0-30 -x perl -e 'require "./data_entry1.pl"; my $co=get_input();'}); > > > > # do something with $co > > > > The code works in that it opens a small terminal at the bottom of the screen where the user can enter info. ?However, the program continues to execute without waiting for the value of $co. Is there a way to make the program wait until the terminal session has been terminated so that the value of $co can be obtained? > > > > Been banging my head on this one since 6:30am so any help would be greatly appreciated. > > > > Thanks > > Richard > > > > > > > > ---- Chicago.pm chatter wrote: > >> > >> > >> On Mar 8, 2010, at 7:27 AM, Richard Reina wrote: > >> > >> > system("gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4;'"); > >> > >> You have double quotes inside of that string. ?You need to do either: > >> > >> system("gnome-terminal -x perl -e 'print \"Hello World\n\"; sleep 4;'"); > >> > >> or > >> > >> system(q{gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4;'}); > >> > >> -- > >> Andy Lester => andy at petdance.com => www.theworkinggeek.com => AIM:petdance > >> > >> > >> > >> > >> > >> > >> _______________________________________________ > >> Chicago-talk mailing list > >> Chicago-talk at pm.org > >> http://mail.pm.org/mailman/listinfo/chicago-talk > >> > > _______________________________________________ > > Chicago-talk mailing list > > Chicago-talk at pm.org > > http://mail.pm.org/mailman/listinfo/chicago-talk > > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From imranjj at gmail.com Tue Mar 9 11:12:56 2010 From: imranjj at gmail.com (imran javaid) Date: Tue, 9 Mar 2010 13:12:56 -0600 Subject: [Chicago-talk] concurrent processes? In-Reply-To: <20100309183748.9FE8E5FB@swiftsure.xo.com> References: <20100308132750.9D38B3E96@courageux.xo.com> <20100309181430.5EC498998@arkroyal.xo.com> <20100309183748.9FE8E5FB@swiftsure.xo.com> Message-ID: The man page of exec() explains this: Since it's a common mistake to use exec instead of system, Perl warns you if there is a following statement which isn't die, warn, or exit (if -w is set - but you always do that). If you really want to follow an exec with some other statement, you can use one of these styles to avoid the warning: exec ('foo') or print STDERR "couldn't exec foo: $!"; { exec ('foo') }; print STDERR "couldn't exec foo: $!"; On Tue, Mar 9, 2010 at 12:37 PM, Richard Reina wrote: > > Shawn thanks for your reply. It looks promising but the program crashes with: > > Statement unlikely to be reached at test_exec.pl line 5. > ? ? ? ?(Maybe you meant system() when you said exec()?) > > Do I need some added syntax to use exec? > > ---- Chicago.pm chatter wrote: > > > > Replace system w/ exec. ?system() forks, exec does not. > > shawn.c.carroll at gmail.com > > Perl Programmer > > Soccer Referee > > > > > > > > On Tue, Mar 9, 2010 at 12:14, Richard Reina wrote: > > > I have a program that opens a terminal so that the user can enter some info. ?Like this: > > > > > > > > > system(q{gnome-terminal --geometry=80x12+0-30 -x perl -e 'require "./data_entry1.pl"; my $co=get_input();'}); > > > > > > # do something with $co > > > > > > The code works in that it opens a small terminal at the bottom of the screen where the user can enter info. ?However, the program continues to execute without waiting for the value of $co. Is there a way to make the program wait until the terminal session has been terminated so that the value of $co can be obtained? > > > > > > Been banging my head on this one since 6:30am so any help would be greatly appreciated. > > > > > > Thanks > > > Richard > > > > > > > > > > > > ---- Chicago.pm chatter wrote: > > >> > > >> > > >> On Mar 8, 2010, at 7:27 AM, Richard Reina wrote: > > >> > > >> > system("gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4;'"); > > >> > > >> You have double quotes inside of that string. ?You need to do either: > > >> > > >> system("gnome-terminal -x perl -e 'print \"Hello World\n\"; sleep 4;'"); > > >> > > >> or > > >> > > >> system(q{gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4;'}); > > >> > > >> -- > > >> Andy Lester => andy at petdance.com => www.theworkinggeek.com => AIM:petdance > > >> > > >> > > >> > > >> > > >> > > >> > > >> _______________________________________________ > > >> Chicago-talk mailing list > > >> Chicago-talk at pm.org > > >> http://mail.pm.org/mailman/listinfo/chicago-talk > > >> > > > _______________________________________________ > > > Chicago-talk mailing list > > > Chicago-talk at pm.org > > > http://mail.pm.org/mailman/listinfo/chicago-talk > > > > > _______________________________________________ > > Chicago-talk mailing list > > Chicago-talk at pm.org > > http://mail.pm.org/mailman/listinfo/chicago-talk > > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk From richard at rushlogistics.com Tue Mar 9 11:29:54 2010 From: richard at rushlogistics.com (Richard Reina) Date: Tue, 09 Mar 2010 14:29:54 -0500 (EST) Subject: [Chicago-talk] =?utf-8?q?concurrent_processes=3F?= In-Reply-To: <20100308132750.9D38B3E96@courageux.xo.com> <20100309181430.5EC498998@arkroyal.xo.com> <20100309183748.9FE8E5FB@swiftsure.xo.com> Message-ID: <20100309192954.F25B35F6@captain.xo.com> That stops the error message but the rest of the program does not execute. ---- Chicago.pm chatter wrote: > > The man page of exec() explains this: > > Since it's a common mistake to use exec instead of system, Perl warns > you if there is a following statement which isn't die, warn, or exit > (if -w is set - but you always do that). If you really want to follow > an exec with some other statement, you can use one of these styles to > avoid the warning: > > exec ('foo') or print STDERR "couldn't exec foo: $!"; > { exec ('foo') }; print STDERR "couldn't exec foo: $!"; > > > On Tue, Mar 9, 2010 at 12:37 PM, Richard Reina > wrote: > > > > Shawn thanks for your reply. It looks promising but the program crashes with: > > > > Statement unlikely to be reached at test_exec.pl line 5. > > ? ? ? ?(Maybe you meant system() when you said exec()?) > > > > Do I need some added syntax to use exec? > > > > ---- Chicago.pm chatter wrote: > > > > > > Replace system w/ exec. ?system() forks, exec does not. > > > shawn.c.carroll at gmail.com > > > Perl Programmer > > > Soccer Referee > > > > > > > > > > > > On Tue, Mar 9, 2010 at 12:14, Richard Reina wrote: > > > > I have a program that opens a terminal so that the user can enter some info. ?Like this: > > > > > > > > > > > > system(q{gnome-terminal --geometry=80x12+0-30 -x perl -e 'require "./data_entry1.pl"; my $co=get_input();'}); > > > > > > > > # do something with $co > > > > > > > > The code works in that it opens a small terminal at the bottom of the screen where the user can enter info. ?However, the program continues to execute without waiting for the value of $co. Is there a way to make the program wait until the terminal session has been terminated so that the value of $co can be obtained? > > > > > > > > Been banging my head on this one since 6:30am so any help would be greatly appreciated. > > > > > > > > Thanks > > > > Richard > > > > > > > > > > > > > > > > ---- Chicago.pm chatter wrote: > > > >> > > > >> > > > >> On Mar 8, 2010, at 7:27 AM, Richard Reina wrote: > > > >> > > > >> > system("gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4;'"); > > > >> > > > >> You have double quotes inside of that string. ?You need to do either: > > > >> > > > >> system("gnome-terminal -x perl -e 'print \"Hello World\n\"; sleep 4;'"); > > > >> > > > >> or > > > >> > > > >> system(q{gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4;'}); > > > >> > > > >> -- > > > >> Andy Lester => andy at petdance.com => www.theworkinggeek.com => AIM:petdance > > > >> > > > >> > > > >> > > > >> > > > >> > > > >> > > > >> _______________________________________________ > > > >> Chicago-talk mailing list > > > >> Chicago-talk at pm.org > > > >> http://mail.pm.org/mailman/listinfo/chicago-talk > > > >> > > > > _______________________________________________ > > > > Chicago-talk mailing list > > > > Chicago-talk at pm.org > > > > http://mail.pm.org/mailman/listinfo/chicago-talk > > > > > > > _______________________________________________ > > > Chicago-talk mailing list > > > Chicago-talk at pm.org > > > http://mail.pm.org/mailman/listinfo/chicago-talk > > > > > _______________________________________________ > > Chicago-talk mailing list > > Chicago-talk at pm.org > > http://mail.pm.org/mailman/listinfo/chicago-talk > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From briank at kappacs.com Tue Mar 9 11:55:39 2010 From: briank at kappacs.com (Brian Katzung) Date: Tue, 09 Mar 2010 13:55:39 -0600 Subject: [Chicago-talk] concurrent processes? In-Reply-To: <20100309192954.F25B35F6@captain.xo.com> References: <20100309192954.F25B35F6@captain.xo.com> Message-ID: <4B96A7BB.2020704@kappacs.com> Richard, Did I miss part of the discussion? It seems as if we're throwing out "1 foot solutions" without seeing the "30,000 foot view". How about if we take a few steps backwards. In the bigger picture, what are you trying to accomplish, and why do you believe it requires launching an interactive windows session and a new terminal window rather than just prompting in the original execution context? - Brian Richard Reina wrote: > That stops the error message but the rest of the program does not execute. > > > ---- Chicago.pm chatter wrote: > >> The man page of exec() explains this: >> >> Since it's a common mistake to use exec instead of system, Perl warns >> you if there is a following statement which isn't die, warn, or exit >> (if -w is set - but you always do that). If you really want to follow >> an exec with some other statement, you can use one of these styles to >> avoid the warning: >> >> exec ('foo') or print STDERR "couldn't exec foo: $!"; >> { exec ('foo') }; print STDERR "couldn't exec foo: $!"; >> >> >> On Tue, Mar 9, 2010 at 12:37 PM, Richard Reina >> wrote: >> >>> Shawn thanks for your reply. It looks promising but the program crashes with: >>> >>> Statement unlikely to be reached at test_exec.pl line 5. >>> (Maybe you meant system() when you said exec()?) >>> >>> Do I need some added syntax to use exec? >>> >>> ---- Chicago.pm chatter wrote: >>> >>>> Replace system w/ exec. system() forks, exec does not. >>>> shawn.c.carroll at gmail.com >>>> Perl Programmer >>>> Soccer Referee >>>> >>>> >>>> >>>> On Tue, Mar 9, 2010 at 12:14, Richard Reina wrote: >>>> >>>>> I have a program that opens a terminal so that the user can enter some info. Like this: >>>>> >>>>> >>>>> system(q{gnome-terminal --geometry=80x12+0-30 -x perl -e 'require "./data_entry1.pl"; my $co=get_input();'}); >>>>> >>>>> # do something with $co >>>>> >>>>> The code works in that it opens a small terminal at the bottom of the screen where the user can enter info. However, the program continues to execute without waiting for the value of $co. Is there a way to make the program wait until the terminal session has been terminated so that the value of $co can be obtained? >>>>> >>>>> Been banging my head on this one since 6:30am so any help would be greatly appreciated. >>>>> >>>>> Thanks >>>>> Richard >>>>> >>>>> >>>>> >>>>> ---- Chicago.pm chatter wrote: >>>>> >>>>>> On Mar 8, 2010, at 7:27 AM, Richard Reina wrote: >>>>>> >>>>>> >>>>>>> system("gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4;'"); >>>>>>> >>>>>> You have double quotes inside of that string. You need to do either: >>>>>> >>>>>> system("gnome-terminal -x perl -e 'print \"Hello World\n\"; sleep 4;'"); >>>>>> >>>>>> or >>>>>> >>>>>> system(q{gnome-terminal -x perl -e 'print "Hello World\n"; sleep 4;'}); >>>>>> >>>>>> -- >>>>>> Andy Lester => andy at petdance.com => www.theworkinggeek.com => AIM:petdance >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> Chicago-talk mailing list >>>>>> Chicago-talk at pm.org >>>>>> http://mail.pm.org/mailman/listinfo/chicago-talk >>>>>> -- Brian Katzung, Kappa Computer Solutions, LLC Leveraging UNIX, GNU/Linux, open source, and custom software solutions for business and beyond Phone: 877.367.8837 x1 http://www.kappacs.com From imranjj at gmail.com Tue Mar 9 11:59:44 2010 From: imranjj at gmail.com (imran javaid) Date: Tue, 9 Mar 2010 13:59:44 -0600 Subject: [Chicago-talk] concurrent processes? In-Reply-To: <4B96A7BB.2020704@kappacs.com> References: <20100309192954.F25B35F6@captain.xo.com> <4B96A7BB.2020704@kappacs.com> Message-ID: btw, in your original post you are running another perl interpreter inside the terminal and assigning a value to a variable. You will not be able to see that variable in your original program. the whole technique is a kluge. On Tue, Mar 9, 2010 at 1:55 PM, Brian Katzung wrote: > Richard, > > Did I miss part of the discussion? It seems as if we're throwing out "1 foot > solutions" without seeing the "30,000 foot view". > > How about if we take a few steps backwards. > > In the bigger picture, what are you trying to accomplish, and why do you > believe it requires launching an interactive windows session and a new > terminal window rather than just prompting in the original execution > context? > > ?- Brian > > Richard Reina wrote: >> >> That stops the error message but the rest of the program does not execute. >> >> >> ---- Chicago.pm chatter wrote: >> >>> >>> The man page of exec() explains this: >>> >>> Since it's a common mistake to use exec instead of system, Perl warns >>> you if there is a following statement which isn't die, warn, or exit >>> (if -w is set - but you always do that). If you really want to follow >>> an exec with some other statement, you can use one of these styles to >>> avoid the warning: >>> >>> ? ?exec ('foo') ? or print STDERR "couldn't exec foo: $!"; >>> ? ?{ exec ('foo') }; print STDERR "couldn't exec foo: $!"; >>> >>> >>> On Tue, Mar 9, 2010 at 12:37 PM, Richard Reina >>> wrote: >>> >>>> >>>> Shawn thanks for your reply. It looks promising but the program crashes >>>> with: >>>> >>>> Statement unlikely to be reached at test_exec.pl line 5. >>>> ? ? ? (Maybe you meant system() when you said exec()?) >>>> >>>> Do I need some added syntax to use exec? >>>> >>>> ---- Chicago.pm chatter wrote: >>>> >>>>> >>>>> Replace system w/ exec. ?system() forks, exec does not. >>>>> shawn.c.carroll at gmail.com >>>>> Perl Programmer >>>>> Soccer Referee >>>>> >>>>> >>>>> >>>>> On Tue, Mar 9, 2010 at 12:14, Richard Reina >>>>> wrote: >>>>> >>>>>> >>>>>> I have a program that opens a terminal so that the user can enter some >>>>>> info. ?Like this: >>>>>> >>>>>> >>>>>> system(q{gnome-terminal --geometry=80x12+0-30 -x perl -e 'require >>>>>> "./data_entry1.pl"; my $co=get_input();'}); >>>>>> >>>>>> # do something with $co >>>>>> >>>>>> The code works in that it opens a small terminal at the bottom of the >>>>>> screen where the user can enter info. ?However, the program continues to >>>>>> execute without waiting for the value of $co. Is there a way to make the >>>>>> program wait until the terminal session has been terminated so that the >>>>>> value of $co can be obtained? >>>>>> >>>>>> Been banging my head on this one since 6:30am so any help would be >>>>>> greatly appreciated. >>>>>> >>>>>> Thanks >>>>>> Richard >>>>>> >>>>>> >>>>>> >>>>>> ---- Chicago.pm chatter wrote: >>>>>> >>>>>>> >>>>>>> On Mar 8, 2010, at 7:27 AM, Richard Reina wrote: >>>>>>> >>>>>>> >>>>>>>> >>>>>>>> system("gnome-terminal -x perl -e 'print "Hello World\n"; sleep >>>>>>>> 4;'"); >>>>>>>> >>>>>>> >>>>>>> You have double quotes inside of that string. ?You need to do either: >>>>>>> >>>>>>> system("gnome-terminal -x perl -e 'print \"Hello World\n\"; sleep >>>>>>> 4;'"); >>>>>>> >>>>>>> or >>>>>>> >>>>>>> system(q{gnome-terminal -x perl -e 'print "Hello World\n"; sleep >>>>>>> 4;'}); >>>>>>> >>>>>>> -- >>>>>>> Andy Lester => andy at petdance.com => www.theworkinggeek.com => >>>>>>> AIM:petdance >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> _______________________________________________ >>>>>>> Chicago-talk mailing list >>>>>>> Chicago-talk at pm.org >>>>>>> http://mail.pm.org/mailman/listinfo/chicago-talk >>>>>>> > > -- > Brian Katzung, Kappa Computer Solutions, LLC > Leveraging UNIX, GNU/Linux, open source, and custom > software solutions for business and beyond > Phone: 877.367.8837 x1 ?http://www.kappacs.com > > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From imranjj at gmail.com Tue Mar 9 12:07:57 2010 From: imranjj at gmail.com (imran javaid) Date: Tue, 9 Mar 2010 14:07:57 -0600 Subject: [Chicago-talk] concurrent processes? In-Reply-To: References: <20100309192954.F25B35F6@captain.xo.com> <4B96A7BB.2020704@kappacs.com> Message-ID: Maybe what you are trying to do can be done better using perl/tk. Using that can open an input window for the user. The window could have an input box and an ok button, for example. On Tue, Mar 9, 2010 at 1:59 PM, imran javaid wrote: > btw, in your original post you are running another perl interpreter > inside the terminal and assigning a value to a variable. You will not > be able to see that variable in your original program. > the whole technique is a kluge. > > On Tue, Mar 9, 2010 at 1:55 PM, Brian Katzung wrote: >> Richard, >> >> Did I miss part of the discussion? It seems as if we're throwing out "1 foot >> solutions" without seeing the "30,000 foot view". >> >> How about if we take a few steps backwards. >> >> In the bigger picture, what are you trying to accomplish, and why do you >> believe it requires launching an interactive windows session and a new >> terminal window rather than just prompting in the original execution >> context? >> >> ?- Brian >> >> Richard Reina wrote: >>> >>> That stops the error message but the rest of the program does not execute. >>> >>> >>> ---- Chicago.pm chatter wrote: >>> >>>> >>>> The man page of exec() explains this: >>>> >>>> Since it's a common mistake to use exec instead of system, Perl warns >>>> you if there is a following statement which isn't die, warn, or exit >>>> (if -w is set - but you always do that). If you really want to follow >>>> an exec with some other statement, you can use one of these styles to >>>> avoid the warning: >>>> >>>> ? ?exec ('foo') ? or print STDERR "couldn't exec foo: $!"; >>>> ? ?{ exec ('foo') }; print STDERR "couldn't exec foo: $!"; >>>> >>>> >>>> On Tue, Mar 9, 2010 at 12:37 PM, Richard Reina >>>> wrote: >>>> >>>>> >>>>> Shawn thanks for your reply. It looks promising but the program crashes >>>>> with: >>>>> >>>>> Statement unlikely to be reached at test_exec.pl line 5. >>>>> ? ? ? (Maybe you meant system() when you said exec()?) >>>>> >>>>> Do I need some added syntax to use exec? >>>>> >>>>> ---- Chicago.pm chatter wrote: >>>>> >>>>>> >>>>>> Replace system w/ exec. ?system() forks, exec does not. >>>>>> shawn.c.carroll at gmail.com >>>>>> Perl Programmer >>>>>> Soccer Referee >>>>>> >>>>>> >>>>>> >>>>>> On Tue, Mar 9, 2010 at 12:14, Richard Reina >>>>>> wrote: >>>>>> >>>>>>> >>>>>>> I have a program that opens a terminal so that the user can enter some >>>>>>> info. ?Like this: >>>>>>> >>>>>>> >>>>>>> system(q{gnome-terminal --geometry=80x12+0-30 -x perl -e 'require >>>>>>> "./data_entry1.pl"; my $co=get_input();'}); >>>>>>> >>>>>>> # do something with $co >>>>>>> >>>>>>> The code works in that it opens a small terminal at the bottom of the >>>>>>> screen where the user can enter info. ?However, the program continues to >>>>>>> execute without waiting for the value of $co. Is there a way to make the >>>>>>> program wait until the terminal session has been terminated so that the >>>>>>> value of $co can be obtained? >>>>>>> >>>>>>> Been banging my head on this one since 6:30am so any help would be >>>>>>> greatly appreciated. >>>>>>> >>>>>>> Thanks >>>>>>> Richard >>>>>>> >>>>>>> >>>>>>> >>>>>>> ---- Chicago.pm chatter wrote: >>>>>>> >>>>>>>> >>>>>>>> On Mar 8, 2010, at 7:27 AM, Richard Reina wrote: >>>>>>>> >>>>>>>> >>>>>>>>> >>>>>>>>> system("gnome-terminal -x perl -e 'print "Hello World\n"; sleep >>>>>>>>> 4;'"); >>>>>>>>> >>>>>>>> >>>>>>>> You have double quotes inside of that string. ?You need to do either: >>>>>>>> >>>>>>>> system("gnome-terminal -x perl -e 'print \"Hello World\n\"; sleep >>>>>>>> 4;'"); >>>>>>>> >>>>>>>> or >>>>>>>> >>>>>>>> system(q{gnome-terminal -x perl -e 'print "Hello World\n"; sleep >>>>>>>> 4;'}); >>>>>>>> >>>>>>>> -- >>>>>>>> Andy Lester => andy at petdance.com => www.theworkinggeek.com => >>>>>>>> AIM:petdance >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> _______________________________________________ >>>>>>>> Chicago-talk mailing list >>>>>>>> Chicago-talk at pm.org >>>>>>>> http://mail.pm.org/mailman/listinfo/chicago-talk >>>>>>>> >> >> -- >> Brian Katzung, Kappa Computer Solutions, LLC >> Leveraging UNIX, GNU/Linux, open source, and custom >> software solutions for business and beyond >> Phone: 877.367.8837 x1 ?http://www.kappacs.com >> >> >> _______________________________________________ >> Chicago-talk mailing list >> Chicago-talk at pm.org >> http://mail.pm.org/mailman/listinfo/chicago-talk >> > From richard at rushlogistics.com Tue Mar 9 12:25:21 2010 From: richard at rushlogistics.com (richard at rushlogistics.com) Date: Tue, 9 Mar 2010 20:25:21 +0000 Subject: [Chicago-talk] concurrent processes? In-Reply-To: References: <20100309192954.F25B35F6@captain.xo.com><4B96A7BB.2020704@kappacs.com> Message-ID: <842210494-1268166459-cardhu_decombobulator_blackberry.rim.net-230634683-@bda2622.bisx.prod.on.blackberry> The reason I am launching it in another window is so that the user can enter the info in a small window data entry window at the bottom of the screen while still being able to see an image that is open in the background being viewed via evince. Sent via my BlackBerry. Ignore all the typos. -----Original Message----- From: imran javaid Date: Tue, 9 Mar 2010 14:07:57 To: Chicago.pm chatter Subject: Re: [Chicago-talk] concurrent processes? Maybe what you are trying to do can be done better using perl/tk. Using that can open an input window for the user. The window could have an input box and an ok button, for example. On Tue, Mar 9, 2010 at 1:59 PM, imran javaid wrote: > btw, in your original post you are running another perl interpreter > inside the terminal and assigning a value to a variable. You will not > be able to see that variable in your original program. > the whole technique is a kluge. > > On Tue, Mar 9, 2010 at 1:55 PM, Brian Katzung wrote: >> Richard, >> >> Did I miss part of the discussion? It seems as if we're throwing out "1 foot >> solutions" without seeing the "30,000 foot view". >> >> How about if we take a few steps backwards. >> >> In the bigger picture, what are you trying to accomplish, and why do you >> believe it requires launching an interactive windows session and a new >> terminal window rather than just prompting in the original execution >> context? >> >> ?- Brian >> >> Richard Reina wrote: >>> >>> That stops the error message but the rest of the program does not execute. >>> >>> >>> ---- Chicago.pm chatter wrote: >>> >>>> >>>> The man page of exec() explains this: >>>> >>>> Since it's a common mistake to use exec instead of system, Perl warns >>>> you if there is a following statement which isn't die, warn, or exit >>>> (if -w is set - but you always do that). If you really want to follow >>>> an exec with some other statement, you can use one of these styles to >>>> avoid the warning: >>>> >>>> ? ?exec ('foo') ? or print STDERR "couldn't exec foo: $!"; >>>> ? ?{ exec ('foo') }; print STDERR "couldn't exec foo: $!"; >>>> >>>> >>>> On Tue, Mar 9, 2010 at 12:37 PM, Richard Reina >>>> wrote: >>>> >>>>> >>>>> Shawn thanks for your reply. It looks promising but the program crashes >>>>> with: >>>>> >>>>> Statement unlikely to be reached at test_exec.pl line 5. >>>>> ? ? ? (Maybe you meant system() when you said exec()?) >>>>> >>>>> Do I need some added syntax to use exec? >>>>> >>>>> ---- Chicago.pm chatter wrote: >>>>> >>>>>> >>>>>> Replace system w/ exec. ?system() forks, exec does not. >>>>>> shawn.c.carroll at gmail.com >>>>>> Perl Programmer >>>>>> Soccer Referee >>>>>> >>>>>> >>>>>> >>>>>> On Tue, Mar 9, 2010 at 12:14, Richard Reina >>>>>> wrote: >>>>>> >>>>>>> >>>>>>> I have a program that opens a terminal so that the user can enter some >>>>>>> info. ?Like this: >>>>>>> >>>>>>> >>>>>>> system(q{gnome-terminal --geometry=80x12+0-30 -x perl -e 'require >>>>>>> "./data_entry1.pl"; my $co=get_input();'}); >>>>>>> >>>>>>> # do something with $co >>>>>>> >>>>>>> The code works in that it opens a small terminal at the bottom of the >>>>>>> screen where the user can enter info. ?However, the program continues to >>>>>>> execute without waiting for the value of $co. Is there a way to make the >>>>>>> program wait until the terminal session has been terminated so that the >>>>>>> value of $co can be obtained? >>>>>>> >>>>>>> Been banging my head on this one since 6:30am so any help would be >>>>>>> greatly appreciated. >>>>>>> >>>>>>> Thanks >>>>>>> Richard >>>>>>> >>>>>>> >>>>>>> >>>>>>> ---- Chicago.pm chatter wrote: >>>>>>> >>>>>>>> >>>>>>>> On Mar 8, 2010, at 7:27 AM, Richard Reina wrote: >>>>>>>> >>>>>>>> >>>>>>>>> >>>>>>>>> system("gnome-terminal -x perl -e 'print "Hello World\n"; sleep >>>>>>>>> 4;'"); >>>>>>>>> >>>>>>>> >>>>>>>> You have double quotes inside of that string. ?You need to do either: >>>>>>>> >>>>>>>> system("gnome-terminal -x perl -e 'print \"Hello World\n\"; sleep >>>>>>>> 4;'"); >>>>>>>> >>>>>>>> or >>>>>>>> >>>>>>>> system(q{gnome-terminal -x perl -e 'print "Hello World\n"; sleep >>>>>>>> 4;'}); >>>>>>>> >>>>>>>> -- >>>>>>>> Andy Lester => andy at petdance.com => www.theworkinggeek.com => >>>>>>>> AIM:petdance >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>>_______________________________________________ >>>>>>>> Chicago-talk mailing list >>>>>>>> Chicago-talk at pm.org >>>>>>>> http://mail.pm.org/mailman/listinfo/chicago-talk >>>>>>>> >> >> -- >> Brian Katzung, Kappa Computer Solutions, LLC >> Leveraging UNIX, GNU/Linux, open source, and custom >> software solutions for business and beyond >> Phone: 877.367.8837 x1 ?http://www.kappacs.com >> >> >>_______________________________________________ >> Chicago-talk mailing list >> Chicago-talk at pm.org >> http://mail.pm.org/mailman/listinfo/chicago-talk >> > _______________________________________________ Chicago-talk mailing list Chicago-talk at pm.org http://mail.pm.org/mailman/listinfo/chicago-talk From imranjj at gmail.com Tue Mar 9 12:36:07 2010 From: imranjj at gmail.com (imran javaid) Date: Tue, 9 Mar 2010 14:36:07 -0600 Subject: [Chicago-talk] concurrent processes? In-Reply-To: <842210494-1268166459-cardhu_decombobulator_blackberry.rim.net-230634683-@bda2622.bisx.prod.on.blackberry> References: <20100309192954.F25B35F6@captain.xo.com> <4B96A7BB.2020704@kappacs.com> <842210494-1268166459-cardhu_decombobulator_blackberry.rim.net-230634683-@bda2622.bisx.prod.on.blackberry> Message-ID: check out the "label and textinput" example in this web page: http://lena.franken.de/perl_hier/perltk_examples/index.html On Tue, Mar 9, 2010 at 2:25 PM, wrote: > The reason I am launching it in another window is so that the user can enter the info in a small window data entry window at the bottom of the screen while still being able to see an image that is open in the background being viewed via evince. > Sent via my BlackBerry. Ignore all the typos. > > -----Original Message----- > From: imran javaid > Date: Tue, 9 Mar 2010 14:07:57 > To: Chicago.pm chatter > Subject: Re: [Chicago-talk] concurrent processes? > > Maybe what you are trying to do can be done better using perl/tk. > Using that can open an input window for the user. The window could > have an input box and an ok button, for example. > > On Tue, Mar 9, 2010 at 1:59 PM, imran javaid wrote: >> btw, in your original post you are running another perl interpreter >> inside the terminal and assigning a value to a variable. You will not >> be able to see that variable in your original program. >> the whole technique is a kluge. >> >> On Tue, Mar 9, 2010 at 1:55 PM, Brian Katzung wrote: >>> Richard, >>> >>> Did I miss part of the discussion? It seems as if we're throwing out "1 foot >>> solutions" without seeing the "30,000 foot view". >>> >>> How about if we take a few steps backwards. >>> >>> In the bigger picture, what are you trying to accomplish, and why do you >>> believe it requires launching an interactive windows session and a new >>> terminal window rather than just prompting in the original execution >>> context? >>> >>> ?- Brian >>> >>> Richard Reina wrote: >>>> >>>> That stops the error message but the rest of the program does not execute. >>>> >>>> >>>> ---- Chicago.pm chatter wrote: >>>> >>>>> >>>>> The man page of exec() explains this: >>>>> >>>>> Since it's a common mistake to use exec instead of system, Perl warns >>>>> you if there is a following statement which isn't die, warn, or exit >>>>> (if -w is set - but you always do that). If you really want to follow >>>>> an exec with some other statement, you can use one of these styles to >>>>> avoid the warning: >>>>> >>>>> ? ?exec ('foo') ? or print STDERR "couldn't exec foo: $!"; >>>>> ? ?{ exec ('foo') }; print STDERR "couldn't exec foo: $!"; >>>>> >>>>> >>>>> On Tue, Mar 9, 2010 at 12:37 PM, Richard Reina >>>>> wrote: >>>>> >>>>>> >>>>>> Shawn thanks for your reply. It looks promising but the program crashes >>>>>> with: >>>>>> >>>>>> Statement unlikely to be reached at test_exec.pl line 5. >>>>>> ? ? ? (Maybe you meant system() when you said exec()?) >>>>>> >>>>>> Do I need some added syntax to use exec? >>>>>> >>>>>> ---- Chicago.pm chatter wrote: >>>>>> >>>>>>> >>>>>>> Replace system w/ exec. ?system() forks, exec does not. >>>>>>> shawn.c.carroll at gmail.com >>>>>>> Perl Programmer >>>>>>> Soccer Referee >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Tue, Mar 9, 2010 at 12:14, Richard Reina >>>>>>> wrote: >>>>>>> >>>>>>>> >>>>>>>> I have a program that opens a terminal so that the user can enter some >>>>>>>> info. ?Like this: >>>>>>>> >>>>>>>> >>>>>>>> system(q{gnome-terminal --geometry=80x12+0-30 -x perl -e 'require >>>>>>>> "./data_entry1.pl"; my $co=get_input();'}); >>>>>>>> >>>>>>>> # do something with $co >>>>>>>> >>>>>>>> The code works in that it opens a small terminal at the bottom of the >>>>>>>> screen where the user can enter info. ?However, the program continues to >>>>>>>> execute without waiting for the value of $co. Is there a way to make the >>>>>>>> program wait until the terminal session has been terminated so that the >>>>>>>> value of $co can be obtained? >>>>>>>> >>>>>>>> Been banging my head on this one since 6:30am so any help would be >>>>>>>> greatly appreciated. >>>>>>>> >>>>>>>> Thanks >>>>>>>> Richard >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> ---- Chicago.pm chatter wrote: >>>>>>>> >>>>>>>>> >>>>>>>>> On Mar 8, 2010, at 7:27 AM, Richard Reina wrote: >>>>>>>>> >>>>>>>>> >>>>>>>>>> >>>>>>>>>> system("gnome-terminal -x perl -e 'print "Hello World\n"; sleep >>>>>>>>>> 4;'"); >>>>>>>>>> >>>>>>>>> >>>>>>>>> You have double quotes inside of that string. ?You need to do either: >>>>>>>>> >>>>>>>>> system("gnome-terminal -x perl -e 'print \"Hello World\n\"; sleep >>>>>>>>> 4;'"); >>>>>>>>> >>>>>>>>> or >>>>>>>>> >>>>>>>>> system(q{gnome-terminal -x perl -e 'print "Hello World\n"; sleep >>>>>>>>> 4;'}); >>>>>>>>> >>>>>>>>> -- >>>>>>>>> Andy Lester => andy at petdance.com => www.theworkinggeek.com => >>>>>>>>> AIM:petdance >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>>_______________________________________________ >>>>>>>>> Chicago-talk mailing list >>>>>>>>> Chicago-talk at pm.org >>>>>>>>> http://mail.pm.org/mailman/listinfo/chicago-talk >>>>>>>>> >>> >>> -- >>> Brian Katzung, Kappa Computer Solutions, LLC >>> Leveraging UNIX, GNU/Linux, open source, and custom >>> software solutions for business and beyond >>> Phone: 877.367.8837 x1 ?http://www.kappacs.com >>> >>> >>>_______________________________________________ >>> Chicago-talk mailing list >>> Chicago-talk at pm.org >>> http://mail.pm.org/mailman/listinfo/chicago-talk >>> >> > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From richard at rushlogistics.com Tue Mar 9 19:20:53 2010 From: richard at rushlogistics.com (Richard Reina) Date: Tue, 09 Mar 2010 22:20:53 -0500 (EST) Subject: [Chicago-talk] concurrent processes w/ Perl Tk In-Reply-To: <20100309192954.F25B35F6@captain.xo.com> <4B96A7BB.2020704@kappacs.com> <842210494-1268166459-cardhu_decombobulator_blackberry.rim.net-230634683-@bda2622.bisx.prod.on.blackberry> Message-ID: <20100310032054.12D88229B@bellona.xo.com> Imran, Thank you very much for you perlTk suggestion. I've been playing around with it and I like it. However, I have one big problem. I can't figure out how I can get the the values from buttons returned as a array or scalar. I execute the program and whoof! Where did the values I just selected go? If anyone has sample code of a very simple button that returns value, I would really appreciate it? Thanks ---- Chicago.pm chatter wrote: > > check out the "label and textinput" example in this web page: > http://lena.franken.de/perl_hier/perltk_examples/index.html > > On Tue, Mar 9, 2010 at 2:25 PM, wrote: > > The reason I am launching it in another window is so that the user can enter the info in a small window data entry window at the bottom of the screen while still being able to see an image that is open in the background being viewed via evince. > > Sent via my BlackBerry. Ignore all the typos. > > > > -----Original Message----- > > From: imran javaid > > Date: Tue, 9 Mar 2010 14:07:57 > > To: Chicago.pm chatter > > Subject: Re: [Chicago-talk] concurrent processes? > > > > Maybe what you are trying to do can be done better using perl/tk. > > Using that can open an input window for the user. The window could > > have an input box and an ok button, for example. > > > > On Tue, Mar 9, 2010 at 1:59 PM, imran javaid wrote: > >> btw, in your original post you are running another perl interpreter > >> inside the terminal and assigning a value to a variable. You will not > >> be able to see that variable in your original program. > >> the whole technique is a kluge. > >> > >> On Tue, Mar 9, 2010 at 1:55 PM, Brian Katzung wrote: > >>> Richard, > >>> > >>> Did I miss part of the discussion? It seems as if we're throwing out "1 foot > >>> solutions" without seeing the "30,000 foot view". > >>> > >>> How about if we take a few steps backwards. > >>> > >>> In the bigger picture, what are you trying to accomplish, and why do you > >>> believe it requires launching an interactive windows session and a new > >>> terminal window rather than just prompting in the original execution > >>> context? > >>> > >>> ?- Brian > >>> > >>> Richard Reina wrote: > >>>> > >>>> That stops the error message but the rest of the program does not execute. > >>>> > >>>> > >>>> ---- Chicago.pm chatter wrote: > >>>> > >>>>> > >>>>> The man page of exec() explains this: > >>>>> > >>>>> Since it's a common mistake to use exec instead of system, Perl warns > >>>>> you if there is a following statement which isn't die, warn, or exit > >>>>> (if -w is set - but you always do that). If you really want to follow > >>>>> an exec with some other statement, you can use one of these styles to > >>>>> avoid the warning: > >>>>> > >>>>> ? ?exec ('foo') ? or print STDERR "couldn't exec foo: $!"; > >>>>> ? ?{ exec ('foo') }; print STDERR "couldn't exec foo: $!"; > >>>>> > >>>>> > >>>>> On Tue, Mar 9, 2010 at 12:37 PM, Richard Reina > >>>>> wrote: > >>>>> > >>>>>> > >>>>>> Shawn thanks for your reply. It looks promising but the program crashes > >>>>>> with: > >>>>>> > >>>>>> Statement unlikely to be reached at test_exec.pl line 5. > >>>>>> ? ? ? (Maybe you meant system() when you said exec()?) > >>>>>> > >>>>>> Do I need some added syntax to use exec? > >>>>>> > >>>>>> ---- Chicago.pm chatter wrote: > >>>>>> > >>>>>>> > >>>>>>> Replace system w/ exec. ?system() forks, exec does not. > >>>>>>> shawn.c.carroll at gmail.com > >>>>>>> Perl Programmer > >>>>>>> Soccer Referee > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> On Tue, Mar 9, 2010 at 12:14, Richard Reina > >>>>>>> wrote: > >>>>>>> > >>>>>>>> > >>>>>>>> I have a program that opens a terminal so that the user can enter some > >>>>>>>> info. ?Like this: > >>>>>>>> > >>>>>>>> > >>>>>>>> system(q{gnome-terminal --geometry=80x12+0-30 -x perl -e 'require > >>>>>>>> "./data_entry1.pl"; my $co=get_input();'}); > >>>>>>>> > >>>>>>>> # do something with $co > >>>>>>>> > >>>>>>>> The code works in that it opens a small terminal at the bottom of the > >>>>>>>> screen where the user can enter info. ?However, the program continues to > >>>>>>>> execute without waiting for the value of $co. Is there a way to make the > >>>>>>>> program wait until the terminal session has been terminated so that the > >>>>>>>> value of $co can be obtained? > >>>>>>>> > >>>>>>>> Been banging my head on this one since 6:30am so any help would be > >>>>>>>> greatly appreciated. > >>>>>>>> > >>>>>>>> Thanks > >>>>>>>> Richard > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> ---- Chicago.pm chatter wrote: > >>>>>>>> > >>>>>>>>> > >>>>>>>>> On Mar 8, 2010, at 7:27 AM, Richard Reina wrote: > >>>>>>>>> > >>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> system("gnome-terminal -x perl -e 'print "Hello World\n"; sleep > >>>>>>>>>> 4;'"); > >>>>>>>>>> > >>>>>>>>> > >>>>>>>>> You have double quotes inside of that string. ?You need to do either: > >>>>>>>>> > >>>>>>>>> system("gnome-terminal -x perl -e 'print \"Hello World\n\"; sleep > >>>>>>>>> 4;'"); > >>>>>>>>> > >>>>>>>>> or > >>>>>>>>> > >>>>>>>>> system(q{gnome-terminal -x perl -e 'print "Hello World\n"; sleep > >>>>>>>>> 4;'}); > >>>>>>>>> > >>>>>>>>> -- > >>>>>>>>> Andy Lester => andy at petdance.com => www.theworkinggeek.com => > >>>>>>>>> AIM:petdance > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>>_______________________________________________ > >>>>>>>>> Chicago-talk mailing list > >>>>>>>>> Chicago-talk at pm.org > >>>>>>>>> http://mail.pm.org/mailman/listinfo/chicago-talk > >>>>>>>>> > >>> > >>> -- > >>> Brian Katzung, Kappa Computer Solutions, LLC > >>> Leveraging UNIX, GNU/Linux, open source, and custom > >>> software solutions for business and beyond > >>> Phone: 877.367.8837 x1 ?http://www.kappacs.com > >>> > >>> > >>>_______________________________________________ > >>> Chicago-talk mailing list > >>> Chicago-talk at pm.org > >>> http://mail.pm.org/mailman/listinfo/chicago-talk > >>> > >> > > _______________________________________________ > > Chicago-talk mailing list > > Chicago-talk at pm.org > > http://mail.pm.org/mailman/listinfo/chicago-talk > > _______________________________________________ > > Chicago-talk mailing list > > Chicago-talk at pm.org > > http://mail.pm.org/mailman/listinfo/chicago-talk > > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From imranjj at gmail.com Tue Mar 9 21:37:50 2010 From: imranjj at gmail.com (imran javaid) Date: Tue, 9 Mar 2010 23:37:50 -0600 Subject: [Chicago-talk] concurrent processes w/ Perl Tk In-Reply-To: <20100310032054.12D88229B@bellona.xo.com> References: <20100309192954.F25B35F6@captain.xo.com> <4B96A7BB.2020704@kappacs.com> <842210494-1268166459-cardhu_decombobulator_blackberry.rim.net-230634683-@bda2622.bisx.prod.on.blackberry> <20100310032054.12D88229B@bellona.xo.com> Message-ID: try this (it is a better version of the link i suggested earlier): use strict; use Tk; my $animal = getInput(); print $animal; sub getInput { my $input = ""; my $mw = MainWindow->new; # Mainwindow: sizex/y, positionx/y $mw->geometry("320x50+100+120"); # A label to show what to type in my $label = $mw->Label( -text => 'Your animal:', ); $label->place( -x => 5, -y => 10); # This is the text-userinput field my $entry = $mw->Text( # width is in characters, not pixel -width => 20, -height => 1, ); $entry->place( -x => 80, -y => 10); my $button = $mw->Button( -text => 'Submit', -width => 8, -command => sub { chomp($input = $entry->Contents); destroy $mw; }, ); $button->place( -x => 230, -y => 10); MainLoop; return $input; } On Tue, Mar 9, 2010 at 9:20 PM, Richard Reina wrote: > Imran, > > Thank you very much for you perlTk suggestion. ?I've been playing around with it and I like it. ?However, I have one big problem. I can't figure out how I can get the the values from buttons returned as a array or scalar. I execute the program and whoof! Where did the values I just selected go? If anyone has sample code of a very simple button that returns value, I would really appreciate it? > > Thanks From richard at rushlogistics.com Thu Mar 11 05:14:59 2010 From: richard at rushlogistics.com (Richard Reina) Date: Thu, 11 Mar 2010 08:14:59 -0500 (EST) Subject: [Chicago-talk] concurrent processes w/ Perl Tk In-Reply-To: <20100309192954.F25B35F6@captain.xo.com> <4B96A7BB.2020704@kappacs.com> <842210494-1268166459-cardhu_decombobulator_blackberry.rim.net-230634683-@bda2622.bisx.prod.on.blackberry> <20100310032054.12D88229B@bellona.xo.com> Message-ID: <20100311131459.93FBB3E98@courageux.xo.com> Imran, Thanks very much for the help. ---- Chicago.pm chatter wrote: > > try this (it is a better version of the link i suggested earlier): > > use strict; > use Tk; > > my $animal = getInput(); > print $animal; > > sub getInput { > my $input = ""; > > my $mw = MainWindow->new; > # Mainwindow: sizex/y, positionx/y > $mw->geometry("320x50+100+120"); > > # A label to show what to type in > my $label = $mw->Label( > -text => 'Your animal:', > ); > $label->place( -x => 5, -y => 10); > > # This is the text-userinput field > my $entry = $mw->Text( > # width is in characters, not pixel > -width => 20, > -height => 1, > ); > $entry->place( -x => 80, -y => 10); > > my $button = $mw->Button( > -text => 'Submit', > -width => 8, > -command => sub { chomp($input = $entry->Contents); destroy $mw; }, > ); > $button->place( -x => 230, -y => 10); > > MainLoop; > return $input; > } > > > On Tue, Mar 9, 2010 at 9:20 PM, Richard Reina wrote: > > Imran, > > > > Thank you very much for you perlTk suggestion. ?I've been playing around with it and I like it. ?However, I have one big problem. I can't figure out how I can get the the values from buttons returned as a array or scalar. I execute the program and whoof! Where did the values I just selected go? If anyone has sample code of a very simple button that returns value, I would really appreciate it? > > > > Thanks > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From richard at rushlogistics.com Thu Mar 11 05:39:25 2010 From: richard at rushlogistics.com (Richard Reina) Date: Thu, 11 Mar 2010 08:39:25 -0500 (EST) Subject: [Chicago-talk] =?utf-8?q?system_command_to_kill_Xwindows_session?= =?utf-8?q?=3F?= In-Reply-To: <20100307163334.32983328@victory.xo.com> Message-ID: <20100311133925.A63E46B6F@atlas.xo.com> Hello Jonathon, Thanks again for your suggestions. I was reading up on Xvfb and I not sure I understand what it will and won't do. What I need is to give a user working in console mode to the ability to view a multi-page tiff file and save it. This is something I currently do in Xwindows using evince. Will a Xvfb session allow for that? If not is the code you included below a good way to go about something like that? Thanks, Richard ---- Chicago.pm chatter wrote: > > OK, so here are my thoughts on this issue. > > "startx" has way too much baggage for an automated process. Do you > really want the X server to load, take over the screen and keyboard, and > wait for default system window manager (like a full GNOME session) to > load... or do you just want to run some script that requires an X > server? > > In the first case, sure, use startx. But isn't the user going to be > confused when the X server randomly dies without saving his session? > > If you just want an interactive Xserver, though, just run "X :1" or > whatever, and then set DISPLAY to ":1". When you don't want X anymore, > just send it SIGTERM or whatever. > > But in most cases, you don't actually need a real Xserver that touches > the hardware; you can just use Xvfb and connect your clients to that. > Then there is no interference with the host machine. > > http://en.wikipedia.org/wiki/Xvfb > > Any time I have ever needed an X server for an automated process, Xvfb > has been what I've needed. It works like a real X server, except it > doesn't touch the real hardware. > > Finally, stop fighting with hacks around system and qx. If you need to > start a real background process, use a module like AnyEvent::Subprocess: > > my $done = AnyEvent->condvar; > my $job = AnyEvent::Subprocess->new( > code => [qw/Xvfb :1234/], > on_completion => sub { say 'X server exited with status '. $_[0]->exit_status }, > ); > > my $proc = $job->run; > $ENV{DISPLAY} = ':1234'; > ; > $proc->kill('TERM'); > > Much cleaner. > > Regards, > Jonathan Rockway > > * On Sun, Mar 07 2010, Richard Reina wrote: > > Linux. Sorry. > > ---- Chicago.pm chatter wrote: > >> > >> You didn't telll me if you are on UNIX. > >> > >> The "startx" script has to give you the PID, which it currently isn't doing, > >> and then you have to gather the PID. > >> > >> In "startx", assuming Unix > >> > >> $!/bin/ksh > >> Foobar & > >> echo $! > >> > >> I assume you are using the '&' to background "Foobar". The '$!' gives you > >> pid of background job, but must be immediately following "Foobar &" command. > >> > >> In Perl, you gather the echoed PID by using "qx" instead of system() > >> > >> my $thePid = qx/startx/; > >> > >> Now you can kill $thePid. > >> > >> Got to go. Goodluck, bye. > >> > >> Alexander > >> > >> -----Original Message----- > >> From: chicago-talk-bounces+danel=speakeasy.net at pm.org > >> [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of > >> Richard Reina > >> Sent: Sunday, March 07, 2010 10:06 AM > >> To: Chicago.pm chatter > >> Subject: Re: [Chicago-talk]system command to kill Xwindows session? > >> > >> I have script that starts an xwindows session with system("startx") I want > >> it to end as soon as a specific tast is done? > >> > >> > >> ---- Chicago.pm chatter wrote: > >> > > >> > Your question is incoherent; obviously if you are looking for a system > >> > command, then its not a Perl function. > >> > > >> > How did you start the process that opened the window, and are you willing > >> to > >> > kill the entire process? > >> > > >> > On Unix, if you know the process-id, then try: > >> > > >> > system("kill TERM $thePid"); > >> > > >> > Alexander > >> > > >> > -----Original Message----- > >> > From: chicago-talk-bounces+danel=speakeasy.net at pm.org > >> > [mailto:chicago-talk-bounces+danel=speakeasy.net at pm.org] On Behalf Of > >> > Richard Reina > >> > Sent: Sunday, March 07, 2010 9:18 AM > >> > To: chicago-talk at pm.org > >> > Subject: [Chicago-talk] system command to kill Xwindows session? > >> > > >> > Does anyone know if there is a perl fucntion or a command that can be put > >> > into system("") that will kill Xwindow and return a script/user to the > >> > console? > >> > > >> > Thanks, > >> > > >> > Richard > >> > _______________________________________________ > >> > Chicago-talk mailing list > >> > Chicago-talk at pm.org > >> > http://mail.pm.org/mailman/listinfo/chicago-talk > >> > > >> > _______________________________________________ > >> > Chicago-talk mailing list > >> > Chicago-talk at pm.org > >> > http://mail.pm.org/mailman/listinfo/chicago-talk > >> > > >> _______________________________________________ > >> Chicago-talk mailing list > >> Chicago-talk at pm.org > >> http://mail.pm.org/mailman/listinfo/chicago-talk > >> > >> _______________________________________________ > >> Chicago-talk mailing list > >> Chicago-talk at pm.org > >> http://mail.pm.org/mailman/listinfo/chicago-talk > >> > > _______________________________________________ > > Chicago-talk mailing list > > Chicago-talk at pm.org > > http://mail.pm.org/mailman/listinfo/chicago-talk > > -- > print just => another => perl => hacker => if $,=$" > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From lembark at wrkhors.com Wed Mar 10 22:28:52 2010 From: lembark at wrkhors.com (Steven Lembark) Date: Thu, 11 Mar 2010 01:28:52 -0500 Subject: [Chicago-talk] concurrent processes w/ Perl Tk In-Reply-To: <20100310032054.12D88229B@bellona.xo.com> References: <842210494-1268166459-cardhu_decombobulator_blackberry.rim.net-230634683-@bda2622.bisx.prod.on.blackberry> <20100310032054.12D88229B@bellona.xo.com> Message-ID: <20100311012852.1f7b448elembark@wrkhors.com@wrkhors.com> On Tue, 09 Mar 2010 22:20:53 -0500 (EST) Richard Reina wrote: > Thank you very much for you perlTk > suggestion. I've been playing around with it > and I like it. However, I have one big > problem. I can't figure out how I can get the > the values from buttons returned as a array or > scalar. I execute the program and whoof! Where > did the values I just selected go? If anyone > has sample code of a very simple button that > returns value, I would really appreciate it? Both on Safari. -- Steven Lembark 85-09 90th St. Workhorse Computing Woodhaven, NY, 11421 lembark at wrkhors.com +1 888 359 3508 From jon-chicagotalk at jrock.us Sat Mar 13 18:02:14 2010 From: jon-chicagotalk at jrock.us (Jonathan Rockway) Date: Sat, 13 Mar 2010 20:02:14 -0600 Subject: [Chicago-talk] system command to kill Xwindows session? In-Reply-To: <20100311133925.A63E46B6F@atlas.xo.com> (Richard Reina's message of "Thu, 11 Mar 2010 08:39:25 -0500 (EST)") References: <20100311133925.A63E46B6F@atlas.xo.com> Message-ID: <87wrxfhd95.fsf@snowball2.jrock.us> * On Thu, Mar 11 2010, Richard Reina wrote: > Hello Jonathan, > > Thanks again for your suggestions. I was reading up on Xvfb and I not > sure I understand what it will and won't do. What I need is to give a > user working in console mode to the ability to view a multi-page tiff > file and save it. This is something I currently do in Xwindows using > evince. Will a Xvfb session allow for that? If not is the code you > included below a good way to go about something like that? Nope, that's not what Xvfb will do. Xvfb will act as an X server for applications that don't need to display something or accept keyboard input from the user. If you actually want something to show up on the screen, it's not the right solution. So my question now is: Why is the user working at a console instead of in an X session? It is pretty strange to startup an entire X session every time you need to view an image. If you want to have a command-line inside X, use xterm or equivalent. Make it fill the screen and pick a big font, and it will look exactly like the console. Except your program doesn't need to worry about starting X anymore. Regards, Jonathan Rockway -- print just => another => perl => hacker => if $,=$" From warren.lindsey at gmail.com Sun Mar 14 09:30:35 2010 From: warren.lindsey at gmail.com (Warren Lindsey) Date: Sun, 14 Mar 2010 11:30:35 -0500 Subject: [Chicago-talk] system command to kill Xwindows session? In-Reply-To: <87wrxfhd95.fsf@snowball2.jrock.us> References: <20100311133925.A63E46B6F@atlas.xo.com> <87wrxfhd95.fsf@snowball2.jrock.us> Message-ID: <1434D719-CB6B-4963-B7CB-A3185CF191A8@gmail.com> I suggest you checkout zgv. It does not require X and will display pix fullscreen passed from command line. I use it on and old laptop to display pix from a webcam. On Mar 13, 2010, at 8:02 PM, Jonathan Rockway wrote: > * On Thu, Mar 11 2010, Richard Reina wrote: >> Hello Jonathan, >> >> Thanks again for your suggestions. I was reading up on Xvfb and I >> not >> sure I understand what it will and won't do. What I need is to >> give a >> user working in console mode to the ability to view a multi-page tiff >> file and save it. This is something I currently do in Xwindows using >> evince. Will a Xvfb session allow for that? If not is the code you >> included below a good way to go about something like that? > > Nope, that's not what Xvfb will do. Xvfb will act as an X server for > applications that don't need to display something or accept keyboard > input from the user. If you actually want something to show up on the > screen, it's not the right solution. > > So my question now is: Why is the user working at a console instead of > in an X session? It is pretty strange to startup an entire X session > every time you need to view an image. If you want to have a > command-line inside X, use xterm or equivalent. Make it fill the > screen > and pick a big font, and it will look exactly like the console. > Except > your program doesn't need to worry about starting X anymore. > > Regards, > Jonathan Rockway > > -- > print just => another => perl => hacker => if $,=$" > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk From richard at rushlogistics.com Sun Mar 14 09:49:30 2010 From: richard at rushlogistics.com (richard at rushlogistics.com) Date: Sun, 14 Mar 2010 16:49:30 +0000 Subject: [Chicago-talk] system command to kill Xwindows session? In-Reply-To: <1434D719-CB6B-4963-B7CB-A3185CF191A8@gmail.com> References: <20100311133925.A63E46B6F@atlas.xo.com><87wrxfhd95.fsf@snowball2.jrock.us><1434D719-CB6B-4963-B7CB-A3185CF191A8@gmail.com> Message-ID: <1407894478-1268585470-cardhu_decombobulator_blackberry.rim.net-102962038-@bda2622.bisx.prod.on.blackberry> Thanks for the idea. Do you know if it works for multipage tiff files? Thanks. Sent via my BlackBerry. Ignore all the typos. -----Original Message----- From: Warren Lindsey Date: Sun, 14 Mar 2010 11:30:35 To: Chicago.pm chatter Cc: Chicago.pm chatter Subject: Re: [Chicago-talk] system command to kill Xwindows session? I suggest you checkout zgv. It does not require X and will display pix fullscreen passed from command line. I use it on and old laptop to display pix from a webcam. On Mar 13, 2010, at 8:02 PM, Jonathan Rockway wrote: > * On Thu, Mar 11 2010, Richard Reina wrote: >> Hello Jonathan, >> >> Thanks again for your suggestions. I was reading up on Xvfb and I >> not >> sure I understand what it will and won't do. What I need is to >> give a >> user working in console mode to the ability to view a multi-page tiff >> file and save it. This is something I currently do in Xwindows using >> evince. Will a Xvfb session allow for that? If not is the code you >> included below a good way to go about something like that? > > Nope, that's not what Xvfb will do. Xvfb will act as an X server for > applications that don't need to display something or accept keyboard > input from the user. If you actually want something to show up on the > screen, it's not the right solution. > > So my question now is: Why is the user working at a console instead of > in an X session? It is pretty strange to startup an entire X session > every time you need to view an image. If you want to have a > command-line inside X, use xterm or equivalent. Make it fill the > screen > and pick a big font, and it will look exactly like the console. > Except > your program doesn't need to worry about starting X anymore. > > Regards, > Jonathan Rockway > > -- > print just => another => perl => hacker => if $,=$" > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk _______________________________________________ Chicago-talk mailing list Chicago-talk at pm.org http://mail.pm.org/mailman/listinfo/chicago-talk From richard at rushlogistics.com Tue Mar 16 09:59:53 2010 From: richard at rushlogistics.com (Richard Reina) Date: Tue, 16 Mar 2010 12:59:53 -0400 (EDT) Subject: [Chicago-talk] problem installing module Message-ID: <20100316165954.15C94300@victory.xo.com> I am having trouble installing Term::ReadKey something I've done easily in the past. When I try: perl -MCPAN -e 'install Term::ReadKey;' I get Can't locate object method "install" via package Term::ReadKey at e line 1. Would anyone happen to know what I am doing wrong? Thanks Richard From Andy_Bach at wiwb.uscourts.gov Tue Mar 16 10:25:10 2010 From: Andy_Bach at wiwb.uscourts.gov (Andy_Bach at wiwb.uscourts.gov) Date: Tue, 16 Mar 2010 12:25:10 -0500 Subject: [Chicago-talk] problem installing module In-Reply-To: <20100316165954.15C94300@victory.xo.com> References: <20100316165954.15C94300@victory.xo.com> Message-ID: I've always done -e 'shell' or just 'cpan' but perldoc CPAN says: Basic commands: # Modules: cpan> install Acme::Meta # in the shell CPAN::Shell->install("Acme::Meta"); # in perl so # perl -MCPAN -e 'CPAN::Shell->install("Term::ReadKey");' works. a ---------------------- Andy Bach Systems Mangler Internet: andy_bach at wiwb.uscourts.gov Voice: (608) 261-5738; Cell: (608) 658-1890 Any sufficiently advanced bug is indistinguishable from a feature. -- Rich Kulawiec -------------- next part -------------- An HTML attachment was scrubbed... URL: From richard at rushlogistics.com Tue Mar 16 10:40:59 2010 From: richard at rushlogistics.com (Richard Reina) Date: Tue, 16 Mar 2010 13:40:59 -0400 (EDT) Subject: [Chicago-talk] problem installing module In-Reply-To: <20100316165954.15C94300@victory.xo.com> Message-ID: <20100316174059.B102E3E69@courageux.xo.com> That did work.? Thanks very much Andy. > > Chicago.pm chatter wrote: I've always done -e 'shell' or just 'cpan' but perldoc > CPAN says: > ? ? ?Basic commands: > > ? ? ? ? ?# Modules: > > ? ? ? ? ?cpan> install Acme::Meta ? ? ? ? ? ? ? ? > ? ? ? # in the shell > > ? ? ? ? ?CPAN::Shell->install("Acme::Meta"); ? ? ? > ? ? ?# in perl > > so > > > works. > > a > ---------------------- > Andy Bach > Systems Mangler > Internet: andy_bach at wiwb.uscourts.gov > Voice: (608) 261-5738; > Cell: (608) 658-1890 > > > from a feature. ?-- Rich Kulawiec -------------- next part -------------- An HTML attachment was scrubbed... URL: From v.velox at vvelox.net Sat Mar 20 08:30:12 2010 From: v.velox at vvelox.net (Zane C.B.) Date: Sat, 20 Mar 2010 10:30:12 -0500 Subject: [Chicago-talk] a Perl Desktop environment Message-ID: <20100320103012.7b5c94ff@vixen42.vulpes.vvelox.net> I've slowly been piecing together all the components for a Perl desktop environment and I am curious if any one is interested in getting together and collaborating? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 196 bytes Desc: not available URL: From adougher9 at yahoo.com Sat Mar 20 12:01:34 2010 From: adougher9 at yahoo.com (Chou Enlai) Date: Sat, 20 Mar 2010 12:01:34 -0700 (PDT) Subject: [Chicago-talk] a Perl Desktop environment In-Reply-To: <20100320103012.7b5c94ff@vixen42.vulpes.vvelox.net> Message-ID: <106178.24477.qm@web112902.mail.gq1.yahoo.com> Sure, I can help with that. ?I have some ideas I'd like to share, basically composing interfaces automatically based on requirements, a kind of perl logic programming approach to interface generation. --- On Sat, 3/20/10, Zane C.B. wrote: From: Zane C.B. Subject: [Chicago-talk] a Perl Desktop environment To: "Chicago.pm chatter" Date: Saturday, March 20, 2010, 10:30 AM I've slowly been piecing together all the components for a Perl desktop environment and I am curious if any one is interested in getting together and collaborating? -----Inline Attachment Follows----- _______________________________________________ Chicago-talk mailing list Chicago-talk at pm.org http://mail.pm.org/mailman/listinfo/chicago-talk -------------- next part -------------- An HTML attachment was scrubbed... URL: From richard at rushlogistics.com Sun Mar 21 18:44:53 2010 From: richard at rushlogistics.com (Richard Reina) Date: Sun, 21 Mar 2010 21:44:53 -0400 (EDT) Subject: [Chicago-talk] perl GUI question Message-ID: <20100322014453.8DA683E98@courageux.xo.com> I have been using perlmenu to create menus for a small database API. However, perl menu does not allow color. Does anyone know if Cmenu or any other perl GUI (aside from perl-tk) that allows for color in menu items? Like the following: Choice 1 (in red) Choice 2 ( in blue) Choice 3 (in yellow) Thanks From shlomif at iglu.org.il Mon Mar 22 01:58:50 2010 From: shlomif at iglu.org.il (Shlomi Fish) Date: Mon, 22 Mar 2010 10:58:50 +0200 Subject: [Chicago-talk] perl GUI question In-Reply-To: <20100322014453.8DA683E98@courageux.xo.com> References: <20100322014453.8DA683E98@courageux.xo.com> Message-ID: <201003221058.51308.shlomif@iglu.org.il> On Monday 22 Mar 2010 03:44:53 Richard Reina wrote: > I have been using perlmenu to create menus for a small database API. > However, perl menu does not allow color. Does anyone know if Cmenu or any > other perl GUI (aside from perl-tk) that allows for color in menu items? > I believe both wxPerl and Perl/Gtk+ allow you to specify a colour in menu items. Haven't tried it but it should be easy to try. Regards, Shlomi Fish > Like the following: > > Choice 1 (in red) > Choice 2 ( in blue) > Choice 3 (in yellow) > > Thanks > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Freecell Solver - http://fc-solve.berlios.de/ Deletionists delete Wikipedia articles that they consider lame. Chuck Norris deletes deletionists whom he considers lame. Please reply to list if it's a mailing list post - http://shlom.in/reply . From richard at rushlogistics.com Mon Mar 22 16:58:14 2010 From: richard at rushlogistics.com (Richard Reina) Date: Mon, 22 Mar 2010 19:58:14 -0400 (EDT) Subject: [Chicago-talk] perl GUI question In-Reply-To: <20100322014453.8DA683E98@courageux.xo.com> Message-ID: <20100322235814.EB5CA26AC@alexander.xo.com> Shlomi, Thanks for the input. Unfortunately from what I can tell both wxperl and perl/Gtk are very similar to perl/tk in that they are very mouse prone. Don't get me wrong I like Tk and use it, for certain things it can't be beat. However, for this particular instance I am dealing with a menu that's built from the results of a database query and I am looking for something with the feel of a scroll down menu using arrow keys that won't make the user grab for their mouse. Something like this. #!/usr/bin/perl # Sample Cmenu script use Cmenu; menu_initialise("Cmenu Sample Script"); menu_init("Menu Title","Menu Help Text"); menu_item("Option 1","gimme1"); menu_item("Option 2","gimme2"); menu_item("Option 3","gimme3"); chop($sel = menu_display("Menu Prompt")); menu_terminate("bye bye"); I just need a way to make the choices colored in order to fit into my schema ---- Chicago.pm chatter wrote: > > On Monday 22 Mar 2010 03:44:53 Richard Reina wrote: > > I have been using perlmenu to create menus for a small database API. > > However, perl menu does not allow color. Does anyone know if Cmenu or any > > other perl GUI (aside from perl-tk) that allows for color in menu items? > > > > I believe both wxPerl and Perl/Gtk+ allow you to specify a colour in menu > items. Haven't tried it but it should be easy to try. > > Regards, > > Shlomi Fish > > > Like the following: > > > > Choice 1 (in red) > > Choice 2 ( in blue) > > Choice 3 (in yellow) > > > > Thanks > > _______________________________________________ > > Chicago-talk mailing list > > Chicago-talk at pm.org > > http://mail.pm.org/mailman/listinfo/chicago-talk > > -- > ----------------------------------------------------------------- > Shlomi Fish http://www.shlomifish.org/ > Freecell Solver - http://fc-solve.berlios.de/ > > Deletionists delete Wikipedia articles that they consider lame. > Chuck Norris deletes deletionists whom he considers lame. > > Please reply to list if it's a mailing list post - http://shlom.in/reply . > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From shlomif at iglu.org.il Tue Mar 23 01:50:12 2010 From: shlomif at iglu.org.il (Shlomi Fish) Date: Tue, 23 Mar 2010 10:50:12 +0200 Subject: [Chicago-talk] perl GUI question In-Reply-To: <20100322235814.EB5CA26AC@alexander.xo.com> References: <20100322235814.EB5CA26AC@alexander.xo.com> Message-ID: <201003231050.12933.shlomif@iglu.org.il> On Tuesday 23 Mar 2010 01:58:14 Richard Reina wrote: > Shlomi, > > Thanks for the input. Unfortunately from what I can tell both wxperl and > perl/Gtk are very similar to perl/tk in that they are very mouse prone. While you can use the mouse to operate wxPerl and Perl/Gtk+ apps, you can also fully operate them using the keyboard (assuming they are written properly.) > Don't get me wrong I like Tk and use it, for certain things it can't be > beat. However, for this particular instance I am dealing with a menu > that's built from the results of a database query and I am looking for > something with the feel of a scroll down menu using arrow keys that won't > make the user grab for their mouse. > I see that Cmenu is http://search.cpan.org/dist/Cmenu/ . It hasn't been maintained since 2001 and the code shows many vestiges of ancient Perl. I suggest against using it. > Something like this. > > #!/usr/bin/perl > # Sample Cmenu script > No strict, no warnings. > use Cmenu; > > menu_initialise("Cmenu Sample Script"); > > menu_init("Menu Title","Menu Help Text"); > > menu_item("Option 1","gimme1"); > menu_item("Option 2","gimme2"); > menu_item("Option 3","gimme3"); > > chop($sel = menu_display("Menu Prompt")); > chop? Don't you want chomp instead? And why do you need it in the first place? > menu_terminate("bye bye"); And a procedural, global interface. > I just need a way to make the choices colored in order to fit into my > schema > I suggest you write something using http://search.cpan.org/dist/Curses/ or http://search.cpan.org/dist/Curses-UI/ if you wish to have a terminal-based UI. Otherwise, just use wxPerl or something. Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ "The Human Hacking Field Guide" - http://shlom.in/hhfg Deletionists delete Wikipedia articles that they consider lame. Chuck Norris deletes deletionists whom he considers lame. Please reply to list if it's a mailing list post - http://shlom.in/reply . From richard at rushlogistics.com Tue Mar 23 05:37:57 2010 From: richard at rushlogistics.com (Richard Reina) Date: Tue, 23 Mar 2010 08:37:57 -0400 (EDT) Subject: [Chicago-talk] perl GUI question In-Reply-To: <20100322235814.EB5CA26AC@alexander.xo.com> Message-ID: <20100323123757.9D09F600@captain.xo.com> Shlomi, Thanks again for your reply. I know it has not been maintained for a while, however, like perlmenu, upon which it is based, I suspect it is very mature and stable. Not sure if you had a chance to run the sample script I included, but it has such a fast and simple to scroll feel to it that I don't see in the more window-based GUIs such as wxperl and Tk. I realize nonetheless that I may in fact have to go with one of them. That possibly being the case does anyone know if wxperl has any particular advantages over perl/Tk? Thanks, Richard ---- Chicago.pm chatter wrote: > > On Tuesday 23 Mar 2010 01:58:14 Richard Reina wrote: > > Shlomi, > > > > Thanks for the input. Unfortunately from what I can tell both wxperl and > > perl/Gtk are very similar to perl/tk in that they are very mouse prone. > > While you can use the mouse to operate wxPerl and Perl/Gtk+ apps, you can also > fully operate them using the keyboard (assuming they are written properly.) > > > Don't get me wrong I like Tk and use it, for certain things it can't be > > beat. However, for this particular instance I am dealing with a menu > > that's built from the results of a database query and I am looking for > > something with the feel of a scroll down menu using arrow keys that won't > > make the user grab for their mouse. > > > > I see that Cmenu is http://search.cpan.org/dist/Cmenu/ . It hasn't been > maintained since 2001 and the code shows many vestiges of ancient Perl. I > suggest against using it. > > > Something like this. > > > > #!/usr/bin/perl > > # Sample Cmenu script > > > > No strict, no warnings. > > > use Cmenu; > > > > menu_initialise("Cmenu Sample Script"); > > > > menu_init("Menu Title","Menu Help Text"); > > > > menu_item("Option 1","gimme1"); > > menu_item("Option 2","gimme2"); > > menu_item("Option 3","gimme3"); > > > > chop($sel = menu_display("Menu Prompt")); > > > > chop? Don't you want chomp instead? And why do you need it in the first place? > > > menu_terminate("bye bye"); > > And a procedural, global interface. > > > I just need a way to make the choices colored in order to fit into my > > schema > > > > I suggest you write something using http://search.cpan.org/dist/Curses/ or > http://search.cpan.org/dist/Curses-UI/ if you wish to have a terminal-based > UI. Otherwise, just use wxPerl or something. > > Regards, > > Shlomi Fish > > -- > ----------------------------------------------------------------- > Shlomi Fish http://www.shlomifish.org/ > "The Human Hacking Field Guide" - http://shlom.in/hhfg > > Deletionists delete Wikipedia articles that they consider lame. > Chuck Norris deletes deletionists whom he considers lame. > > Please reply to list if it's a mailing list post - http://shlom.in/reply . > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From v.velox at vvelox.net Wed Mar 24 00:23:20 2010 From: v.velox at vvelox.net (Zane C. B.) Date: Wed, 24 Mar 2010 02:23:20 -0500 Subject: [Chicago-talk] a Perl Desktop environment In-Reply-To: <106178.24477.qm@web112902.mail.gq1.yahoo.com> References: <106178.24477.qm@web112902.mail.gq1.yahoo.com> Message-ID: <20100324022320.21453e38ux17w8g0@inari.vvelox.net> Quoting Chou Enlai : > Sure, I can help with that. ?I have some ideas I'd like to share, > basically composing interfaces automatically based on requirements, > a kind of perl logic programming approach to interface generation. Awesome. So far my work has revolved around ZConf, http://search.cpan.org/dist/ZConf/. In regards to GUI stuff, I've been using a system that allows multiple backends to be selected, with the idea that both backends and frontends are implemented as separate modules and then for the GUI, there is a collection of standard dialogs that can be called easily for basic things. It works nicely, for the most part, with the only real issue being that using a automatically chosen backend results in blocking. I've written a few things for so far. Look for ZConf modules and PerlFM at http://search.cpan.org/~vvelox/ . So far my working name for this is EESDP, the Easily Extensible/Scriptable Desktop Project, http://eesdp.org/ . Not much there, but going to begin populating it with more information and etc shortly. The system largely expects a few certain things in regards to LDAP as well, but can be overridden. http://eesdp.org/docs/EESDP/Docs/LDAP/trunk/EESDP%20LDAP%20Standard.pod.html That has the current incarnation, which may be more or less correct. Finally starting to get around to putting more time into it again. Will be opening up the svn of it all shortly. From andy at petdance.com Fri Mar 26 12:06:20 2010 From: andy at petdance.com (Andy Lester) Date: Fri, 26 Mar 2010 14:06:20 -0500 Subject: [Chicago-talk] Fwd: [Chirb] Chicago Code Camp 2 References: Message-ID: <01154E3A-E3D1-44E6-ACF8-DE6F2DB85857@petdance.com> Begin forwarded message: > From: "Sergio Pereira" > Date: March 26, 2010 1:17:49 PM CDT > To: > Subject: [Chirb] Chicago Code Camp 2 > Reply-To: Chirb discussion list > > Sorry for announcing on the mailing list but I believe it will be of > interest to everyone. > > I sent this invitation last year too and we had a good number of Rubyists > there. If you're not familiar with code camps, these are free events > by-and-for the developer community. > > > > The sessions are totally up to the diversity of speaker submissions and > community interest. Last year we had around 35 sessions with topics such as > JavaScript, Ruby, .NET, Python, iPhone, Scala, XUL, TDD, Rails, Cloud > Computing, Regular Expressions, etc. > > > > So let's get some cool Ruby talks submitted too and attend the event. > > > > The Code Camp will be at the IIT campus on Saturday May 1st. > > > > More details at: http://chicagocodecamp.com and > http://chicagocodecamp.pbworks.com/ > > > > Feel free to contact me for more info, volunteering, sponsorship > opportunities, etc. > > Thanks > > - sp > > > > _______________________________________________ > ChicagoGroup-Members-List at rubyforge.org > http://rubyforge.org/mailman/listinfo/chicagogroup-members-list -- Andy Lester => andy at petdance.com => www.theworkinggeek.com => AIM:petdance From kent at c2group.net Tue Mar 30 10:41:03 2010 From: kent at c2group.net (Kent Cowgill) Date: Tue, 30 Mar 2010 13:41:03 -0400 Subject: [Chicago-talk] =?utf-8?q?Meeting=3F?= Message-ID: <79cb8e72d7fe75b71f2f1929347bfb20@roundcube-imap.mailstore.pobox.com> Hi, Are we due for a meeting soon? Or have I missed it yet again? :) -- Kent Cowgill kent at c2group.net http://kentcowgill.org/blog http://youtube.com/kcowgill http://kentcowgill.org/photos http://flickr.com/people/kcowgill From joshua.mcadams at gmail.com Tue Mar 30 13:45:52 2010 From: joshua.mcadams at gmail.com (Joshua) Date: Tue, 30 Mar 2010 15:45:52 -0500 Subject: [Chicago-talk] Meeting? In-Reply-To: <79cb8e72d7fe75b71f2f1929347bfb20@roundcube-imap.mailstore.pobox.com> References: <79cb8e72d7fe75b71f2f1929347bfb20@roundcube-imap.mailstore.pobox.com> Message-ID: <49d805d71003301345gdabdean3fe033c1b85dd599@mail.gmail.com> We've been on quite a dry spell... how about an April get-together? I'll host as long as it is early in the month. The 12th and the 15th both work for me. Any objections, preferences, or alternative suggestions? On Tue, Mar 30, 2010 at 12:41 PM, Kent Cowgill wrote: > Hi, > > Are we due for a meeting soon? > > Or have I missed it yet again? :) > > -- > Kent Cowgill kent at c2group.net > > http://kentcowgill.org/blog http://youtube.com/kcowgill > http://kentcowgill.org/photos http://flickr.com/people/kcowgill > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sblanton at choppertrading.com Tue Mar 30 13:59:51 2010 From: sblanton at choppertrading.com (Sean Blanton) Date: Tue, 30 Mar 2010 15:59:51 -0500 Subject: [Chicago-talk] Meeting? In-Reply-To: <49d805d71003301345gdabdean3fe033c1b85dd599@mail.gmail.com> References: <79cb8e72d7fe75b71f2f1929347bfb20@roundcube-imap.mailstore.pobox.com> <49d805d71003301345gdabdean3fe033c1b85dd599@mail.gmail.com> Message-ID: <44AE62A7ED7A1F40AF0FC503B50F92780154E41C74@chopperexchange.choppertrading.com> I'm up for it as well. Those days work for me. From: chicago-talk-bounces+sblanton=choppertrading.com at pm.org [mailto:chicago-talk-bounces+sblanton=choppertrading.com at pm.org] On Behalf Of Joshua Sent: Tuesday, March 30, 2010 3:46 PM To: Chicago.pm chatter Subject: Re: [Chicago-talk] Meeting? We've been on quite a dry spell... how about an April get-together? I'll host as long as it is early in the month. The 12th and the 15th both work for me. Any objections, preferences, or alternative suggestions? On Tue, Mar 30, 2010 at 12:41 PM, Kent Cowgill > wrote: Hi, Are we due for a meeting soon? Or have I missed it yet again? :) -- Kent Cowgill kent at c2group.net http://kentcowgill.org/blog http://youtube.com/kcowgill http://kentcowgill.org/photos http://flickr.com/people/kcowgill _______________________________________________ Chicago-talk mailing list Chicago-talk at pm.org http://mail.pm.org/mailman/listinfo/chicago-talk ________________________________ CONFIDENTIALITY WARNING: This email including any attachments may contain privileged or confidential information and is for the sole use of the intended recipient(s). Any unauthorized use or disclosure of this communication is prohibited. This e-mail may also be subject to specific non-disclosure and confidentiality provisions. The information contained herein is the property of Chopper Trading, LLC. If you believe that you have received this email in error, please notify the sender immediately and delete it from your system. -------------- next part -------------- An HTML attachment was scrubbed... URL: From kent at c2group.net Tue Mar 30 19:05:46 2010 From: kent at c2group.net (Kent Cowgill) Date: Tue, 30 Mar 2010 21:05:46 -0500 Subject: [Chicago-talk] Meeting? In-Reply-To: <49d805d71003301345gdabdean3fe033c1b85dd599@mail.gmail.com> References: <79cb8e72d7fe75b71f2f1929347bfb20@roundcube-imap.mailstore.pobox.com> <49d805d71003301345gdabdean3fe033c1b85dd599@mail.gmail.com> Message-ID: <9B200BC7-6EE9-4EFF-9866-660E677B6F96@c2group.net> On Mar 30, 2010, at 3:45 PM, Joshua wrote: > We've been on quite a dry spell... how about an April get-together? I'll host as long as it is early in the month. The 12th and the 15th both work for me. Any objections, preferences, or alternative suggestions? Either of those work for me. Kent Cowgill kent at c2group.net http://kentcowgill.org/blog http://youtube.com/kcowgill http://kentcowgill.org/photos http://flickr.com/people/kcowgill From dontyoumonkeywiththemonkey at gmail.com Tue Mar 30 23:54:58 2010 From: dontyoumonkeywiththemonkey at gmail.com (Elias Lutfallah) Date: Wed, 31 Mar 2010 00:54:58 -0600 Subject: [Chicago-talk] Meeting? In-Reply-To: <9B200BC7-6EE9-4EFF-9866-660E677B6F96@c2group.net> References: <79cb8e72d7fe75b71f2f1929347bfb20@roundcube-imap.mailstore.pobox.com> <49d805d71003301345gdabdean3fe033c1b85dd599@mail.gmail.com> <9B200BC7-6EE9-4EFF-9866-660E677B6F96@c2group.net> Message-ID: I'm in too. Those dates are fine by me. On Tue, Mar 30, 2010 at 8:05 PM, Kent Cowgill wrote: > On Mar 30, 2010, at 3:45 PM, Joshua wrote: > > > We've been on quite a dry spell... how about an April get-together? I'll > host as long as it is early in the month. The 12th and the 15th both work > for me. Any objections, preferences, or alternative suggestions? > > Either of those work for me. > > Kent Cowgill kent at c2group.net > > http://kentcowgill.org/blog http://youtube.com/kcowgill > http://kentcowgill.org/photos http://flickr.com/people/kcowgill > > > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From richard at rushlogistics.com Wed Mar 31 05:37:16 2010 From: richard at rushlogistics.com (Richard Reina) Date: Wed, 31 Mar 2010 08:37:16 -0400 (EDT) Subject: [Chicago-talk] trouble caputuring return value Message-ID: <20100331123716.5B9E81B39@bellona.xo.com> I have a program that opens a separate terminal and prompts the user for some information. However, for some reason I can't seem to capture the return value. Does anyone happen to know why the value returned by get_info.pl is not getting returned? Any help would really be appreciated. Thanks Richard #!/usr/bin/perl -w use strict; my $info; system(q{gnome-terminal --geometry=80x12-0-30 -x perl -e 'require "./get_info.pl"; ($info) = get_input();'}); print $info . "\n"; <<<<<<< get_info.pl >>>>>>>> #!/usr/bin/perl -w use strict; print "Enter Info\n"; chomp (my $info = ); return $info; From shlomif at iglu.org.il Wed Mar 31 06:13:27 2010 From: shlomif at iglu.org.il (Shlomi Fish) Date: Wed, 31 Mar 2010 16:13:27 +0300 Subject: [Chicago-talk] trouble caputuring return value In-Reply-To: <20100331123716.5B9E81B39@bellona.xo.com> References: <20100331123716.5B9E81B39@bellona.xo.com> Message-ID: <201003311613.28085.shlomif@iglu.org.il> Hi Richard! On Wednesday 31 Mar 2010 15:37:16 Richard Reina wrote: > I have a program that opens a separate terminal and prompts the user for > some information. However, for some reason I can't seem to capture the > return value. Does anyone happen to know why the value returned by > get_info.pl is not getting returned? Any help would really be appreciated. > > Thanks > Richard > > #!/usr/bin/perl -w > > use strict; > my $info; > > system(q{gnome-terminal --geometry=80x12-0-30 -x perl -e 'require > "./get_info.pl"; ($info) = get_input();'}); You should not expect Perl to assign to a variable in the main program by evaluating an assignment to its name in a different process. To communicate with a child process you need inter-process communications, such as anonymous pipes, sockets, named pipes, System V IPC, mmap, using the file-system for that, etc. Please read a little about UNIX multi-processing basics (a lot of which is also relevant to Windows and other operating systems). > print $info . "\n"; > > > <<<<<<< get_info.pl >>>>>>>> > #!/usr/bin/perl -w > > use strict; > > print "Enter Info\n"; > chomp (my $info = ); > > return $info; You cannot use return to return an arbitrary Perl value from a program. It only works for functions. As far as C and UNIX are concerned, everything that comes out of a process must be in sequences of octets. You need to use "print()" on something to emit it to the outside somehow. Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ What does "Zionism" mean? - http://shlom.in/def-zionism Deletionists delete Wikipedia articles that they consider lame. Chuck Norris deletes deletionists whom he considers lame. Please reply to list if it's a mailing list post - http://shlom.in/reply . From joshua.mcadams at gmail.com Wed Mar 31 07:13:35 2010 From: joshua.mcadams at gmail.com (Joshua) Date: Wed, 31 Mar 2010 08:13:35 -0600 Subject: [Chicago-talk] Last day for YAPC::NA talk submissions... Message-ID: http://conferences.mongueurs.net/yn2010/newtalk From richard at rushlogistics.com Wed Mar 31 10:01:27 2010 From: richard at rushlogistics.com (Richard Reina) Date: Wed, 31 Mar 2010 13:01:27 -0400 (EDT) Subject: [Chicago-talk] trouble caputuring return value In-Reply-To: <20100331123716.5B9E81B39@bellona.xo.com> Message-ID: <20100331170128.11B2D3563@theseus.xo.com> Shlomi, Thanks for your reply. Is this something complicated to do? If it is I just opt to save the input to a file and have the 1st program open the file to get it. I was just wondering if you had an idea how steep of a learning curve I have in front of me. Thanks, Richard ---- Chicago.pm chatter wrote: > > Hi Richard! > > On Wednesday 31 Mar 2010 15:37:16 Richard Reina wrote: > > I have a program that opens a separate terminal and prompts the user for > > some information. However, for some reason I can't seem to capture the > > return value. Does anyone happen to know why the value returned by > > get_info.pl is not getting returned? Any help would really be appreciated. > > > > Thanks > > Richard > > > > #!/usr/bin/perl -w > > > > use strict; > > my $info; > > > > system(q{gnome-terminal --geometry=80x12-0-30 -x perl -e 'require > > "./get_info.pl"; ($info) = get_input();'}); > > You should not expect Perl to assign to a variable in the main program by > evaluating an assignment to its name in a different process. To communicate > with a child process you need inter-process communications, such as anonymous > pipes, sockets, named pipes, System V IPC, mmap, using the file-system for > that, etc. Please read a little about UNIX multi-processing basics (a lot of > which is also relevant to Windows and other operating systems). > > > print $info . "\n"; > > > > > > <<<<<<< get_info.pl >>>>>>>> > > #!/usr/bin/perl -w > > > > use strict; > > > > print "Enter Info\n"; > > chomp (my $info = ); > > > > return $info; > > You cannot use return to return an arbitrary Perl value from a program. It > only works for functions. As far as C and UNIX are concerned, everything that > comes out of a process must be in sequences of octets. You need to use > "print()" on something to emit it to the outside somehow. > > Regards, > > Shlomi Fish > > -- > ----------------------------------------------------------------- > Shlomi Fish http://www.shlomifish.org/ > What does "Zionism" mean? - http://shlom.in/def-zionism > > Deletionists delete Wikipedia articles that they consider lame. > Chuck Norris deletes deletionists whom he considers lame. > > Please reply to list if it's a mailing list post - http://shlom.in/reply . > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > From tzz at lifelogs.com Wed Mar 31 10:03:17 2010 From: tzz at lifelogs.com (Ted Zlatanov) Date: Wed, 31 Mar 2010 12:03:17 -0500 Subject: [Chicago-talk] trouble caputuring return value In-Reply-To: <201003311613.28085.shlomif@iglu.org.il> (Shlomi Fish's message of "Wed, 31 Mar 2010 16:13:27 +0300") References: <20100331123716.5B9E81B39@bellona.xo.com> <201003311613.28085.shlomif@iglu.org.il> Message-ID: <87634cbezu.fsf@lifelogs.com> On Wed, 31 Mar 2010 16:13:27 +0300 Shlomi Fish wrote: SF> You should not expect Perl to assign to a variable in the main program by SF> evaluating an assignment to its name in a different process. To communicate SF> with a child process you need inter-process communications, such as anonymous SF> pipes, sockets, named pipes, System V IPC, mmap, using the file-system for SF> that, etc. Please read a little about UNIX multi-processing basics (a lot of SF> which is also relevant to Windows and other operating systems). ... SF> You cannot use return to return an arbitrary Perl value from a program. It SF> only works for functions. As far as C and UNIX are concerned, everything that SF> comes out of a process must be in sequences of octets. You need to use SF> "print()" on something to emit it to the outside somehow. If shared memory is a possibility, Tie::ShareLite makes it *really* easy to share information persistently between programs. Richard could also look into wxWidgets, which would make the input reader better and wouldn't depend on gnome-terminal. If he explains more about why he's splitting the task into a reader and a processor, I'm sure he'd get more specific suggestions. Ted From bdoty at eqtc.com Wed Mar 31 12:32:10 2010 From: bdoty at eqtc.com (Brad Doty) Date: Wed, 31 Mar 2010 14:32:10 -0500 Subject: [Chicago-talk] Chicago-talk Digest, Vol 80, Issue 27 In-Reply-To: References: Message-ID: <1270063930.6417.2794.camel@bdoty01.eqtc.local> Hold the phone. Why are you guys making this evermore complicated? Good God, you don't need sockets to shell out to the system! And you don't need to start reading Unix books on IPC to do this task. First of all, Richard, what do you want to do? Is there a reason this has to be a separate Perl process in a separate gnome-window? If not, you could write a simple Perl program to call the get_input function and then call that from a shell script that opens a gnome window. You'd have nothing interprocess going on in Perl. Assuming you have an existing Perl process that needs to open a separate window for this input... I would suggest starting with the ole reliable open pipe function. I'm not familiar with perl on the fly with -e, but what's wrong with something like? open (INPUT, "gnome-terminal --geometry=80x12-0-30 -x perl -e 'require > > "./get_info.pl"; my $input = get_input(); print $input' |"); while () { my $info = $_; # or whatever processing you need } OR if you just want to print out the lines generated by get_input()... my @info = ; ## Assigns all lines from INPUT to @info print @info; Call me old-fashioned, but I'd write a Perl script that opens the gnome-terminal and prints the output of get_input on stdout and call that with open (INPUT, "readInput.pl |"); while () { process the input } Maybe I'm missing something, but Perl makes shelling out to the system, even to a new window very easy if you let it. - Thanks, Brad -----Original Message----- From: chicago-talk-request at pm.org Reply-to: chicago-talk at pm.org To: chicago-talk at pm.org Subject: Chicago-talk Digest, Vol 80, Issue 27 Date: Wed, 31 Mar 2010 12:00:08 -0700 Send Chicago-talk mailing list submissions to chicago-talk at pm.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.pm.org/mailman/listinfo/chicago-talk or, via email, send a message with subject or body 'help' to chicago-talk-request at pm.org You can reach the person managing the list at chicago-talk-owner at pm.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Chicago-talk digest..." Today's Topics: 1. Last day for YAPC::NA talk submissions... (Joshua) 2. Re: trouble caputuring return value (Richard Reina) 3. Re: trouble caputuring return value (Ted Zlatanov) ---------------------------------------------------------------------- Message: 1 Date: Wed, 31 Mar 2010 08:13:35 -0600 From: Joshua Subject: [Chicago-talk] Last day for YAPC::NA talk submissions... To: "Chicago.pm chatter" Message-ID: Content-Type: text/plain; charset=ISO-8859-1 http://conferences.mongueurs.net/yn2010/newtalk ------------------------------ Message: 2 Date: Wed, 31 Mar 2010 13:01:27 -0400 (EDT) From: Richard Reina Subject: Re: [Chicago-talk] trouble caputuring return value To: "Chicago.pm chatter" Message-ID: <20100331170128.11B2D3563 at theseus.xo.com> Content-Type: text/plain; charset="utf-8" Shlomi, Thanks for your reply. Is this something complicated to do? If it is I just opt to save the input to a file and have the 1st program open the file to get it. I was just wondering if you had an idea how steep of a learning curve I have in front of me. Thanks, Richard ---- Chicago.pm chatter wrote: > > Hi Richard! > > On Wednesday 31 Mar 2010 15:37:16 Richard Reina wrote: > > I have a program that opens a separate terminal and prompts the user for > > some information. However, for some reason I can't seem to capture the > > return value. Does anyone happen to know why the value returned by > > get_info.pl is not getting returned? Any help would really be appreciated. > > > > Thanks > > Richard > > > > #!/usr/bin/perl -w > > > > use strict; > > my $info; > > > > system(q{gnome-terminal --geometry=80x12-0-30 -x perl -e 'require > > "./get_info.pl"; ($info) = get_input();'}); > > You should not expect Perl to assign to a variable in the main program by > evaluating an assignment to its name in a different process. To communicate > with a child process you need inter-process communications, such as anonymous > pipes, sockets, named pipes, System V IPC, mmap, using the file-system for > that, etc. Please read a little about UNIX multi-processing basics (a lot of > which is also relevant to Windows and other operating systems). > > > print $info . "\n"; > > > > > > <<<<<<< get_info.pl >>>>>>>> > > #!/usr/bin/perl -w > > > > use strict; > > > > print "Enter Info\n"; > > chomp (my $info = ); > > > > return $info; > > You cannot use return to return an arbitrary Perl value from a program. It > only works for functions. As far as C and UNIX are concerned, everything that > comes out of a process must be in sequences of octets. You need to use > "print()" on something to emit it to the outside somehow. > > Regards, > > Shlomi Fish > > -- > ----------------------------------------------------------------- > Shlomi Fish http://www.shlomifish.org/ > What does "Zionism" mean? - http://shlom.in/def-zionism > > Deletionists delete Wikipedia articles that they consider lame. > Chuck Norris deletes deletionists whom he considers lame. > > Please reply to list if it's a mailing list post - http://shlom.in/reply . > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > ------------------------------ Message: 3 Date: Wed, 31 Mar 2010 12:03:17 -0500 From: Ted Zlatanov Subject: Re: [Chicago-talk] trouble caputuring return value To: Chicago.pm chatter Cc: Richard Reina Message-ID: <87634cbezu.fsf at lifelogs.com> Content-Type: text/plain; charset="us-ascii" On Wed, 31 Mar 2010 16:13:27 +0300 Shlomi Fish wrote: SF> You should not expect Perl to assign to a variable in the main program by SF> evaluating an assignment to its name in a different process. To communicate SF> with a child process you need inter-process communications, such as anonymous SF> pipes, sockets, named pipes, System V IPC, mmap, using the file-system for SF> that, etc. Please read a little about UNIX multi-processing basics (a lot of SF> which is also relevant to Windows and other operating systems). ... SF> You cannot use return to return an arbitrary Perl value from a program. It SF> only works for functions. As far as C and UNIX are concerned, everything that SF> comes out of a process must be in sequences of octets. You need to use SF> "print()" on something to emit it to the outside somehow. If shared memory is a possibility, Tie::ShareLite makes it *really* easy to share information persistently between programs. Richard could also look into wxWidgets, which would make the input reader better and wouldn't depend on gnome-terminal. If he explains more about why he's splitting the task into a reader and a processor, I'm sure he'd get more specific suggestions. Ted ------------------------------ _______________________________________________ Chicago-talk mailing list Chicago-talk at pm.org http://mail.pm.org/mailman/listinfo/chicago-talk End of Chicago-talk Digest, Vol 80, Issue 27 ******************************************** From shlomif at iglu.org.il Wed Mar 31 21:57:59 2010 From: shlomif at iglu.org.il (Shlomi Fish) Date: Thu, 1 Apr 2010 07:57:59 +0300 Subject: [Chicago-talk] trouble caputuring return value In-Reply-To: <20100331170128.11B2D3563@theseus.xo.com> References: <20100331170128.11B2D3563@theseus.xo.com> Message-ID: <201004010757.59312.shlomif@iglu.org.il> Hi Richard, On Wednesday 31 Mar 2010 20:01:27 Richard Reina wrote: > Shlomi, > > Thanks for your reply. Is this something complicated to do? Not in particular. See http://perldoc.perl.org/perlipc.html for some initial pointers (though you should use IO::Socket and friends, etc. which I'm not sure if it mentions it properly). You can learn how to do IPC, and then it serves you for the rest of your life. > If it is I > just opt to save the input to a file and have the 1st program open the > file to get it. I was just wondering if you had an idea how steep of a > learning curve I have in front of me. Saving to a file is a good option. However, as Ted Zlatanov mentioned in reply to my message, if you're doing such acrobatics to get a value from program being forked and ran in gnome-terminal, you should reconsider your study. There are much better uses for Inter-Process Communication (IPC) than what it seems like you're trying to do. Regards, Shlomi Fish > > Thanks, > > Richard > -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Interview with Ben Collins-Sussman - http://shlom.in/sussman Deletionists delete Wikipedia articles that they consider lame. Chuck Norris deletes deletionists whom he considers lame. Please reply to list if it's a mailing list post - http://shlom.in/reply .