LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-04-2011, 06:20 AM   #1
qrange
Senior Member
 
Registered: Jul 2006
Location: Belgrade, Yugoslavia
Distribution: Debian stable/testing, amd64
Posts: 1,061

Rep: Reputation: 47
perl problem


sorry if this is offtopic..

I got a problem in perl, this line:

Code:
if( $text =~ /^\s*\d+-\d+-\d+\s+(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)\s*$/i ){
should match this line:
2011-06-27 Monday

but it doesn't
why?
 
Old 07-04-2011, 07:03 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,006

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Seems to work just fine for me??
 
Old 07-04-2011, 09:45 AM   #3
qrange
Senior Member
 
Registered: Jul 2006
Location: Belgrade, Yugoslavia
Distribution: Debian stable/testing, amd64
Posts: 1,061

Original Poster
Rep: Reputation: 47
hm, perhaps then the problem is that line ends with CR+LF?
 
Old 07-04-2011, 01:49 PM   #4
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Hello grange,

first thing, use the report button at the bottom of your post and ask a moderator to move this thread to the "Programming" forum of LQ: http://www.linuxquestions.org/questions/programming-9/

And please post more of your code, we'll need to see this line of code in relationship to the whole script in order to answer your question.

If the problem comes from the "CR-LF" you may use
Code:
if( $text =~ /^\s*\d+-\d+-\d+\s+(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday).*/i ){
which makes the end of the pattern independent of the following linebreak (which differs on Linux or Windows respectively).

Markus
 
1 members found this post helpful.
Old 07-04-2011, 06:44 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Moved: This thread is more suitable in <PROGRAMMING> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 07-05-2011, 02:10 AM   #6
qrange
Senior Member
 
Registered: Jul 2006
Location: Belgrade, Yugoslavia
Distribution: Debian stable/testing, amd64
Posts: 1,061

Original Poster
Rep: Reputation: 47
solved. the problem was that input file contained some nonprintable characters at beginning of line, so this did the trick:
Code:
 if( $text =~ /^.*\d+-\d+-\d+\s+(monday|tuesday|wednesday|thursday|friday|saturday|sunday)\s*$/i ){
 
  


Reply

Tags
[perl]



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with perl modules declaration and perl/cgi script shifter Programming 9 02-24-2010 09:09 AM
need perl help...perl module problem john83reuben Programming 2 03-22-2008 09:08 PM
Problem with perl module for w3c validator to work on my local Apache+PHP+perl instal tbamt Linux - Software 0 12-16-2004 05:37 PM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM
perl problem? apache problem? cgi problem? WorldBuilder Linux - Software 1 09-17-2003 07:45 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration