RE: problem with nested regex matchs
Chris Stinemetz [chrisstinem...@gmail.com] wrote: >Hello Shanmugam, > >Please start a new thread when you post a new topic. > > >On Wed, Mar 7, 2012 at 5:14 PM, shanmugam m wrote: >> Hi, >> This is my first perl program..I'm getting wired errors.Please take a >> look. >> >> This line looks incorrect. >> #!persist/pkg/bin/perl Everything following the #! on the first line of a script should be the path to the Perl interpreter. This could keep the Perl script program from being properly executed. Frequently this shebang line looks like: #!/usr/bin/perl >> use diagnostics; >> use warnings; > >always use the strict pragma especially when you are learning Perl. >This will help you understand what is going on and also enforce you to >use better programming practices such as lexical scope. >use strict; > >> >> open(MYINPUTFILE ,"/net/fallsroot/export/d100/m4/input_file"); >> open(MYOUTFILE, "> output_file"); > >it is recommended to use a three argument filehandle >open my $INPUTFILE, '<',$input_file or die "ERROR opening $input_file: $!"; >open my $OUTFILE, '>',$output_file or die "ERROR opening $output_file: $!"; > >> >> foreach $line (){ > >use a while loop to read one line at a time >while ( my $line = $INPUTFILE ) { >chomp $line; > >> >>chomp($line);# remove the newline from $line. >> # do line-by-line processing. >>my @column1 = split("/\\/",$line); >I'm not sure what you are trying to do here. Split will split on white >space by default > >>print MYOUTFILE $column1[5] ,"\t" ; >you are trying to print the fifth element in the array @column1 > >>my @column2 = split("=",$line); >now it looks like you are wanting to split $line again based on "=" >this would require you to reread the input file or create a better >regex to capture everything you want in the first read > >>print MYOUTFILE $column2[1] ,"\n" ; >> >>} >> >> close(MYOUTFILE); >> Regards, >> Shanmugam >> > >-- HTH, David Kronheim This communication is confidential. Frontier only sends and receives email on the basis of the terms set out at http://www.frontier.com/email_disclaimer. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: work with hexadecimal values
On 12-03-08 03:06 PM, Steve Bertrand wrote: You wanted to find out the numbers between the two. While playing around, I found this: perl -e 'printf "%X\n", $_ for ( 0x415a+1 .. 0x415f-1 ) ...prints: 415B 415C 415D 415E Yes the 0x notation is just another number. You can do anything with it that you can do with an integer. Example: perl -le'print $_ for (( 0x10 >> 4 ) .. ( 0x10 | 0x01 ) - 1 )' -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. It's Mutual Aid, not fierce competition, that's the dominate force of evolution. Of course, anyone who has worked in open source already knows this. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Of Date-Manip and Perl versions
On 03/08/2012 12:35 PM, sb...@cpan.org wrote: > On 03/08/2012 02:53 PM, Bruce Ferrell wrote: >> Just thought I'd share with the group and experience I just had. In perhaps >> the hope of sparing others of the PITA I just went through. >> >> First of all, I will acknowledge I am perhaps not the best of programmers... >> Perhaps being an understatement. >> >> Second of all, it is not a request for a "better way to code" this. This is >> a recounting of some troubleshooting I just endured due to a programmer very >> much more clever than I. >> >> First, allow me to present the offender(s): >> >> sub timestamp { >> return strftime( "%Y-%m-%d %H:%M:%S", gmtime($_[0] || time()) ); >> } >> >> my $ts0 = UnixDate( Date_ConvTZ( ParseDate( timestamp() >> ),"GMT",$tz),"%Y-%m-%d %T" ); >> >> The original environment for this code is a Linux system running Perl 5.8.8 >> and it performed flawlessly there and was successfully transplanted to >> 5.10.0 with no changes needed. >> When the application containing the code above was transplanted to a system >> running Perl 5.12.3... Well, lets just say this is where the fun began. >> >> When it comes to Perl installations, I long ago learned not to trust >> Distribution provided modules so I always use CPAN to install from. Basic >> Perl, from the Distro, sure... Add >> on modules, not so much. Often the modules I want aren't even in the distro >> and for module sets I use often I have little shell scripts to load the >> necessary modules from CPAN. I >> don't really look at it that much. Maybe not the best practice, but I'm >> busy. I also want to say, this is code a wrote a couple of years ago. I've >> not touched it since and have >> since moved on to other things. >> >> When the report came in that important function weren't working I first had >> to find the location of the failing code. Is it being passed it's necessary >> data. Yep... OK, so what's >> wrong? Any errors thrown? Nope. OK, extract the code into a test program >> (below, suitably "cleaned" to disguise what it really is). "In circuit" the >> code runs as a daemon and >> errors aren't easy to get at. >> >> #!/usr/bin/perl -w >> >> use lib '../lib'; >> >> use Common; # contains timestamp() >> >> use Date::Manip; >> >> my $graphdates=''; >> >> $graphdates .= "&action=plot&ts2=" . UnixDate( Date_ConvTZ( >> ParseDate( timestamp() ),"GMT",$tz),"%Y-%m-%d %T" ); >> $graphdates .= "&ts=" . UnixDate( Date_ConvTZ(DateCalc( ParseDate( >> timestamp() ), "- 120 Minutes" ),"GMT",$tz),"%Y-%m-%d %T" ); >> my $test = UnixDate( Date_ConvTZ( ParseDate( timestamp() >> ),"GMT",$tz),"%Y-%m-%d %T" ); >> >> print STDERR "$test\n" >> >> >> In the test program, the conversion stream works correctly. OK... Now what? >> Maybe the module didn't install correctly?! Hand install with UNINST=1 set >> >> The application still misbehaves but now I have the all distribution files >> so I dig into the docs where I find this: >> >> FUNCTIONAL INTERFACE (VERSION 5) >> When using a version of perl older than 5.10, this is the only interface >> available. This interface is documented in the Date::Manip::DM5 >> document. >> >> (The above should read 5.10 and below, because the code worked exactly as it >> did under 5.8.8 at 5.10.0) >> >> and this: >> >> DATE_MANIP ENVIRONMENT VARIABLE >> By setting the DATE_MANIP environment variable to 'DM5' before >> running the perl script, the version 5 interface will be used. >> >> suffice to say, problem solved! >> >> insert >> >> export DATE_MANIP=DM5 >> >> into the daemon startup script and enable mod_env in the apache that runs >> other parts, adding >> >> SetEnv DATE_MANIP DM5 >> >> to the apache config file. >> >> Now here comes my question: >> >> Shouldn't this have thrown SOME kind of error/warning what was going on? Is >> silent failure a proper behavior no matter how clever the switch around is? >> Just asking. >> >> Respectfully, >> Bruce Ferrell > > Your report is long... but it unfortunately doesn't contain much information > on what failed or why. > > When I run your script (with the addition of the line setting $tz and a > couple prints): > > #!/usr/bin/perl > > use POSIX qw(strftime); > use Date::Manip; > > sub timestamp { >return strftime( "%Y-%m-%d %H:%M:%S", gmtime($_[0] || time()) ); > } > > my $tz = "America/New_York"; > > my $st = timestamp(); > print "$st\n"; > > my $ts0 = UnixDate( Date_ConvTZ( ParseDate( $st ),"GMT",$tz),"%Y-%m-%d %T" > ); > > print "$ts0\n"; > > it seems to work fine. You didn't tell me what $tz should be, so I just used > my local timezone, and the result of this is that it prints out the current > time (which is > correct). I ran it with both perl 5.10.1 and 5.14.2. > > So, I can't tell what you expected it to produce, or what it did produce > based on your report. If you fill in some/all of this informa
Re: work with hexadecimal values
On 2012-03-08 08:24, sunita.prad...@emc.com wrote: Hi I have one range of hexadecimal numbers like : 415A till 415F . I need to find all other numbers between this 2 . Is there any Perl function which will help to find all numbers or any other way in Perl ? You wanted to find out the numbers between the two. While playing around, I found this: perl -e 'printf "%X\n", $_ for ( 0x415a+1 .. 0x415f-1 ) ...prints: 415B 415C 415D 415E Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: work with hexadecimal values
On 2012-03-08 08:41, John W. Krahn wrote: sunita.prad...@emc.com wrote: Hi Hello, I have one range of hexadecimal numbers like : 415A till 415F . I need to find all other numbers between this 2 . Is there any Perl function which will help to find all numbers or any other way in Perl ? $ perl -e'printf "%X\n", $_ for hex( "415A" ) .. hex( "415F" )' I was trying to do it without a function call to hex(). I remember that Perl understands hex so long as the actual number is prepended with '0x': perl -e 'printf "%X\n", $_ for ( 0x415a .. 0x415f )' ...as far as using print instead of printf, I didn't do enough testing :) Here's to learning. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Of Date-Manip and Perl versions
Just thought I'd share with the group and experience I just had. In perhaps the hope of sparing others of the PITA I just went through. First of all, I will acknowledge I am perhaps not the best of programmers... Perhaps being an understatement. Second of all, it is not a request for a "better way to code" this. This is a recounting of some troubleshooting I just endured due to a programmer very much more clever than I. First, allow me to present the offender(s): sub timestamp { return strftime( "%Y-%m-%d %H:%M:%S", gmtime($_[0] || time()) ); } my $ts0 = UnixDate( Date_ConvTZ( ParseDate( timestamp() ),"GMT",$tz),"%Y-%m-%d %T" ); The original environment for this code is a Linux system running Perl 5.8.8 and it performed flawlessly there and was successfully transplanted to 5.10.0 with no changes needed. When the application containing the code above was transplanted to a system running Perl 5.12.3... Well, lets just say this is where the fun began. When it comes to Perl installations, I long ago learned not to trust Distribution provided modules so I always use CPAN to install from. Basic Perl, from the Distro, sure... Add on modules, not so much. Often the modules I want aren't even in the distro and for module sets I use often I have little shell scripts to load the necessary modules from CPAN. I don't really look at it that much. Maybe not the best practice, but I'm busy. I also want to say, this is code a wrote a couple of years ago. I've not touched it since and have since moved on to other things. When the report came in that important function weren't working I first had to find the location of the failing code. Is it being passed it's necessary data. Yep... OK, so what's wrong? Any errors thrown? Nope. OK, extract the code into a test program (below, suitably "cleaned" to disguise what it really is). "In circuit" the code runs as a daemon and errors aren't easy to get at. #!/usr/bin/perl -w use lib '../lib'; use Common; # contains timestamp() use Date::Manip; my $graphdates=''; $graphdates .= "&action=plot&ts2=" . UnixDate( Date_ConvTZ( ParseDate( timestamp() ),"GMT",$tz),"%Y-%m-%d %T" ); $graphdates .= "&ts=" . UnixDate( Date_ConvTZ(DateCalc( ParseDate( timestamp() ), "- 120 Minutes" ),"GMT",$tz),"%Y-%m-%d %T" ); my $test = UnixDate( Date_ConvTZ( ParseDate( timestamp() ),"GMT",$tz),"%Y-%m-%d %T" ); print STDERR "$test\n" In the test program, the conversion stream works correctly. OK... Now what? Maybe the module didn't install correctly?! Hand install with UNINST=1 set The application still misbehaves but now I have the all distribution files so I dig into the docs where I find this: FUNCTIONAL INTERFACE (VERSION 5) When using a version of perl older than 5.10, this is the only interface available. This interface is documented in the Date::Manip::DM5 document. (The above should read 5.10 and below, because the code worked exactly as it did under 5.8.8 at 5.10.0) and this: DATE_MANIP ENVIRONMENT VARIABLE By setting the DATE_MANIP environment variable to 'DM5' before running the perl script, the version 5 interface will be used. suffice to say, problem solved! insert export DATE_MANIP=DM5 into the daemon startup script and enable mod_env in the apache that runs other parts, adding SetEnv DATE_MANIP DM5 to the apache config file. Now here comes my question: Shouldn't this have thrown SOME kind of error/warning what was going on? Is silent failure a proper behavior no matter how clever the switch around is? Just asking. Respectfully, Bruce Ferrell -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: work with hexadecimal values
On 2012-03-08 08:41, John W. Krahn wrote: sunita.prad...@emc.com wrote: Hi Hello, I have one range of hexadecimal numbers like : 415A till 415F . I need to find all other numbers between this 2 . Is there any Perl function which will help to find all numbers or any other way in Perl ? $ perl -e'printf "%X\n", $_ for hex( "415A" ) .. hex( "415F" )' Sweet. Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: multiple pattern matching
On 08/03/2012 17:03, sunita.prad...@emc.com wrote: Hi All I have one output of one my command like : $output = "Step 155 of 171 steps.Executing. Step 168 of 171 steps.Executing. Step 171 of 171 steps.Executing. Local: COMMITDone. New symdev: 2552 New symdev: 2553 Terminating the configuration change session..Done." ; I need to get those numbers like 2552 , 2553 . I am applying following patter matching logic but it does not get me the 1st number (2552) . @devs = $output =~ m/New symdev:\s*([0-9A-Fa-f]{4})/gis; print $output,"\n"; print "Devices @devs<\n"; Could you please check what is going wrong in the above lines ? I am no sure what you mean Sunita. I have run your program and the output is Devices 2552 2553 < as I would expect. All I can see is that you don't need the /s modifier as you aren't using /./ anywhere in your regex; and with the /i modifier you can shorten your character class to [0-9a-f], or you could write [[:xdigit:]]. Neither of these will change the functionality of your program though - I think it's fine. Rob -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: multiple pattern matching
On Thu, Mar 8, 2012 at 11:03 AM, wrote: > Hi All > > I have one output of one my command like : > > $output = "Step 155 of 171 > steps.Executing. > Step 168 of 171 steps.Executing. > Step 171 of 171 steps.Executing. > Local: COMMITDone. > > New symdev: 2552 > New symdev: 2553 > Terminating the configuration change session..Done." ; > > I need to get those numbers like 2552 , 2553 . > > I am applying following patter matching logic but it does not get me the 1st > number (2552) . > > @devs = $output =~ m/New symdev:\s*([0-9A-Fa-f]{4})/gis; > print $output,"\n"; > print "Devices @devs <\n"; > > > Could you please check what is going wrong in the above lines ? > My approach would be to read it line by line with a while loop. There may be a better way of achieving your goal. #!/usr/bin/perl use warnings; use strict; while ( ) { if ( $_ =~ m/New symdev:\s+(\d+)/ ) { print "$1\n"; } } __DATA__ my $output = "Step 155 of 171 steps.Executing. Step 168 of 171 steps.Executing. Step 171 of 171 steps.Executing. Local: COMMITDone. New symdev: 2552 New symdev: 2553 Terminating the configuration change session..Done." ; ###OUTPUT### 2552 2553 -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: work with hexadecimal values
On 08/03/2012 16:18, sunita.prad...@emc.com wrote: From: John W. Krahn [mailto:jwkr...@shaw.ca] > sunita.prad...@emc.com wrote: I have one range of hexadecimal numbers like : 415A till 415F . I need to find all other numbers between this 2 . Is there any Perl function which will help to find all numbers or any other way in Perl ? $ perl -e'printf "%X\n", $_ for hex( "415A" ) .. hex( "415F" )' 415A 415B 415C 415D 415E 415F Thanks John . How can I collect all devices in a array ? Hi Sunita If you want the numbers in the range expressed in hex, to put them into an array you would write my @devs = map sprintf('%04X', $_), hex( "415A" ) .. hex( "415F" ); HTH, Rob -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: work with hexadecimal values
On 12-03-08 11:44 AM, sunita.prad...@emc.com wrote: Sorry , I mean how will I get all those hexadecimal numbers in a array? my @hex = (); for my $nbr ( hex( "415A" ) .. hex( "415F" ) ){ push @hex, sprintf '%04X', $nbr; } You could also use map: my @hex = map { sprintf '%04X', $_ } hex( "415A" ) .. hex( "415F" ); See: perldoc -f hex perldoc -f sprintf perldoc -f map -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. It's Mutual Aid, not fierce competition, that's the dominate force of evolution. Of course, anyone who has worked in open source already knows this. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
multiple pattern matching
Hi All I have one output of one my command like : $output = "Step 155 of 171 steps.Executing. Step 168 of 171 steps.Executing. Step 171 of 171 steps.Executing. Local: COMMITDone. New symdev: 2552 New symdev: 2553 Terminating the configuration change session..Done." ; I need to get those numbers like 2552 , 2553 . I am applying following patter matching logic but it does not get me the 1st number (2552) . @devs = $output =~ m/New symdev:\s*([0-9A-Fa-f]{4})/gis; print $output,"\n"; print "Devices @devs <\n"; Could you please check what is going wrong in the above lines ? Thanks Sunita
RE: work with hexadecimal values
Sorry , I mean how will I get all those hexadecimal numbers in a array? -Sunita -Original Message- From: sunita.prad...@emc.com [mailto:sunita.prad...@emc.com] Sent: Thursday, March 08, 2012 9:48 PM To: jwkr...@shaw.ca; beginners@perl.org Subject: RE: work with hexadecimal values Thanks John . How can I collect all devices in a array ? -Sunita -Original Message- From: John W. Krahn [mailto:jwkr...@shaw.ca] Sent: Thursday, March 08, 2012 7:11 PM To: Perl Beginners Subject: Re: work with hexadecimal values sunita.prad...@emc.com wrote: > Hi Hello, > I have one range of hexadecimal numbers like : 415A till 415F . > I need to find all other numbers between this 2 . Is there any Perl > function which will help to find all numbers or any other way in Perl ? $ perl -e'printf "%X\n", $_ for hex( "415A" ) .. hex( "415F" )' 415A 415B 415C 415D 415E 415F John -- Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. -- Albert Einstein -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: work with hexadecimal values
Thanks John . How can I collect all devices in a array ? -Sunita -Original Message- From: John W. Krahn [mailto:jwkr...@shaw.ca] Sent: Thursday, March 08, 2012 7:11 PM To: Perl Beginners Subject: Re: work with hexadecimal values sunita.prad...@emc.com wrote: > Hi Hello, > I have one range of hexadecimal numbers like : 415A till 415F . > I need to find all other numbers between this 2 . Is there any Perl > function which will help to find all numbers or any other way in Perl ? $ perl -e'printf "%X\n", $_ for hex( "415A" ) .. hex( "415F" )' 415A 415B 415C 415D 415E 415F John -- Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. -- Albert Einstein -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
beginners@perl.org
On 12-03-08 09:19 AM, lina wrote: a quick question, is padre very popular, do you use it often, seems a bit heavy. I use GViM since it allows me to place to files (or the same one) side-by-side on the screen. Padre doesn't do this yet. But learning to use GViM is difficult since its commands are very esoteric. I usually recommend Padre since it is a more modern editor and works similar to a word processor. If you're going to use GViM, I recommend installing Cream http://cream.sourceforge.net/ which is an overlay that makes GViM behave more like a word processor. -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. It's Mutual Aid, not fierce competition, that's the dominate force of evolution. Of course, anyone who has worked in open source already knows this. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
beginners@perl.org
On Thu, Mar 8, 2012 at 10:14 PM, lina wrote: > On Thu, Mar 8, 2012 at 10:07 PM, Shawn H Corey wrote: >> On 12-03-07 11:49 PM, lina wrote: >>> >>> I only read till 15 pages, progressed so slow, and sometimes choked by >>> understanding the "pack". really hard for me to understand it, so I >>> just skip. meanwhile I also did some search. >> >> >> pack() is difficult to understand, and most of the time, unneeded. I suggest >> you skip it and come back when you have more experience. >> >> Also, I suggest you get a syntax-highlight editor. It will highlight >> keywords like substr so if you accidentally type in subst, you can tell you >> made an mistake because it's not highlighted. Check out Padre: >> http://padre.perlide.org/ # aptitude install padre The following NEW packages will be installed: ack-grep{a} cpanminus{a} libalien-wxwidgets-perl{a} libcapture-tiny-perl{a} libclass-adapter-perl{a} libclass-unload-perl{a} libclass-xsaccessor-perl{a} libcpan-distnameinfo-perl{a} libdebug-client-perl{a} libdevel-dumpvar-perl{a} libdevel-refactor-perl{a} libfile-find-rule-perl{a} libfile-homedir-perl{a} libfile-next-perl{a} libfile-pushd-perl{a} libfile-remove-perl{a} libfile-sharedir-perl{a} libfile-slurp-perl{a} libfile-spec-perl{a} libformat-human-bytes-perl{a} libipc-run3-perl{a} liblocal-lib-perl{a} liblocale-msgfmt-perl{a} libmodule-manifest-perl{a} libnumber-compare-perl{a} liborlite-migrate-perl{a} liborlite-perl{a} libpadwalker-perl{a} libparse-errorstring-perl-perl{a} libparse-exuberantctags-perl{a} libpod-abstract-perl{a} libpod-pom-perl{a} libpod2-base-perl{a} libppi-perl{a} libppix-editortools-perl{a} libppix-regexp-perl{a} libprobe-perl-perl{a} libsort-versions-perl{a} libtemplate-tiny-perl{a} libterm-readline-perl-perl{a} libtext-diff-perl{a} libtext-findindent-perl{a} libtext-glob-perl{a} libtext-patch-perl{a} libwx-perl{a} libwx-perl-processstream-perl{a} libwx-scintilla-perl{a} libwxbase2.8-dev{a} libwxgtk2.8-dev{a} padre wx-common{a} wx2.8-headers{a} 0 packages upgraded, 52 newly installed, 0 to remove and 0 not upgraded. Need to get 8,195 kB of archives. After unpacking 28.0 MB will be used. Do you want to continue? [Y/n/?] a quick question, is padre very popular, do you use it often, seems a bit heavy. >> >> -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
beginners@perl.org
On Thu, Mar 8, 2012 at 10:07 PM, Shawn H Corey wrote: > On 12-03-07 11:49 PM, lina wrote: >> >> I only read till 15 pages, progressed so slow, and sometimes choked by >> understanding the "pack". really hard for me to understand it, so I >> just skip. meanwhile I also did some search. > > > pack() is difficult to understand, and most of the time, unneeded. I suggest > you skip it and come back when you have more experience. > > Also, I suggest you get a syntax-highlight editor. It will highlight > keywords like substr so if you accidentally type in subst, you can tell you > made an mistake because it's not highlighted. Check out Padre: > http://padre.perlide.org/ Thanks Shawn, I use gvim which has the highlight function, last time I just headed wrong direction to look for solutions, I thought I forget to import some modules, Best regards, > > > -- > Just my 0.0002 million dollars worth, > Shawn > > Programming is as much about organization and communication > as it is about coding. > > It's Mutual Aid, not fierce competition, that's the dominate > force of evolution. Of course, anyone who has worked in > open source already knows this. > > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
beginners@perl.org
On 12-03-07 11:49 PM, lina wrote: I only read till 15 pages, progressed so slow, and sometimes choked by understanding the "pack". really hard for me to understand it, so I just skip. meanwhile I also did some search. pack() is difficult to understand, and most of the time, unneeded. I suggest you skip it and come back when you have more experience. Also, I suggest you get a syntax-highlight editor. It will highlight keywords like substr so if you accidentally type in subst, you can tell you made an mistake because it's not highlighted. Check out Padre: http://padre.perlide.org/ -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. It's Mutual Aid, not fierce competition, that's the dominate force of evolution. Of course, anyone who has worked in open source already knows this. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: work with hexadecimal values
sunita.prad...@emc.com wrote: Hi Hello, I have one range of hexadecimal numbers like : 415A till 415F . I need to find all other numbers between this 2 . Is there any Perl function which will help to find all numbers or any other way in Perl ? $ perl -e'printf "%X\n", $_ for hex( "415A" ) .. hex( "415F" )' 415A 415B 415C 415D 415E 415F John -- Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. -- Albert Einstein -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: work with hexadecimal values
On Thu, Mar 8, 2012 at 10:24 AM, wrote: > Hi > > I have one range of hexadecimal numbers like : 415A till 415F . > I need to find all other numbers between this 2 . Is there any Perl > function which will help to find all numbers or any other way in Perl ? > > > Thanks > Sunita > my @numbers = hex("415A")..hex("415F"); See perldoc -f hex and 'Range Operators' under perldoc perlop.
work with hexadecimal values
Hi I have one range of hexadecimal numbers like : 415A till 415F . I need to find all other numbers between this 2 . Is there any Perl function which will help to find all numbers or any other way in Perl ? Thanks Sunita
RE: problem with nested regex matchs
> -Original Message- > From: Chris Stinemetz [mailto:chrisstinem...@gmail.com] > Sent: Wednesday, March 07, 2012 8:57 PM > To: John W. Krahn; beginners@perl.org > Subject: Re: problem with nested regex matchs > > >> > >>> > >>> open(MYINPUTFILE ,"/net/fallsroot/export/d100/m4/input_file"); > >>> open(MYOUTFILE, "> output_file"); > >> > >> > >> it is recommended to use a three argument filehandle > > > > > > "three argument filehandle"? > > What I meant to imply was: "3-argument version of open" > > > > > > >> open my $INPUTFILE, '<',$input_file or die "ERROR opening > $input_file: > >> $!"; > >> open my $OUTFILE, '>',$output_file or die "ERROR opening > $output_file: > >> $!"; > >> > >>> > >>> foreach $line (){ > >> > >> > >> use a while loop to read one line at a time while ( my $line = > >> $INPUTFILE ) { > >> chomp $line; > >> > >>> > >>> chomp($line); # remove the newline from > $line. > >>> # do line-by-line processing. > >>> my @column1 = split("/\\/",$line); > >> > >> I'm not sure what you are trying to do here. Split will split on > >> white space by default > >> > >>> print MYOUTFILE $column1[5] ,"\t" ; > >> > >> you are trying to print the fifth element in the array @column1 > > > > > > Array indexes start at 0 so that is the sixth element. > > You are correct. This was a careless response on my part. > > > > > > > > >>> my @column2 = split("=",$line); > >> > >> now it looks like you are wanting to split $line again based on "=" > >> this would require you to reread the input file or create a better > > > > > > Why would you need to reread the input file? > > How would you handle this? > The OP didn't provide the input data. > The OP is splitting the variable $line. That variable should still be available for splitting a second time. There is no need to reread the file. > > > > Chris > Ken -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/