Re: Split FileName
Pablo Fischer wrote at Fri, 25 Jul 2003 13:49:55 +: I have a string (its an array, the array has the values that $ftp-ls(dir) returns), so $array[1] contains this: -rw-r--r-- 1 pablopablo 18944 Jul 16 21:14 File28903.zip What I would like to do is: get the date (Jul 16), the time (12:14) and the FileName, each one if a different array, like.. my ($date, $time, $fname) = $array[1]; I know that I could to it with split, I solved the problem with split( ,$array[1]); You should also consider to use my @col = split , $array[1]; # or my @col = split /\s+/, $array[1]; Allthough the first method looks very similar to your one, splitting for one blank is a special case that splits at all whitespaces doing nearly the same as the second line (but leading whitespaces are ignored). For further details, please read perldoc -f split However I would like to know if I can separeate the original string into columns, so I could access the values like: $date = $col[6]+$col[7]; The addition seems to be the wrong opparator, as you want mainly concatenate the month with the day of month. Use one of the next methods: my $date = @col[6,7]; my $date = $col[6] $col[7]; my $date = join , @col[6,7]; $time = $col[8]; $fname = $col[9]; However, there would also be a regexp solution: my ($date, $time, $fname) = $array[1] =~ /(\w\w\w \d?\d) (\d?\d:\d\d) (\S+)$/; (I don't have the feeling, that the solution is really better, but I find it always good to know that there are more than one ways to do it) Greetings, Janek PS: In any case, I would recommend you to give the variables a better name. $array[1] is not very self explaining. What about $file_listing[1]. I personally, also found it good not play around with magic numbers like 6, 7, 8, 9 in my source code, unless it is very obviously what they are doing. In your case it might be an idea to declare some constants that are selfexplicating: use constant MONTH_COL = 6; use constant DAY_COL = 7; use constant TIME_COL = 8; use constant FNAME_COL = 9; Than you can write e.g.: my $date = @col[MONTH_COL, DAY_COL]; what is much easier to maintain on a long run. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Thumb-nailing Pic's
Ramon Chavez [EMAIL PROTECTED] wrote: : : Maybe I'm missing something here but, It can be : done just using HTML, say... : : $h= 250; : $w= 250; : : print img src=\yourimage.jpg\ width=\$w\ height=\$h\\n; qq would make much easier to read. print qq|img src=yourimage.jpg width=$w height=$h\n|; : : Or maybe you're talking about something more : complex and at this time in the morning I can't : figure out what is it... ;-) When creating web pages of photo albums you need to watch out for dumbnails. They are like thumbnails, but only the dimensions of the image are changed. If the image is 250 meg the thumbnail should be much smaller, but the dumbnail will be the same size. It would be much better to use an external program to generate the thumbnails than to generate them on-the-fly. Then use perl to automatically create the thumbnail pages. John cited Randal's article on automating the process is at: http://www.stonehenge.com/merlyn/WebTechniques/col29.html HTH, Charles K. Clarkson -- Head Bottle Washer, Clarkson Energy Homes, Inc. Mobile Home Specialists 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Test
Test -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Thumb-nailing Pic's
On Fri, 25 Jul 2003 07:57:32 -0500, [EMAIL PROTECTED] (Ramon Chavez) wrote: Maybe I'm missing something here but, It can be done just using HTML, say... $h= 250; $w= 250; print img src=\yourimage.jpg\ width=\$w\ height=\$h\\n; Or maybe you're talking about something more complex and at this time in the morning I can't figure out what is it... ;-) A problem with your html method is that you still need to download the original big file to display the thumbnail. One purpose of thumbnails is to speed up the download time, so you want real smaller thumbnail files. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: base-filename without modules
On Sat, Jul 26, 2003 at 08:24:50AM -0700, Bryan Harris wrote: Is there a generally accepted way to get the base of a filename, i.e. strip off the multi-letter extension without using any modules? I've been doing something like this: $fname = shift; $fname =~ s/\.[^.]+$//; It feels a little hokey, though. Maybe it's just me. Sure, that's fine -- but why don't you want to use modules? File::Basename has been in the core distribution for a long time. -- Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to read multiple files in the same time ?
How can I do this ? Or could it be done ? Open some files ( unknown number of files ), depends on users demand. Then start looking for some desired line ( use regex ). I have an array to carry the info of matched data ( from which file, which line ). while the $#array is 99 and all files would be closed Result is then print to screen. However, I am trying not to use looping process like : open all files, then read a line from file A and try matching, then read a line from file B and try matching,, then read a line from file C and try matching, until eof of all files or $#result == 99. and close all file handles... I hope folks here can understand what I am asking about. Thanks in advise
\r\n\r\n or \n\n or \r\n or \n... What is the term / name for this?
RE: IDE for Perl Development
Open PERL IDE is a very good PERL dvelopment environment. But it only runs on Windows. For linux vim or EMACS might be good. http://open-perl-ide.sourceforge.net/ RD -Original Message- From: Trevor Morrison [mailto:[EMAIL PROTECTED] Sent: Thursday, July 24, 2003 7:54 PM To: [EMAIL PROTECTED] Subject: IDE for Perl Development HI, Is there any type of IDE that I can use for Perl programming (free of course) that will run both on Windows 2000 and Linux? TIA Trevor -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Logfile processing
Hello, I am trying to process a log file. The format of log file is something like this: datetimecodeActionDescription The file can be between 100-200MB. The problem is that we don't know the code numbers in advance. I want to count the number of times each code entry occurred in the file. I would like to get the output in this format: CodeCount Code#1xxx times Code#2yyy time .. and so on. Should I make an array of each unique code and count its occurance or is there a better way to do it? Thanks in advance. Sayeed -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Kinda Perl
Yesterday, [EMAIL PROTECTED] wrote: I have been writing perl along with some other languages, and I have been thinking about setting up a server (so that I can play with different server OS's and settings without messing anything up on our home network). My parents think that it will cost to much in power. I was just wondering if anyone knows about how much it is per day to run a computer without a monitor. This might help: I live in South Texas (Houston, to be exact), and run a Celeron-300 class machine, two dual-processor Celeron-600 class machines, two monitors, an array of peripherals, and two UPSs (all 24/7 except for the monitors, which are on about 10 hours a day)--and in the summertime heat my electric bill (average 10 cents/Kilowatt-hour) is still around $150 a month. So yes, the machines do eat a bit of electricity, but replace some standard incandescent bulbs with florescent, and it'll balance out. Paul -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to pass CODE reference in hash?
I hope to design an interface of a function like this (not in OO way) : sub tell_error { print Error for @_ } sub Check_err { my %argv = @_; } Check_err ( TYPE = [1, 1, \tell_error('Type')], DATA = [ 1, 2, \tell_error ('Data')] ); In Check_err, I want tell_error ('Type') runs when ${argv{TYPE}}[0] ${argv{TYPE}}[1] both == 1 but do nothing if that's not the case... $argv{DATA} also doing the same thing... What I've wrote make tell_error directly run before I go inside Check_err... Any pointers ? Must I pass in a $scalar code and eval it ? Thanks in advise.
Re: How to pass CODE reference in hash?
sub tell_error { print Error for @_ } Check_err ( TYPE = [1, 1, \tell_error('Type')], DATA = [ 1, 2, \tell_error ('Data')] ); You can't take a reference to a function WITH ARGUMENTS. You must either do foo = \function or foo = sub { function(args) } Since you want to pass arguments, I'd say the second option is what you want. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regex(?)
Douglass Franklin wrote: I'm trying to transform this html table to a colon-delimited flat-file Why colon separated? What if one of the fields has a colon? database. This is what I have so far: HTML: trtd class='bodyblack' width='50%'a href='http://jsearch.usajobs.opm.gov/summary.asp?OPMControl=IC9516' class='jobrlist'font size='2'ACCOUNTANT /font/a/tdtd class='bodyblack' width='40%'$24,701.00 - $51,971.00 /tdtd class='bodyblack'INDEFINITE/td/tr trtd class='bodyblack'CONTINENTAL U.S., US/td /trtd class='bodyblack' colspan='3'nbsp /td/tr Database Record (wanted): Accountant:$24,701.00 - $51,971.00:INDEFINITE:CONTINENTAL U.S., US Regex I have: $jobrecord =~ ^(tr)(td class='bodyblack' width='50%')(.+)(nbsp /td/tr)$ However, this doesn't seem to be working. Please help. This will work and was tested on the attached page from http://jsearch.usajobs.opm.gov/ #!/usr/bin/perl use warnings; use strict; use HTML::TokeParser; my $p = HTML::TokeParser-new( 'page1.html' ) or die Cannot open page1.html: $!; my @data; TABLE: while ( my $token = $p-get_token() ) { my @table; if ( $token-[ 0 ] eq 'S' and $token-[ 1 ] eq 'center' ) { $token = $p-get_token(); if ( $token-[ 0 ] eq 'S' and $token-[ 1 ] eq 'table' ) { $token = $p-get_token(); if ( $token-[ 0 ] eq 'S' and $token-[ 1 ] eq 'tr' ) { $token = $p-get_token(); if ( $token-[ 0 ] eq 'S' and $token-[ 1 ] eq 'td' ) { $token = $p-get_token(); if ( $token-[ 0 ] eq 'S' and $token-[ 1 ] eq 'strong' ) { while ( $token = $p-get_token() ) { push @table, $token-[ 1 ] if $token-[ 0 ] eq 'T'; if ( $token-[ 0 ] eq 'S' and $token-[ 1 ] eq 'center' ) { $p-unget_token( $token ); s/nbsp/ /g, s/^\s+//, s/\s+$// for @table; push @data, join ':', @table; next TABLE; } } } } } } } } print $_\n for @data; __END__ HTH John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Logfile processing
Sayeed Mohammed wrote: Hello, Hello, I am trying to process a log file. The format of log file is something like this: datetimecodeActionDescription The file can be between 100-200MB. The problem is that we don't know the code numbers in advance. I want to count the number of times each code entry occurred in the file. I would like to get the output in this format: CodeCount Code#1xxx times Code#2yyy time .. and so on. Should I make an array of each unique code and count its occurance or is there a better way to do it? Use a hash for the code count: my %code_count; while ( LOG ) { my $code = get_code_number_somehow(); $code_count{ $code }++; } print CodeCount\n; for my $code ( keys %code_count ) { printf %-12s%s\n $code, $code_count{ $code }; } __END__ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regex(?)
John W. Krahn wrote: This will work and was tested on the attached page from http://jsearch.usajobs.opm.gov/ I see that the file didn't get attached. Here it is: !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html head titleUSAJOBS Job Result List/title meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 link href=/styles/rosusajobs.css rel=stylesheet type=text/css script language=JavaScript type=text/JavaScript !-- function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; ia.length; i++) if (a[i].indexOf(#)!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;aia.length(x=a[i])x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf(?))0parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])d.all) x=d.all[n]; for (i=0;!xid.forms.length;i++) x=d.forms[i][n]; for(i=0;!xd.layersid.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } function MM_goToURL() { //v3.0 var i, args=MM_goToURL.arguments; document.MM_returnValue = false; for (i=0; i(args.length-1); i+=2) eval(args[i]+.location='+args[i+1]+'); } //-- /script /head body bgcolor=#FF leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onLoad=MM_preloadImages('rosimages/tab_but_srch_over.gif','rosimages/tab_but_1st_over.gif','rosimages/tab_but_build_over.gif') table summary=This table contains the U S A Jobs logo with the caption, working for America width=600 border=0 cellspacing=0 cellpadding=0 tr tda href=http://www.usajobs.opm.gov/index.htm;img src=rosimages/top1_logo.gif alt=USAJOBS logo and link to main page width=223 height=48 border=0/aimg src=rosimages/top2.gif alt=Working for America, OPM logo and link to OPM home page width=377 height=48 border=0 usemap=#Map/td /tr /table table width=600 border=0 cellpadding=0 cellspacing=0 background=rosimages/nav_top_bkgrd.gif bgcolor=#CC summary=This table contains navigational links tr td width=20 background=rosimages/nav_top_bkgrd.gif bgcolor=#CC class=bodyblack div align=centera href=#SkipNavigationBarimg src=rosimages/spacer.gif alt=Skip navigation and go to to main section width=1 height=1 border=0/a/div/td td width=501 align=left valign=middle div align=center class=bodyblack a href=http://www.usajobs.opm.gov/a.htm;Job Search/a #8226; a href=http://profiler.usajobs.opm.gov;USAJOBS by Email/a #8226; a href=http://www.usajobs.opm.gov/b.htm;FAQs/a #8226; a href=http://www.usajobs.opm.gov/forms.htm;Forms/a/div/td td width=79 align=left valign=topa href=http://www.opm.gov;img src=rosimages/opm_logo.gif alt=OPM logo and link to OPM home page width=79 height=20 border=0/a/td /tr /table map name=Map area shape=rect coords=300,2,365,47 href=http://www.opm.gov; alt=link to OPM home page www.opm.gov /map table summary= width=600 border=0 cellpadding=0 cellspacing=0 bgcolor=#CC tr td align=left valign=topimg src=rosimages/spacer.gif alt= width=20 height=10/td /tr /table table summary=This table contains links to the three major sections; Search Jobs, First Timers Start Here, and Build Your Resume width=600 border=0 cellpadding=0 cellspacing=0 bgcolor=#CC tr align=left valign=top td width=20img src=rosimages/spacer.gif alt= width=20 height=28/td td width=175img src=rosimages/tab_but_srch_on.gif alt=Search Jobs button width=175 height=28/td td width=25img src=rosimages/tab_end_srch_on.gif alt= width=25 height=28/td td width=177a href=http://www.usajobs.opm.gov/first.htm; onMouseOut=MM_swapImgRestore() onMouseOver=MM_swapImage('1st_but','','rosimages/tab_but_1st_over.gif',1)img src=rosimages/tab_but_1st_off.gif alt=First Timers Start Here button name=1st_but width=177 height=28 border=0 title=First Timers Start Here button/a/td td width=25img src=rosimages/tab_end_build_off.gif alt= width=25 height=28/td td width=178a href=https://resume.usajobs.opm.gov; onMouseOut=MM_swapImgRestore() onMouseOver=MM_swapImage('build_but','','rosimages/tab_but_build_over.gif',1) title=Build Your Resume buttonimg src=rosimages/tab_but_build_off.gif alt=Build Your Resume button name=build_but width=178 height=28 border=0/a/td /tr /table table summary= width=600 border=0 cellpadding=0 cellspacing=0 bgcolor=#CC tr align=left valign=top td width=20 height=10 img src=rosimages/spacer.gif alt= width=20 height=10/td td width=1
Notetab-like Perl editor?
Questions about editors have been asked many times, but i'm going to be a little more specific. I am in a Windows environment, and i love NotaTab. It is one of the few tools that makes me wonder how could i ever have carried on without it. Only it doesn't do syntax highlighting. I have searched for add-ons but i didn't found anything. It lets you apply Perl script as macros on the documents you are editing, but it doesn't syntax highlighting. I tried others editor with syntax highlighting, but they are very different from NoteTab and i didn't like them. Does anybody know if there is a way to improve NoteTab with this feature, or if there is another editor very similar to NoteTab (i mean appeareance, keys shortcuts, and all) but with this feature included? Thank you for your time. -- Zanardi2k3 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Notetab-like Perl editor?
This the best text editor I've ever used and I use it exclusively for PERL. Additionally, it has the features you are interested in http://www.ultraedit.com/ Shareware: $35 a year. Web Hosting Development http://www.decattus.com - Original Message - From: Zanardi2k3 [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, July 26, 2003 6:54 PM Subject: Notetab-like Perl editor? Questions about editors have been asked many times, but i'm going to be a little more specific. I am in a Windows environment, and i love NotaTab. It is one of the few tools that makes me wonder how could i ever have carried on without it. Only it doesn't do syntax highlighting. I have searched for add-ons but i didn't found anything. It lets you apply Perl script as macros on the documents you are editing, but it doesn't syntax highlighting. I tried others editor with syntax highlighting, but they are very different from NoteTab and i didn't like them. Does anybody know if there is a way to improve NoteTab with this feature, or if there is another editor very similar to NoteTab (i mean appeareance, keys shortcuts, and all) but with this feature included? Thank you for your time. -- Zanardi2k3 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Save a connection inside an object?
Hi all! Im creating a class named DemoDB, the purpouse of this class its to give data. For example, I create an object: $object = new DemoDB; And I want to retrieve data (the name of the leader), so $object-get_leadername(); Ok, the questions its inside the class. I have this: sub new { my $this = shift; #Tomar el objeto de donde viene my $clase = ref($this) || $this; #Tomar el nombre de la clase my $dDB = {}; $dDB-{LINK} = DBI-connect(DBI:mysql:$basedatos_nombre:$basedatos_servidor, $basedatos_usuario,$basedatos_password); bless($dDB, $clase); return $dDB; } The big question, is it valid to save the 'link connection', inside $dDB-{LINK}?, so I can use it in other methods. Thanks!!! Pablo -- Pablo Fischer Sandoval ([EMAIL PROTECTED]) http://www.pablo.com.mx http://www.debianmexico.org GPG FingerTip: 3D49 4CB8 8951 F2CA 8131 AF7C D1B9 1FB9 6B11 810C Firma URL: http://www.pablo.com.mx/firmagpg.txt -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Save a connection inside an object?
On Jul 26, Pablo Fischer said: sub new { my $this = shift; #Tomar el objeto de donde viene my $clase = ref($this) || $this; #Tomar el nombre de la clase my $dDB = {}; $dDB-{LINK} = DBI-connect(DBI:mysql:$basedatos_nombre:$basedatos_servidor, $basedatos_usuario,$basedatos_password); bless($dDB, $clase); return $dDB; } The big question, is it valid to save the 'link connection', inside $dDB-{LINK}?, so I can use it in other methods. Absolutely. It's perfectly fine to do that. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Kinda Perl
[EMAIL PROTECTED] writes: I have been writing perl along with some other languages, and I have been thinking about setting up a server (so that I can play with different server OS's and settings without messing anything up on our home network). My parents think that it will cost to much in power. I was just wondering if anyone knows about how much it is per day to run a computer without a monitor. Brian, Most computers today have around a 300 watt power supply - if your system were running at maximum capacity, all the time (which never, ever, happens), that's .3 kilowatts. At $0.10/kilowatt-hour, that's 3 cents per hour - 168 hours in a week is $5.04/wk, approximately 4 weeks in a month gives you $20.16/mo. Now, your system is never fully loaded, so the actual cost is going to be much lower. Not to mention using various power-saving features, etc. If I had to guess, I'd say $5/mo. -RN -- Robin Norwood Red Hat, Inc. The Sage does nothing, yet nothing remains undone. -Lao Tzu, Te Tao Ching -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Case Statement
Hello Again! I need to evaluate a lot of conditionals, and of course the use of a lot of if's its not the 'right' way, so Im using something like this: CASE: { ($string == match1) do { actions.. last CASE; }; ($string == match2) do { actions.. last CASE; }; and a lot more.. } The question, where does the 'default' case starts?. The last 5 years I have been programming in C/C++/C#/Php.. C-styles languages, so in Perl, where does the 'default' case begins? Thanks Pablo -- Pablo Fischer Sandoval ([EMAIL PROTECTED]) http://www.pablo.com.mx http://www.debianmexico.org GPG FingerTip: 3D49 4CB8 8951 F2CA 8131 AF7C D1B9 1FB9 6B11 810C Firma URL: http://www.pablo.com.mx/firmagpg.txt -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: perl program
Visu [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] above steps to a complex script fo which i got the following error message. ## /usr/bin/perlcc: multipleanalyseV5.0.pl did not compile, which can't happen: Starting compile Walking tree Prescan Saving methods ## not sure what could cause this but from the error message, it's probably a bug in perlcc. that's why it's experimental. try perlcc with the '-verbose 7' option might tell you what perlcc is having problem. david btw, is this the only error message perlcc splits out? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]