Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > if (/^$date\s+(.+)/)

Reply
Thread Tools

if (/^$date\s+(.+)/)

 
 
April
Guest
Posts: n/a
 
      10-29-2008

{
printf "%2d. ", $count;
print "$1\n";
}

what would be true for /^$date\s+(.+)/? \s+ matches one or more white
spaces, and (.+) matches the rest?
 
Reply With Quote
 
 
 
 
Tim Greer
Guest
Posts: n/a
 
      10-29-2008
April wrote:

>
> {
> printf "%2d. ", $count;
> print "$1\n";
> }


^^^^^^^^^^

Is the above supposed to relate to your question?

> what would be true for /^$date\s+(.+)/? \s+ matches one or more white
> spaces, and (.+) matches the rest?


..+ matches anything (one or more characters) after the start of the line
^ and whatever $date is, one or more white spaces and then captures
whatever follows it. You might want to be more specific if you want to
match up to the end of the line $ or include new lines, or only match
up to a certain length or character, etc. So, yes and no, depending.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
 
Reply With Quote
 
 
 
 
April
Guest
Posts: n/a
 
      10-29-2008
On Oct 29, 1:58*am, Tim Greer <(E-Mail Removed)> wrote:
> April wrote:
>
> > * * * * * * {
> > * * * * * * * * printf "%2d. ", $count;
> > * * * * * * * * print "$1\n";
> > * * * * * * }

>
> ^^^^^^^^^^
>
> Is the above supposed to relate to your question?
>
> > what would be true for /^$date\s+(.+)/? *\s+ matches one or more white
> > spaces, and (.+) matches the rest?

>
> .+ matches anything (one or more characters) after the start of the line
> ^ and whatever $date is, one or more white spaces and then captures
> whatever follows it. *You might want to be more specific if you want to
> match up to the end of the line $ or include new lines, or only match
> up to a certain length or character, etc. *So, yes and no, depending.
> --
> Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
> Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
> and Custom Hosting. *24/7 support, 30 day guarantee, secure servers.
> Industry's most experienced staff! -- Web Hosting With Muscle!


thanks Tim .. then what would be true here, something started with
$date exists?
 
Reply With Quote
 
Josef Moellers
Guest
Posts: n/a
 
      10-29-2008
Tim Greer wrote:
> April wrote:
>
>> {
>> printf "%2d. ", $count;
>> print "$1\n";
>> }

>
> ^^^^^^^^^^
>
> Is the above supposed to relate to your question?


It's probably cut and pasted from the assignment sheet.

--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html
 
Reply With Quote
 
April
Guest
Posts: n/a
 
      10-29-2008
On Oct 29, 8:39*am, Josef Moellers <josef.moell...@fujitsu-
siemens.com> wrote:
> Tim Greer wrote:
> > April wrote:

>
> >> * * * * * * {
> >> * * * * * * * * printf "%2d. ", $count;
> >> * * * * * * * * print "$1\n";
> >> * * * * * * }

>
> > ^^^^^^^^^^

>
> > Is the above supposed to relate to your question?

>
> It's probably cut and pasted from the assignment sheet.
>
> --
> These are my personal views and not those of Fujitsu Siemens Computers!
> Josef Möllers (Pinguinpfleger bei FSC)
> * * * * If failure had no penalty success would not be a prize (T.. *Pratchett)
> Company Details:http://www.fujitsu-siemens.com/imprint.html


yes, that is the block to be executed, depending on the if test
result ..
 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      10-29-2008
April <(E-Mail Removed)> wrote:
>
> {
> printf "%2d. ", $count;
> print "$1\n";
> }


???

>what would be true for /^$date\s+(.+)/? \


You question is confusing. Did you mean to ask: Which strings are
matched by that RE?

Answer to that question:
Any string, that
- starts with
- whatever is matched by the RE stored in $date
and then

>\s+ matches one or more white

-has at least one white space

>spaces, and (.+) matches the rest?

- and then at least one other character

jue
 
Reply With Quote
 
April
Guest
Posts: n/a
 
      10-29-2008
On Oct 29, 10:38*am, Glenn Jackman <(E-Mail Removed)> wrote:
> At 2008-10-28 11:17PM, "April" wrote:
>
> > * * * * * * *if (/^$date\s+(.+)/)
> > * * * * * * *{
> > * * * * * * * * *printf "%2d. ", $count;
> > * * * * * * * * *print "$1\n";
> > * * * * * * *}

>
> > *what would be true for /^$date\s+(.+)/?

>
> That depends on the current line ($_) and the value of $date.
>
> You need to provide more info if you expect to receive any help. *
>
> --
> Glenn Jackman
> * * Write a wise saying and your name will live forever. -- Anonymous


I'm looking for the meaning of that test, not an actual answer in the
program context.
 
Reply With Quote
 
April
Guest
Posts: n/a
 
      10-29-2008
On Oct 29, 11:59*am, Jürgen Exner <(E-Mail Removed)> wrote:
> April <(E-Mail Removed)> wrote:
>
> > * * * * * *{
> > * * * * * * * *printf "%2d. ", $count;
> > * * * * * * * *print "$1\n";
> > * * * * * *}

>
> ???
>
> >what would be true for /^$date\s+(.+)/? *\

>
> You question is confusing. Did you mean to ask: Which strings are
> matched by that RE?
>
> Answer to that question:
> Any string, that
> - starts with
> - whatever is matched by the RE stored in $date
> and then
>
> >\s+ matches one or more white

>
> -has at least one white space
>
> >spaces, and (.+) matches the rest?

>
> - and then at least one other character
>
> jue


my question should be restated as what makes the if test true, if (/^
$date\s+(.+)/)?
 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      10-29-2008
April <(E-Mail Removed)> wrote:

if (/^$date\s+(.+)/)

>my question should be restated as what makes the if test true, if (/^
>$date\s+(.+)/)?


Ok, that is easy. The condition is true if and only if the regular
expression /^$date\s+(.+)/ matches the text content of $_.

jue
 
Reply With Quote
 
April
Guest
Posts: n/a
 
      10-29-2008
On Oct 29, 12:46*pm, Jürgen Exner <(E-Mail Removed)> wrote:
> April <(E-Mail Removed)> wrote:
>
> * * * * * * * * if (/^$date\s+(.+)/)
>
> >my question should be restated as what makes the if test true, if (/^
> >$date\s+(.+)/)?

>
> Ok, that is easy. The condition is true if and only if *the regular
> expression /^$date\s+(.+)/ matches the text content of $_.
>
> jue


k thank you Jue and everyone I think with this and the explanation of
the re/pattern, I'm all set and thanks again.
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments